Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the CPU facts Hyperthreading aware #3427

Merged
merged 1 commit into from
Jul 3, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 14 additions & 6 deletions library/system/setup
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,9 @@ class LinuxHardware(Hardware):
def get_cpu_facts(self):
i = 0
physid = 0
coreid = 0
sockets = {}
cores = {}
if not os.access("/proc/cpuinfo", os.R_OK):
return
self.facts['processor'] = []
Expand All @@ -536,14 +538,20 @@ class LinuxHardware(Hardware):
physid = data[1].strip()
if physid not in sockets:
sockets[physid] = 1
elif key == 'core id':
coreid = data[1].strip()
if coreid not in sockets:
cores[coreid] = 1
elif key == 'cpu cores':
sockets[physid] = int(data[1].strip())
if len(sockets) > 0:
self.facts['processor_count'] = len(sockets)
self.facts['processor_cores'] = reduce(lambda x, y: x + y, sockets.values())
else:
self.facts['processor_count'] = i
self.facts['processor_cores'] = 'NA'
elif key == 'siblings':
cores[coreid] = int(data[1].strip())
self.facts['processor_count'] = sockets and len(sockets) or i
self.facts['processor_cores'] = sockets.values() and sockets.values()[0] or 1
self.facts['processor_threads_per_core'] = ((cores.values() and
cores.values()[0] or 1) / self.facts['processor_cores'])
self.facts['processor_vcpus'] = (self.facts['processor_threads_per_core'] *
self.facts['processor_count'] * self.facts['processor_cores'])

def get_dmi_facts(self):
''' learn dmi facts from system
Expand Down