From d32974518c8920c0d3163d6672a434d1cbbeb429 Mon Sep 17 00:00:00 2001 From: Qiao Nuohan Date: Sat, 23 Aug 2014 10:16:11 +0800 Subject: [PATCH 01/23] x86_64: add an API to check an offline cpu on x86_64, when a cpu is hot removed(offline), this function will check it out Signed-off-by: Qiao Nuohan --- defs.h | 1 + kernel.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/defs.h b/defs.h index 44df6ae..a751813 100755 --- a/defs.h +++ b/defs.h @@ -4883,6 +4883,7 @@ 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 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 2a1e0a8..736ede0 100755 --- a/kernel.c +++ b/kernel.c @@ -7973,6 +7973,24 @@ get_cpus_online() return online; } +int +check_offline_cpu(int cpu) +{ + /* + * currently, only x86_64 is taken into consideration. + */ + if (!machine_type("X86_64")) + return FALSE; + + if (!cpu_map_addr("online")) + return FALSE; + + if (in_cpu_map(ONLINE_MAP, cpu)) + return FALSE; + + return TRUE; +} + /* * If it exists, return the highest cpu number in the cpu_online_map. */ -- 1.8.5.3