diff options
author | Burt P <pburt0@gmail.com> | 2017-08-11 01:11:04 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-08-11 02:52:21 -0700 |
commit | 86fcd53f806750708d1d0942368bbd1f416ab959 (patch) | |
tree | b1fb378b2a84a7b83f21bf99f3ccba00efae86b2 | |
parent | 8de8535398ea0838301802ad7fc764144f9b3135 (diff) |
fix: core_ids are not unique
Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r-- | modules/devices/cpu_util.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/devices/cpu_util.c b/modules/devices/cpu_util.c index 6a689a4e..f5bddd5c 100644 --- a/modules/devices/cpu_util.c +++ b/modules/devices/cpu_util.c @@ -65,6 +65,13 @@ gint get_cpu_int(const char* item, int cpuid, int null_val) { return ret; } +/* cpubits is 32768 bits long + * core_ids are not unique among physical_ids + * hack up cpubits into 128 packs of 256 cores + * to make cores unique in cpubits */ +#define MAX_CORES_PER_PACK 256 +#define MAX_PACKS 128 + int cpu_procs_cores_threads(int *p, int *c, int *t) { cpubits *threads, *cores, *packs; char *tmp; @@ -79,7 +86,7 @@ int cpu_procs_cores_threads(int *p, int *c, int *t) { pack_id = get_cpu_int("topology/physical_package_id", i, CPU_TOPO_NULL); core_id = get_cpu_int("topology/core_id", i, CPU_TOPO_NULL); if (pack_id >= 0) { CPUBIT_SET(packs, pack_id); } - if (core_id >= 0) { CPUBIT_SET(cores, core_id); } + if (core_id >= 0) { CPUBIT_SET(cores, (pack_id * MAX_CORES_PER_PACK) + core_id ); } } *t = cpubits_count(threads); *c = cpubits_count(cores); |