Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/power turbostat: Process HT siblings in CPU order

On large systems with HT sibling cpu#'s more than 32 apart,
HT siblings were processed and displayed in reverse order.

This was due to how set_thread_siblings() parsed the
sibling-bit-mask.

Update set_thread_siblings to instead parse the sibling-list,
like other cpu lists, and to thus order HT siblings
by ascending CPU number, no matter the size of the system.

Signed-off-by: Len Brown <len.brown@intel.com>

+31 -49
+31 -49
tools/power/x86/turbostat/turbostat.c
··· 6219 6219 return 0; 6220 6220 } 6221 6221 6222 - int set_thread_siblings(struct cpu_topology *thiscpu) 6223 - { 6224 - char path[80], character; 6225 - FILE *filep; 6226 - unsigned long map; 6227 - int so, shift, sib_core; 6228 - int cpu = thiscpu->cpu_id; 6229 - int offset = topo.max_cpu_num + 1; 6230 - size_t size; 6231 - int ht_id = 0; 6232 - 6233 - thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1)); 6234 - if (thiscpu->ht_id < 0) 6235 - thiscpu->ht_id = 0; /* first CPU in core */ 6236 - if (!thiscpu->put_ids) 6237 - return -1; 6238 - 6239 - size = CPU_ALLOC_SIZE((topo.max_cpu_num + 1)); 6240 - CPU_ZERO_S(size, thiscpu->put_ids); 6241 - 6242 - sprintf(path, "/sys/devices/system/cpu/cpu%d/topology/thread_siblings", cpu); 6243 - filep = fopen(path, "r"); 6244 - 6245 - if (!filep) { 6246 - warnx("%s: open failed", path); 6247 - return -1; 6248 - } 6249 - do { 6250 - offset -= BITMASK_SIZE; 6251 - if (fscanf(filep, "%lx%c", &map, &character) != 2) 6252 - err(1, "%s: failed to parse file", path); 6253 - for (shift = 0; shift < BITMASK_SIZE; shift++) { 6254 - if ((map >> shift) & 0x1) { 6255 - so = shift + offset; 6256 - sib_core = get_core_id(so); 6257 - if (sib_core == thiscpu->core_id) { 6258 - CPU_SET_S(so, size, thiscpu->put_ids); 6259 - cpus[so].ht_id = ht_id; 6260 - cpus[cpu].ht_sibling_cpu_id[ht_id] = so; 6261 - ht_id += 1; 6262 - } 6263 - } 6264 - } 6265 - } while (character == ','); 6266 - fclose(filep); 6267 - 6268 - return CPU_COUNT_S(size, thiscpu->put_ids); 6269 - } 6270 - 6271 6222 /* 6272 6223 * run func(thread, core, package) in topology order 6273 6224 * skip non-present cpus ··· 9488 9537 return 1; 9489 9538 else 9490 9539 return 0; 9540 + } 9541 + 9542 + int set_thread_siblings(struct cpu_topology *thiscpu) 9543 + { 9544 + char path[80]; 9545 + int cpu = thiscpu->cpu_id; 9546 + size_t size; 9547 + int ht_id = 0; 9548 + int i; 9549 + 9550 + thiscpu->put_ids = CPU_ALLOC((topo.max_cpu_num + 1)); 9551 + if (thiscpu->ht_id < 0) 9552 + thiscpu->ht_id = 0; /* first CPU in core */ 9553 + if (!thiscpu->put_ids) 9554 + return -1; 9555 + 9556 + size = CPU_ALLOC_SIZE((topo.max_cpu_num + 1)); 9557 + CPU_ZERO_S(size, thiscpu->put_ids); 9558 + 9559 + sprintf(path, "/sys/devices/system/cpu/cpu%d/topology", cpu); 9560 + 9561 + initialize_cpu_set_from_sysfs(thiscpu->put_ids, path, "thread_siblings_list"); 9562 + 9563 + for (i = 0; i <= topo.max_cpu_num; ++i) 9564 + if (CPU_ISSET_S(i, size, thiscpu->put_ids)) { 9565 + cpus[i].ht_id = ht_id; 9566 + cpus[cpu].ht_sibling_cpu_id[ht_id] = i; 9567 + ht_id += 1; 9568 + } 9569 + 9570 + return (ht_id - 1); 9491 9571 } 9492 9572 9493 9573 void topology_probe(bool startup)