From 86fcd53f806750708d1d0942368bbd1f416ab959 Mon Sep 17 00:00:00 2001 From: Burt P Date: Fri, 11 Aug 2017 01:11:04 -0500 Subject: fix: core_ids are not unique Signed-off-by: Burt P --- modules/devices/cpu_util.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'modules/devices') 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); -- cgit v1.2.3