Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Anna-Maria Gleixner and committed by
Thomas Gleixner
7b737965 e210faa2

+47 -41
+46 -41
drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c
··· 967 967 } 968 968 969 969 #ifdef CONFIG_HOTPLUG_CPU 970 - static int 971 - cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) 970 + static enum cpuhp_state lustre_cpu_online; 971 + 972 + static void cfs_cpu_incr_cpt_version(void) 972 973 { 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 - 992 - mutex_lock(&cpt_data.cpt_mutex); 993 - /* if all HTs in a core are offline, it may break affinity */ 994 - cpumask_copy(cpt_data.cpt_cpumask, 995 - topology_sibling_cpumask(cpu)); 996 - warn = cpumask_any_and(cpt_data.cpt_cpumask, 997 - cpu_online_mask) >= nr_cpu_ids; 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 - 1004 - return NOTIFY_OK; 974 + spin_lock(&cpt_data.cpt_lock); 975 + cpt_data.cpt_version++; 976 + spin_unlock(&cpt_data.cpt_lock); 1005 977 } 1006 978 1007 - static struct notifier_block cfs_cpu_notifier = { 1008 - .notifier_call = cfs_cpu_notify, 1009 - .priority = 0 1010 - }; 979 + static int cfs_cpu_online(unsigned int cpu) 980 + { 981 + cfs_cpu_incr_cpt_version(); 982 + return 0; 983 + } 1011 984 985 + static int cfs_cpu_dead(unsigned int cpu) 986 + { 987 + bool warn; 988 + 989 + cfs_cpu_incr_cpt_version(); 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 1002 #endif 1013 1003 1014 1004 void ··· 1008 1018 cfs_cpt_table_free(cfs_cpt_table); 1009 1019 1010 1020 #ifdef CONFIG_HOTPLUG_CPU 1011 - unregister_hotcpu_notifier(&cfs_cpu_notifier); 1021 + if (lustre_cpu_online > 0) 1022 + cpuhp_remove_state_nocalls(lustre_cpu_online); 1023 + cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD); 1012 1024 #endif 1013 1025 if (cpt_data.cpt_cpumask) 1014 1026 LIBCFS_FREE(cpt_data.cpt_cpumask, cpumask_size()); ··· 1019 1027 int 1020 1028 cfs_cpu_init(void) 1021 1029 { 1030 + int ret = 0; 1031 + 1022 1032 LASSERT(!cfs_cpt_table); 1023 1033 1024 1034 memset(&cpt_data, 0, sizeof(cpt_data)); ··· 1035 1041 mutex_init(&cpt_data.cpt_mutex); 1036 1042 1037 1043 #ifdef CONFIG_HOTPLUG_CPU 1038 - register_hotcpu_notifier(&cfs_cpu_notifier); 1044 + ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD, 1045 + "staging/lustre/cfe:dead", NULL, 1046 + cfs_cpu_dead); 1047 + if (ret < 0) 1048 + goto failed; 1049 + ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 1050 + "staging/lustre/cfe:online", 1051 + cfs_cpu_online, NULL); 1052 + if (ret < 0) 1053 + goto failed; 1054 + lustre_cpu_online = ret; 1039 1055 #endif 1056 + ret = -EINVAL; 1040 1057 1041 1058 if (*cpu_pattern) { 1042 1059 cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern); ··· 1080 1075 1081 1076 failed: 1082 1077 cfs_cpu_fini(); 1083 - return -1; 1078 + return ret; 1084 1079 } 1085 1080 1086 1081 #endif
+1
include/linux/cpuhotplug.h
··· 41 41 CPUHP_NET_DEV_DEAD, 42 42 CPUHP_PCI_XGENE_DEAD, 43 43 CPUHP_IOMMU_INTEL_DEAD, 44 + CPUHP_LUSTRE_CFS_DEAD, 44 45 CPUHP_SCSI_BNX2FC_DEAD, 45 46 CPUHP_SCSI_BNX2I_DEAD, 46 47 CPUHP_WORKQUEUE_PREP,