diff options
Diffstat (limited to 'tools/power/cpupower/utils/helpers/topology.c')
-rw-r--r-- | tools/power/cpupower/utils/helpers/topology.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/tools/power/cpupower/utils/helpers/topology.c b/tools/power/cpupower/utils/helpers/topology.c index cea398c176e7..9cbb7fd75171 100644 --- a/tools/power/cpupower/utils/helpers/topology.c +++ b/tools/power/cpupower/utils/helpers/topology.c | |||
@@ -73,18 +73,22 @@ int get_cpu_topology(struct cpupower_topology *cpu_top) | |||
73 | for (cpu = 0; cpu < cpus; cpu++) { | 73 | for (cpu = 0; cpu < cpus; cpu++) { |
74 | cpu_top->core_info[cpu].cpu = cpu; | 74 | cpu_top->core_info[cpu].cpu = cpu; |
75 | cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu); | 75 | cpu_top->core_info[cpu].is_online = sysfs_is_cpu_online(cpu); |
76 | if (!cpu_top->core_info[cpu].is_online) | ||
77 | continue; | ||
78 | if(sysfs_topology_read_file( | 76 | if(sysfs_topology_read_file( |
79 | cpu, | 77 | cpu, |
80 | "physical_package_id", | 78 | "physical_package_id", |
81 | &(cpu_top->core_info[cpu].pkg)) < 0) | 79 | &(cpu_top->core_info[cpu].pkg)) < 0) { |
82 | return -1; | 80 | cpu_top->core_info[cpu].pkg = -1; |
81 | cpu_top->core_info[cpu].core = -1; | ||
82 | continue; | ||
83 | } | ||
83 | if(sysfs_topology_read_file( | 84 | if(sysfs_topology_read_file( |
84 | cpu, | 85 | cpu, |
85 | "core_id", | 86 | "core_id", |
86 | &(cpu_top->core_info[cpu].core)) < 0) | 87 | &(cpu_top->core_info[cpu].core)) < 0) { |
87 | return -1; | 88 | cpu_top->core_info[cpu].pkg = -1; |
89 | cpu_top->core_info[cpu].core = -1; | ||
90 | continue; | ||
91 | } | ||
88 | } | 92 | } |
89 | 93 | ||
90 | qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info), | 94 | qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info), |
@@ -95,12 +99,15 @@ int get_cpu_topology(struct cpupower_topology *cpu_top) | |||
95 | done by pkg value. */ | 99 | done by pkg value. */ |
96 | last_pkg = cpu_top->core_info[0].pkg; | 100 | last_pkg = cpu_top->core_info[0].pkg; |
97 | for(cpu = 1; cpu < cpus; cpu++) { | 101 | for(cpu = 1; cpu < cpus; cpu++) { |
98 | if(cpu_top->core_info[cpu].pkg != last_pkg) { | 102 | if (cpu_top->core_info[cpu].pkg != last_pkg && |
103 | cpu_top->core_info[cpu].pkg != -1) { | ||
104 | |||
99 | last_pkg = cpu_top->core_info[cpu].pkg; | 105 | last_pkg = cpu_top->core_info[cpu].pkg; |
100 | cpu_top->pkgs++; | 106 | cpu_top->pkgs++; |
101 | } | 107 | } |
102 | } | 108 | } |
103 | cpu_top->pkgs++; | 109 | if (!cpu_top->core_info[0].pkg == -1) |
110 | cpu_top->pkgs++; | ||
104 | 111 | ||
105 | /* Intel's cores count is not consecutively numbered, there may | 112 | /* Intel's cores count is not consecutively numbered, there may |
106 | * be a core_id of 3, but none of 2. Assume there always is 0 | 113 | * be a core_id of 3, but none of 2. Assume there always is 0 |