Hi Jeremy,
I have a question about $subject for you, since you wrote the code.
This function returns a unique identifier for the package, but would not
be the logically indexed package id we would expect, like 0, 1, 2, ...
It returns of the offset in the PPTT of the topology physical CPU node.
So I may get something like this:
john@ubuntu:~$ more
/sys/devices/system/cpu/cpu80/topology/physical_package_id
5418
For sure, this does not violate the ABI in
Documentation/ABI/testing/sysfs-devices-system-cpu:
"physical_package_id: physical package id of cpu#. Typically
corresponds to a physical socket number, but the actual value is
architecture and platform dependent."
Question: Is there any reason for which we cannot assign an indexed
package id to each package node?
Some userspace tools rely on a sane meaningful package id, like perf:
See tools/perf/util/cpumap.c:
int cpu_map__get_die(struct perf_cpu_map *map, int idx, void *data)
{
...
s = cpu_map__get_socket(map, idx, data);
if (s == -1)
return -1;
/*
* Encode socket in bit range 15:8
* die_id is relative to socket, and
* we need a global id. So we combine
* socket + die id
*/
if (WARN_ONCE(die_id >> 8, "The die id number is too big.\n"))
return -1;
...
return (s << 8) | (die_id & 0xff);
}
This can only deal with a socket id which fits in a byte. I'd rather not
change this code if possible.
Thanks,
John