From 309752c6e495cfb47f0e4f48ed7244625010a65d Mon Sep 17 00:00:00 2001 From: Qiao Nuohan Date: Tue, 23 Sep 2014 14:19:32 +0800 Subject: [PATCH v3 02/21] add an API to check whether to hide a cpus' data check_offline_cpu() is used to check whether a cpu is offline. hide_offline_cpu() is based on check_offline_cpu() and used to check whether the data related to the specified cpu should be hiden. --- defs.h | 2 ++ kernel.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/defs.h b/defs.h index 32c9d4d..0cf4f31 100755 --- a/defs.h +++ b/defs.h @@ -4894,6 +4894,8 @@ int get_cpus_online(void); int get_cpus_active(void); int get_cpus_present(void); int get_cpus_possible(void); +int check_offline_cpu(int); +int hide_offline_cpu(int); int get_highest_cpu_online(void); int get_highest_cpu_present(void); int get_cpus_to_display(void); diff --git a/kernel.c b/kernel.c index 87a0b75..8948c84 100755 --- a/kernel.c +++ b/kernel.c @@ -7989,6 +7989,33 @@ get_cpus_online() } /* + * check to see whether a cpu is offline + */ +int +check_offline_cpu(int cpu) +{ + if (!cpu_map_addr("online")) + return FALSE; + + if (in_cpu_map(ONLINE_MAP, cpu)) + return FALSE; + + return TRUE; +} + +/* + * check to see whether the data related to the specified cpu should be hide + */ +int +hide_offline_cpu(int cpu) +{ + if (!(pc->flags2 & OFFLINE_HIDE)) + return FALSE; + + return check_offline_cpu(cpu); +} + +/* * If it exists, return the highest cpu number in the cpu_online_map. */ int -- 1.8.5.3