diff options
author | Anna-Maria Gleixner | 2016-12-21 13:19:52 -0600 |
---|---|---|
committer | Thomas Gleixner | 2016-12-25 03:47:43 -0600 |
commit | 7b737965b33188bd3dbb44e938535c4006d97fbb (patch) | |
tree | bdac8e4ce520c971f6adf879099c8378329a40a2 | |
parent | e210faa2359f92eb2e417cd8462eb980a4dbb172 (diff) | |
download | linux-phy-7b737965b33188bd3dbb44e938535c4006d97fbb.tar.gz linux-phy-7b737965b33188bd3dbb44e938535c4006d97fbb.tar.xz linux-phy-7b737965b33188bd3dbb44e938535c4006d97fbb.zip |
staging/lustre/libcfs: Convert to hotplug state machine
Install the callbacks via the state machine. No functional change.
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: devel@driverdev.osuosl.org
Cc: Andreas Dilger <andreas.dilger@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: rt@linutronix.de
Cc: lustre-devel@lists.lustre.org
Link: http://lkml.kernel.org/r/20161202110027.htzzeervzkoc4muv@linutronix.de
Link: http://lkml.kernel.org/r/20161221192111.922872524@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 85 | ||||
-rw-r--r-- | include/linux/cpuhotplug.h | 1 |
2 files changed, 46 insertions, 40 deletions
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c index 6b9cf06e8df2..427e2198bb9e 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | |||
@@ -967,48 +967,38 @@ cfs_cpt_table_create_pattern(char *pattern) | |||
967 | } | 967 | } |
968 | 968 | ||
969 | #ifdef CONFIG_HOTPLUG_CPU | 969 | #ifdef CONFIG_HOTPLUG_CPU |
970 | static int | 970 | static enum cpuhp_state lustre_cpu_online; |
971 | cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) | ||
972 | { | ||
973 | unsigned int cpu = (unsigned long)hcpu; | ||
974 | bool warn; | ||
975 | |||
976 | switch (action) { | ||
977 | case CPU_DEAD: | ||
978 | case CPU_DEAD_FROZEN: | ||
979 | case CPU_ONLINE: | ||
980 | case CPU_ONLINE_FROZEN: | ||
981 | spin_lock(&cpt_data.cpt_lock); | ||
982 | cpt_data.cpt_version++; | ||
983 | spin_unlock(&cpt_data.cpt_lock); | ||
984 | /* Fall through */ | ||
985 | default: | ||
986 | if (action != CPU_DEAD && action != CPU_DEAD_FROZEN) { | ||
987 | CDEBUG(D_INFO, "CPU changed [cpu %u action %lx]\n", | ||
988 | cpu, action); | ||
989 | break; | ||
990 | } | ||
991 | 971 | ||
992 | mutex_lock(&cpt_data.cpt_mutex); | 972 | static void cfs_cpu_incr_cpt_version(void) |
993 | /* if all HTs in a core are offline, it may break affinity */ | 973 | { |
994 | cpumask_copy(cpt_data.cpt_cpumask, | 974 | spin_lock(&cpt_data.cpt_lock); |
995 | topology_sibling_cpumask(cpu)); | 975 | cpt_data.cpt_version++; |
996 | warn = cpumask_any_and(cpt_data.cpt_cpumask, | 976 | spin_unlock(&cpt_data.cpt_lock); |
997 | cpu_online_mask) >= nr_cpu_ids; | 977 | } |
998 | mutex_unlock(&cpt_data.cpt_mutex); | ||
999 | CDEBUG(warn ? D_WARNING : D_INFO, | ||
1000 | "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n", | ||
1001 | cpu, action); | ||
1002 | } | ||
1003 | 978 | ||
1004 | return NOTIFY_OK; | 979 | static int cfs_cpu_online(unsigned int cpu) |
980 | { | ||
981 | cfs_cpu_incr_cpt_version(); | ||
982 | return 0; | ||
1005 | } | 983 | } |
1006 | 984 | ||
1007 | static struct notifier_block cfs_cpu_notifier = { | 985 | static int cfs_cpu_dead(unsigned int cpu) |
1008 | .notifier_call = cfs_cpu_notify, | 986 | { |
1009 | .priority = 0 | 987 | bool warn; |
1010 | }; | 988 | |
989 | cfs_cpu_incr_cpt_version(); | ||
1011 | 990 | ||
991 | mutex_lock(&cpt_data.cpt_mutex); | ||
992 | /* if all HTs in a core are offline, it may break affinity */ | ||
993 | cpumask_copy(cpt_data.cpt_cpumask, topology_sibling_cpumask(cpu)); | ||
994 | warn = cpumask_any_and(cpt_data.cpt_cpumask, | ||
995 | cpu_online_mask) >= nr_cpu_ids; | ||
996 | mutex_unlock(&cpt_data.cpt_mutex); | ||
997 | CDEBUG(warn ? D_WARNING : D_INFO, | ||
998 | "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u]\n", | ||
999 | cpu); | ||
1000 | return 0; | ||
1001 | } | ||
1012 | #endif | 1002 | #endif |
1013 | 1003 | ||
1014 | void | 1004 | void |
@@ -1018,7 +1008,9 @@ cfs_cpu_fini(void) | |||
1018 | cfs_cpt_table_free(cfs_cpt_table); | 1008 | cfs_cpt_table_free(cfs_cpt_table); |
1019 | 1009 | ||
1020 | #ifdef CONFIG_HOTPLUG_CPU | 1010 | #ifdef CONFIG_HOTPLUG_CPU |
1021 | unregister_hotcpu_notifier(&cfs_cpu_notifier); | 1011 | if (lustre_cpu_online > 0) |
1012 | cpuhp_remove_state_nocalls(lustre_cpu_online); | ||
1013 | cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD); | ||
1022 | #endif | 1014 | #endif |
1023 | if (cpt_data.cpt_cpumask) | 1015 | if (cpt_data.cpt_cpumask) |
1024 | LIBCFS_FREE(cpt_data.cpt_cpumask, cpumask_size()); | 1016 | LIBCFS_FREE(cpt_data.cpt_cpumask, cpumask_size()); |
@@ -1027,6 +1019,8 @@ cfs_cpu_fini(void) | |||
1027 | int | 1019 | int |
1028 | cfs_cpu_init(void) | 1020 | cfs_cpu_init(void) |
1029 | { | 1021 | { |
1022 | int ret = 0; | ||
1023 | |||
1030 | LASSERT(!cfs_cpt_table); | 1024 | LASSERT(!cfs_cpt_table); |
1031 | 1025 | ||
1032 | memset(&cpt_data, 0, sizeof(cpt_data)); | 1026 | memset(&cpt_data, 0, sizeof(cpt_data)); |
@@ -1041,8 +1035,19 @@ cfs_cpu_init(void) | |||
1041 | mutex_init(&cpt_data.cpt_mutex); | 1035 | mutex_init(&cpt_data.cpt_mutex); |
1042 | 1036 | ||
1043 | #ifdef CONFIG_HOTPLUG_CPU | 1037 | #ifdef CONFIG_HOTPLUG_CPU |
1044 | register_hotcpu_notifier(&cfs_cpu_notifier); | 1038 | ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD, |
1039 | "staging/lustre/cfe:dead", NULL, | ||
1040 | cfs_cpu_dead); | ||
1041 | if (ret < 0) | ||
1042 | goto failed; | ||
1043 | ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, | ||
1044 | "staging/lustre/cfe:online", | ||
1045 | cfs_cpu_online, NULL); | ||
1046 | if (ret < 0) | ||
1047 | goto failed; | ||
1048 | lustre_cpu_online = ret; | ||
1045 | #endif | 1049 | #endif |
1050 | ret = -EINVAL; | ||
1046 | 1051 | ||
1047 | if (*cpu_pattern) { | 1052 | if (*cpu_pattern) { |
1048 | cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern); | 1053 | cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern); |
@@ -1075,7 +1080,7 @@ cfs_cpu_init(void) | |||
1075 | 1080 | ||
1076 | failed: | 1081 | failed: |
1077 | cfs_cpu_fini(); | 1082 | cfs_cpu_fini(); |
1078 | return -1; | 1083 | return ret; |
1079 | } | 1084 | } |
1080 | 1085 | ||
1081 | #endif | 1086 | #endif |
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index fc4587c05dd3..175d276ac335 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h | |||
@@ -41,6 +41,7 @@ enum cpuhp_state { | |||
41 | CPUHP_NET_DEV_DEAD, | 41 | CPUHP_NET_DEV_DEAD, |
42 | CPUHP_PCI_XGENE_DEAD, | 42 | CPUHP_PCI_XGENE_DEAD, |
43 | CPUHP_IOMMU_INTEL_DEAD, | 43 | CPUHP_IOMMU_INTEL_DEAD, |
44 | CPUHP_LUSTRE_CFS_DEAD, | ||
44 | CPUHP_SCSI_BNX2FC_DEAD, | 45 | CPUHP_SCSI_BNX2FC_DEAD, |
45 | CPUHP_SCSI_BNX2I_DEAD, | 46 | CPUHP_SCSI_BNX2I_DEAD, |
46 | CPUHP_WORKQUEUE_PREP, | 47 | CPUHP_WORKQUEUE_PREP, |