This patch introduces a method to get the number of CPUs on cpu_active_map. It is useful to determine online CPUs for ARM platform. Signed-off-by: Liu Hua <sdu.liu@xxxxxxxxxx> --- defs.h | 1 + kernel.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/defs.h b/defs.h index b5cff61..03b11a8 100644 --- a/defs.h +++ b/defs.h @@ -4792,6 +4792,7 @@ void set_cpu(int); void clear_machdep_cache(void); struct stack_hook *gather_text_list(struct bt_info *); int get_cpus_online(void); +int get_cpus_active(void); int get_cpus_present(void); int get_cpus_possible(void); int get_highest_cpu_online(void); diff --git a/kernel.c b/kernel.c index 9ed280e..fcdb905 100644 --- a/kernel.c +++ b/kernel.c @@ -7934,6 +7934,40 @@ get_highest_cpu_online() } /* + * If it exists, return the number of cpus in the cpu_active_map. + */ +int +get_cpus_active() +{ + int i, len, active; + char *buf; + ulong *maskptr, addr; + + if (!(addr = cpu_map_addr("active"))) + return 0; + + len = cpu_map_size("active"); + buf = GETBUF(len); + + active = 0; + + if (readmem(addr, KVADDR, buf, len, + "cpu_active_map", RETURN_ON_ERROR)) { + + maskptr = (ulong *)buf; + for (i = 0; i < (len/sizeof(ulong)); i++, maskptr++) + active += count_bits_long(*maskptr); + + if (CRASHDEBUG(1)) + error(INFO, "get_cpus_active: active: %d\n", active); + } + + FREEBUF(buf); + + return active; +} + +/* * If it exists, return the number of cpus in the cpu_present_map. */ int -- 1.9.0 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility