phctool-0.5.2.2_kernel_2.6.36.patch 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --- phctool/inc/libs/cpuinfo.py
  2. +++ phctool/inc/libs/cpuinfo.py
  3. @@ -14,33 +14,49 @@
  4. def _get_acpi_cpus(self):
  5. - ##count number of CPUs on this system using acpi proc interface
  6. - ##since we need acpi this i a good way to count CPUs
  7. - ##we also will remember the Directory-Name because on single CPU
  8. - ##systems the Dir may be named CPU while on Multicores they are indexed (CPU0, CPU1) ..
  9. - directory="/proc/acpi/processor/"
  10. - for f in os.listdir(directory): ##iterate the directory
  11. - pathname = os.path.join(directory, f) ##
  12. - if os.path.isdir(pathname): ##is the object we found really a (sub-)directory?
  13. - ##We open the info-file to get the ID to this CPU,
  14. - ##i don't know if this really could happen but the ID may differ from
  15. - ##from the Path iterator (maybe one CPU is supported and another isn't)
  16. - if os.path.exists(pathname+'/info'):
  17. - file = open(pathname+'/info', 'r');
  18. - for line in file:
  19. - if string.find(line,":"):
  20. - content = line.split(":");
  21. - if len(content)>1:
  22. - info_ident=content[0].strip();
  23. - info_value=content[1].strip();
  24. - if info_ident == "processor id":
  25. - cpunr=info_value
  26. - self.data[cpunr]={}
  27. - self.data[cpunr]['acpi']={}
  28. - self.data[cpunr]['acpi']['exist']=True
  29. - self.data[cpunr]['acpi']['acpiname']=f ##remember ACPI Pathname
  30. - else:
  31. - self.data[cpunr]['acpi']['exist']=False
  32. + # We need to ignore /proc/acpi/processor as it's becoming deprecated
  33. + # A good solution might be a look in online cpus, but it doesn't mean they are surely ACPI-supported
  34. + if os.path.exists('/sys/devices/system/cpu/online'):
  35. + file = open('/sys/devices/system/cpu/online', 'r');
  36. + for line in file:
  37. + if string.find(line,"-"):
  38. + content = line.split("-");
  39. + for val in content:
  40. + cpunr=val.strip();
  41. + self.data[cpunr]={}
  42. + self.data[cpunr]['acpi']={}
  43. + self.data[cpunr]['acpi']['exist']=True
  44. + # This sounds useful just for throttling, which is managed better by other stuff... I'll keep just for compatibility
  45. + if os.path.exists('/proc/acpi/processor/CPU'+cpunr):
  46. + ##remember ACPI Pathname
  47. + self.data[cpunr]['acpi']['acpiname']='/proc/acpi/processor/CPU'+cpunr
  48. + else:
  49. + self.data[cpunr]['acpi']['exist']=False
  50. + # For some reason we have to fallback on the old function...
  51. + else:
  52. + directory="/proc/acpi/processor/"
  53. + for f in os.listdir(directory): ##iterate the directory
  54. + pathname = os.path.join(directory, f) ##
  55. + if os.path.isdir(pathname): ##is the object we found really a (sub-)directory?
  56. + ##We open the info-file to get the ID to this CPU,
  57. + ##i don't know if this really could happen but the ID may differ from
  58. + ##from the Path iterator (maybe one CPU is supported and another isn't)
  59. + if os.path.exists(pathname+'/info'):
  60. + file = open(pathname+'/info', 'r');
  61. + for line in file:
  62. + if string.find(line,":"):
  63. + content = line.split(":");
  64. + if len(content)>1:
  65. + info_ident=content[0].strip();
  66. + info_value=content[1].strip();
  67. + if info_ident == "processor id":
  68. + cpunr=info_value
  69. + self.data[cpunr]={}
  70. + self.data[cpunr]['acpi']={}
  71. + self.data[cpunr]['acpi']['exist']=True
  72. + self.data[cpunr]['acpi']['acpiname']=f ##remember ACPI Pathname
  73. + else:
  74. + self.data[cpunr]['acpi']['exist']=False
  75. def _get_cpuinfos(self):