From b3f95beb62110ff6f808d04bd379aad108a2ae83 Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Thu, 27 Aug 2020 10:11:04 -0400 Subject: [PATCH] Adjust how we determine if a cpu is online https://github.com/Irqbalance/irqbalance/issues/159 recently brought to our attention that online cpu status isn't functional on all arches. Specifically on parisc, the availability of /sys/devices/system/cpu/cpu/online is in question. The implication here is that its not feasible to accurately determine cpu count, and as a result, irqbalance doesn't work on that arch Fix it by changing our online detection strategy. The file /sys/devices/system/cpu/online is a cpulist format file that seems to be present accross all arches and configs. As such, we can use this file to determine online status per cpu reliably. Signed-off-by: Neil Horman --- cputree.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cputree.c b/cputree.c index 00cf47f..80a6d9d 100644 --- a/cputree.c +++ b/cputree.c @@ -263,6 +263,7 @@ static void do_one_cpu(char *path) { struct topo_obj *cpu; char new_path[PATH_MAX]; + char *online_path ="/sys/devices/system/cpu/online"; cpumask_t cache_mask, package_mask; struct topo_obj *cache; DIR *dir; @@ -270,12 +271,18 @@ static void do_one_cpu(char *path) int nodeid; int packageid = 0; unsigned int max_cache_index, cache_index, cache_stat; - int online_status = 1; + cpumask_t online_cpus; + char *cpunrptr = NULL; + int cpunr = -1; /* skip offline cpus */ - snprintf(new_path, ADJ_SIZE(path,"/online"), "%s/online", path); - process_one_line(new_path, get_int, &online_status); - if (!online_status) + cpus_clear(online_cpus); + process_one_line(online_path, get_mask_from_cpulist, &online_cpus); + /* Get the current cpu number from the path */ + cpunrptr = rindex(path, '/'); + cpunrptr += 4; + cpunr = atoi(cpunrptr); + if (!cpu_isset(cpunr, online_cpus)) return; cpu = calloc(1, sizeof(struct topo_obj));