Lines Matching refs:cpu_top
126 * Returns amount of cpus, negative on error, cpu_top must be
131 int get_cpu_topology(struct cpupower_topology *cpu_top)
135 cpu_top->core_info = malloc(sizeof(struct cpuid_core_info) * cpus);
136 if (cpu_top->core_info == NULL)
138 cpu_top->pkgs = cpu_top->cores = 0;
140 cpu_top->core_info[cpu].cpu = cpu;
141 cpu_top->core_info[cpu].is_online = cpupower_is_cpu_online(cpu);
145 &(cpu_top->core_info[cpu].pkg)) < 0) {
146 cpu_top->core_info[cpu].pkg = -1;
147 cpu_top->core_info[cpu].core = -1;
153 &(cpu_top->core_info[cpu].core)) < 0) {
154 cpu_top->core_info[cpu].pkg = -1;
155 cpu_top->core_info[cpu].core = -1;
160 qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info),
166 last_pkg = cpu_top->core_info[0].pkg;
168 if (cpu_top->core_info[cpu].pkg != last_pkg &&
169 cpu_top->core_info[cpu].pkg != -1) {
171 last_pkg = cpu_top->core_info[cpu].pkg;
172 cpu_top->pkgs++;
175 if (!(cpu_top->core_info[0].pkg == -1))
176 cpu_top->pkgs++;
181 for (cpu = 0; cpu_top->core_info[cpu].pkg = 0 && cpu < cpus; cpu++) {
182 if (cpu_top->core_info[cpu].core == 0)
183 cpu_top->cores++;
188 void cpu_topology_release(struct cpupower_topology cpu_top)
190 free(cpu_top.core_info);