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

s390/smp: Convert to hotplug state machine

cpuhp_setup_state() invokes the startup callback on all online cpus with
the proper protection, so we can remove the cpu hotplug protection from the
init function and the creation of the per cpu files for online cpus in
smp_add_present_cpu(). smp_add_present_cpu() is called also called from
__smp_rescan_cpus(), but this callpath never adds an online cpu, it merily
adds newly present cpus, so the creation of the cpu files is not required.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20161104144502.7kd4bxz2rxqvtack@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Sebastian Andrzej Siewior and committed by
Thomas Gleixner
dfbbd86a ef65d45c

+11 -26
+11 -26
arch/s390/kernel/smp.c
··· 1047 1047 .attrs = cpu_online_attrs, 1048 1048 }; 1049 1049 1050 - static int smp_cpu_notify(struct notifier_block *self, unsigned long action, 1051 - void *hcpu) 1050 + static int smp_cpu_online(unsigned int cpu) 1052 1051 { 1053 - unsigned int cpu = (unsigned int)(long)hcpu; 1054 1052 struct device *s = &per_cpu(cpu_device, cpu)->dev; 1055 - int err = 0; 1056 1053 1057 - switch (action & ~CPU_TASKS_FROZEN) { 1058 - case CPU_ONLINE: 1059 - case CPU_DOWN_FAILED: 1060 - err = sysfs_create_group(&s->kobj, &cpu_online_attr_group); 1061 - break; 1062 - case CPU_DOWN_PREPARE: 1063 - sysfs_remove_group(&s->kobj, &cpu_online_attr_group); 1064 - break; 1065 - } 1066 - return notifier_from_errno(err); 1054 + return sysfs_create_group(&s->kobj, &cpu_online_attr_group); 1055 + } 1056 + static int smp_cpu_pre_down(unsigned int cpu) 1057 + { 1058 + struct device *s = &per_cpu(cpu_device, cpu)->dev; 1059 + 1060 + sysfs_remove_group(&s->kobj, &cpu_online_attr_group); 1061 + return 0; 1067 1062 } 1068 1063 1069 1064 static int smp_add_present_cpu(int cpu) ··· 1079 1084 rc = sysfs_create_group(&s->kobj, &cpu_common_attr_group); 1080 1085 if (rc) 1081 1086 goto out_cpu; 1082 - if (cpu_online(cpu)) { 1083 - rc = sysfs_create_group(&s->kobj, &cpu_online_attr_group); 1084 - if (rc) 1085 - goto out_online; 1086 - } 1087 1087 rc = topology_cpu_init(c); 1088 1088 if (rc) 1089 1089 goto out_topology; 1090 1090 return 0; 1091 1091 1092 1092 out_topology: 1093 - if (cpu_online(cpu)) 1094 - sysfs_remove_group(&s->kobj, &cpu_online_attr_group); 1095 - out_online: 1096 1093 sysfs_remove_group(&s->kobj, &cpu_common_attr_group); 1097 1094 out_cpu: 1098 1095 #ifdef CONFIG_HOTPLUG_CPU ··· 1137 1150 if (rc) 1138 1151 return rc; 1139 1152 #endif 1140 - cpu_notifier_register_begin(); 1141 1153 for_each_present_cpu(cpu) { 1142 1154 rc = smp_add_present_cpu(cpu); 1143 1155 if (rc) 1144 1156 goto out; 1145 1157 } 1146 1158 1147 - __hotcpu_notifier(smp_cpu_notify, 0); 1148 - 1159 + rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "s390/smp:online", 1160 + smp_cpu_online, smp_cpu_pre_down); 1149 1161 out: 1150 - cpu_notifier_register_done(); 1151 1162 return rc; 1152 1163 } 1153 1164 subsys_initcall(s390_smp_init);