diff options
Diffstat (limited to 'tools/power')
-rw-r--r-- | tools/power/cpupower/utils/helpers/helpers.h | 17 | ||||
-rw-r--r-- | tools/power/cpupower/utils/helpers/topology.c | 14 |
2 files changed, 12 insertions, 19 deletions
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 2eb584cf2f55..f84985f630e2 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h | |||
@@ -92,6 +92,14 @@ extern int get_cpu_info(unsigned int cpu, struct cpupower_cpu_info *cpu_info); | |||
92 | extern struct cpupower_cpu_info cpupower_cpu_info; | 92 | extern struct cpupower_cpu_info cpupower_cpu_info; |
93 | /* cpuid and cpuinfo helpers **************************/ | 93 | /* cpuid and cpuinfo helpers **************************/ |
94 | 94 | ||
95 | struct cpuid_core_info { | ||
96 | int pkg; | ||
97 | int core; | ||
98 | int cpu; | ||
99 | |||
100 | /* flags */ | ||
101 | unsigned int is_online:1; | ||
102 | }; | ||
95 | 103 | ||
96 | /* CPU topology/hierarchy parsing ******************/ | 104 | /* CPU topology/hierarchy parsing ******************/ |
97 | struct cpupower_topology { | 105 | struct cpupower_topology { |
@@ -101,14 +109,7 @@ struct cpupower_topology { | |||
101 | unsigned int threads; /* per core */ | 109 | unsigned int threads; /* per core */ |
102 | 110 | ||
103 | /* Array gets mallocated with cores entries, holding per core info */ | 111 | /* Array gets mallocated with cores entries, holding per core info */ |
104 | struct { | 112 | struct cpuid_core_info *core_info; |
105 | int pkg; | ||
106 | int core; | ||
107 | int cpu; | ||
108 | |||
109 | /* flags */ | ||
110 | unsigned int is_online:1; | ||
111 | } *core_info; | ||
112 | }; | 113 | }; |
113 | 114 | ||
114 | extern int get_cpu_topology(struct cpupower_topology *cpu_top); | 115 | extern int get_cpu_topology(struct cpupower_topology *cpu_top); |
diff --git a/tools/power/cpupower/utils/helpers/topology.c b/tools/power/cpupower/utils/helpers/topology.c index 216f3e3466ce..4e2b583ea17b 100644 --- a/tools/power/cpupower/utils/helpers/topology.c +++ b/tools/power/cpupower/utils/helpers/topology.c | |||
@@ -36,14 +36,6 @@ static int sysfs_topology_read_file(unsigned int cpu, const char *fname, int *re | |||
36 | return 0; | 36 | return 0; |
37 | } | 37 | } |
38 | 38 | ||
39 | struct cpuid_core_info { | ||
40 | unsigned int pkg; | ||
41 | unsigned int thread; | ||
42 | unsigned int cpu; | ||
43 | /* flags */ | ||
44 | unsigned int is_online:1; | ||
45 | }; | ||
46 | |||
47 | static int __compare(const void *t1, const void *t2) | 39 | static int __compare(const void *t1, const void *t2) |
48 | { | 40 | { |
49 | struct cpuid_core_info *top1 = (struct cpuid_core_info *)t1; | 41 | struct cpuid_core_info *top1 = (struct cpuid_core_info *)t1; |
@@ -52,9 +44,9 @@ static int __compare(const void *t1, const void *t2) | |||
52 | return -1; | 44 | return -1; |
53 | else if (top1->pkg > top2->pkg) | 45 | else if (top1->pkg > top2->pkg) |
54 | return 1; | 46 | return 1; |
55 | else if (top1->thread < top2->thread) | 47 | else if (top1->core < top2->core) |
56 | return -1; | 48 | return -1; |
57 | else if (top1->thread > top2->thread) | 49 | else if (top1->core > top2->core) |
58 | return 1; | 50 | return 1; |
59 | else if (top1->cpu < top2->cpu) | 51 | else if (top1->cpu < top2->cpu) |
60 | return -1; | 52 | return -1; |
@@ -74,7 +66,7 @@ int get_cpu_topology(struct cpupower_topology *cpu_top) | |||
74 | { | 66 | { |
75 | int cpu, cpus = sysconf(_SC_NPROCESSORS_CONF); | 67 | int cpu, cpus = sysconf(_SC_NPROCESSORS_CONF); |
76 | 68 | ||
77 | cpu_top->core_info = malloc(sizeof(struct cpupower_topology) * cpus); | 69 | cpu_top->core_info = malloc(sizeof(struct cpuid_core_info) * cpus); |
78 | if (cpu_top->core_info == NULL) | 70 | if (cpu_top->core_info == NULL) |
79 | return -ENOMEM; | 71 | return -ENOMEM; |
80 | cpu_top->pkgs = cpu_top->cores = 0; | 72 | cpu_top->pkgs = cpu_top->cores = 0; |