Skip to content

Commit 530e9b7

Browse files
committed
cpu/hotplug: Remove obsolete cpu hotplug register/unregister functions
hotcpu_notifier(), cpu_notifier(), __hotcpu_notifier(), __cpu_notifier(), register_hotcpu_notifier(), register_cpu_notifier(), __register_hotcpu_notifier(), __register_cpu_notifier(), unregister_hotcpu_notifier(), unregister_cpu_notifier(), __unregister_hotcpu_notifier(), __unregister_cpu_notifier() are unused now. Remove them and all related code. Remove also the now pointless cpu notifier error injection mechanism. The states can be executed step by step and error rollback is the same as cpu down, so any state transition can be tested w/o requiring the notifier error injection. Some CPU hotplug states are kept as they are (ab)used for hotplug state tracking. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 7b73796 commit 530e9b7

File tree

6 files changed

+1
-340
lines changed

6 files changed

+1
-340
lines changed

include/linux/cpu.h

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ struct notifier_block;
5757

5858
#define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */
5959
#define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */
60-
#define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */
61-
#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */
62-
#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */
6360
#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */
6461
#define CPU_POST_DEAD 0x0009 /* CPU (unsigned)v dead, cpu_hotplug
6562
* lock is dropped */
@@ -80,80 +77,14 @@ struct notifier_block;
8077

8178
#ifdef CONFIG_SMP
8279
extern bool cpuhp_tasks_frozen;
83-
/* Need to know about CPUs going up/down? */
84-
#if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
85-
#define cpu_notifier(fn, pri) { \
86-
static struct notifier_block fn##_nb = \
87-
{ .notifier_call = fn, .priority = pri }; \
88-
register_cpu_notifier(&fn##_nb); \
89-
}
90-
91-
#define __cpu_notifier(fn, pri) { \
92-
static struct notifier_block fn##_nb = \
93-
{ .notifier_call = fn, .priority = pri }; \
94-
__register_cpu_notifier(&fn##_nb); \
95-
}
96-
97-
extern int register_cpu_notifier(struct notifier_block *nb);
98-
extern int __register_cpu_notifier(struct notifier_block *nb);
99-
extern void unregister_cpu_notifier(struct notifier_block *nb);
100-
extern void __unregister_cpu_notifier(struct notifier_block *nb);
101-
102-
#else /* #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE) */
103-
#define cpu_notifier(fn, pri) do { (void)(fn); } while (0)
104-
#define __cpu_notifier(fn, pri) do { (void)(fn); } while (0)
105-
106-
static inline int register_cpu_notifier(struct notifier_block *nb)
107-
{
108-
return 0;
109-
}
110-
111-
static inline int __register_cpu_notifier(struct notifier_block *nb)
112-
{
113-
return 0;
114-
}
115-
116-
static inline void unregister_cpu_notifier(struct notifier_block *nb)
117-
{
118-
}
119-
120-
static inline void __unregister_cpu_notifier(struct notifier_block *nb)
121-
{
122-
}
123-
#endif
124-
12580
int cpu_up(unsigned int cpu);
12681
void notify_cpu_starting(unsigned int cpu);
12782
extern void cpu_maps_update_begin(void);
12883
extern void cpu_maps_update_done(void);
12984

130-
#define cpu_notifier_register_begin cpu_maps_update_begin
131-
#define cpu_notifier_register_done cpu_maps_update_done
132-
13385
#else /* CONFIG_SMP */
13486
#define cpuhp_tasks_frozen 0
13587

136-
#define cpu_notifier(fn, pri) do { (void)(fn); } while (0)
137-
#define __cpu_notifier(fn, pri) do { (void)(fn); } while (0)
138-
139-
static inline int register_cpu_notifier(struct notifier_block *nb)
140-
{
141-
return 0;
142-
}
143-
144-
static inline int __register_cpu_notifier(struct notifier_block *nb)
145-
{
146-
return 0;
147-
}
148-
149-
static inline void unregister_cpu_notifier(struct notifier_block *nb)
150-
{
151-
}
152-
153-
static inline void __unregister_cpu_notifier(struct notifier_block *nb)
154-
{
155-
}
156-
15788
static inline void cpu_maps_update_begin(void)
15889
{
15990
}
@@ -162,14 +93,6 @@ static inline void cpu_maps_update_done(void)
16293
{
16394
}
16495

165-
static inline void cpu_notifier_register_begin(void)
166-
{
167-
}
168-
169-
static inline void cpu_notifier_register_done(void)
170-
{
171-
}
172-
17396
#endif /* CONFIG_SMP */
17497
extern struct bus_type cpu_subsys;
17598

@@ -182,12 +105,6 @@ extern void get_online_cpus(void);
182105
extern void put_online_cpus(void);
183106
extern void cpu_hotplug_disable(void);
184107
extern void cpu_hotplug_enable(void);
185-
#define hotcpu_notifier(fn, pri) cpu_notifier(fn, pri)
186-
#define __hotcpu_notifier(fn, pri) __cpu_notifier(fn, pri)
187-
#define register_hotcpu_notifier(nb) register_cpu_notifier(nb)
188-
#define __register_hotcpu_notifier(nb) __register_cpu_notifier(nb)
189-
#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb)
190-
#define __unregister_hotcpu_notifier(nb) __unregister_cpu_notifier(nb)
191108
void clear_tasks_mm_cpumask(int cpu);
192109
int cpu_down(unsigned int cpu);
193110

@@ -199,13 +116,6 @@ static inline void cpu_hotplug_done(void) {}
199116
#define put_online_cpus() do { } while (0)
200117
#define cpu_hotplug_disable() do { } while (0)
201118
#define cpu_hotplug_enable() do { } while (0)
202-
#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
203-
#define __hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
204-
/* These aren't inline functions due to a GCC bug. */
205-
#define register_hotcpu_notifier(nb) ({ (void)(nb); 0; })
206-
#define __register_hotcpu_notifier(nb) ({ (void)(nb); 0; })
207-
#define unregister_hotcpu_notifier(nb) ({ (void)(nb); })
208-
#define __unregister_hotcpu_notifier(nb) ({ (void)(nb); })
209119
#endif /* CONFIG_HOTPLUG_CPU */
210120

211121
#ifdef CONFIG_PM_SLEEP_SMP

include/linux/cpuhotplug.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ enum cpuhp_state {
5959
CPUHP_POWERPC_MMU_CTX_PREPARE,
6060
CPUHP_XEN_PREPARE,
6161
CPUHP_XEN_EVTCHN_PREPARE,
62-
CPUHP_NOTIFY_PREPARE,
6362
CPUHP_ARM_SHMOBILE_SCU_PREPARE,
6463
CPUHP_SH_SH3X_PREPARE,
6564
CPUHP_BLK_MQ_PREPARE,
@@ -74,7 +73,6 @@ enum cpuhp_state {
7473
CPUHP_KVM_PPC_BOOK3S_PREPARE,
7574
CPUHP_ZCOMP_PREPARE,
7675
CPUHP_TIMERS_DEAD,
77-
CPUHP_NOTF_ERR_INJ_PREPARE,
7876
CPUHP_MIPS_SOC_PREPARE,
7977
CPUHP_BRINGUP_CPU,
8078
CPUHP_AP_IDLE_DEAD,
@@ -145,7 +143,6 @@ enum cpuhp_state {
145143
CPUHP_AP_PERF_ARM_L2X0_ONLINE,
146144
CPUHP_AP_WORKQUEUE_ONLINE,
147145
CPUHP_AP_RCUTREE_ONLINE,
148-
CPUHP_AP_NOTIFY_ONLINE,
149146
CPUHP_AP_ONLINE_DYN,
150147
CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30,
151148
CPUHP_AP_X86_HPET_ONLINE,

kernel/cpu.c

Lines changed: 1 addition & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -183,23 +183,16 @@ EXPORT_SYMBOL_GPL(cpuhp_tasks_frozen);
183183
/*
184184
* The following two APIs (cpu_maps_update_begin/done) must be used when
185185
* attempting to serialize the updates to cpu_online_mask & cpu_present_mask.
186-
* The APIs cpu_notifier_register_begin/done() must be used to protect CPU
187-
* hotplug callback (un)registration performed using __register_cpu_notifier()
188-
* or __unregister_cpu_notifier().
189186
*/
190187
void cpu_maps_update_begin(void)
191188
{
192189
mutex_lock(&cpu_add_remove_lock);
193190
}
194-
EXPORT_SYMBOL(cpu_notifier_register_begin);
195191

196192
void cpu_maps_update_done(void)
197193
{
198194
mutex_unlock(&cpu_add_remove_lock);
199195
}
200-
EXPORT_SYMBOL(cpu_notifier_register_done);
201-
202-
static RAW_NOTIFIER_HEAD(cpu_chain);
203196

204197
/* If set, cpu_up and cpu_down will return -EBUSY and do nothing.
205198
* Should always be manipulated under cpu_add_remove_lock
@@ -349,66 +342,7 @@ void cpu_hotplug_enable(void)
349342
EXPORT_SYMBOL_GPL(cpu_hotplug_enable);
350343
#endif /* CONFIG_HOTPLUG_CPU */
351344

352-
/* Need to know about CPUs going up/down? */
353-
int register_cpu_notifier(struct notifier_block *nb)
354-
{
355-
int ret;
356-
cpu_maps_update_begin();
357-
ret = raw_notifier_chain_register(&cpu_chain, nb);
358-
cpu_maps_update_done();
359-
return ret;
360-
}
361-
362-
int __register_cpu_notifier(struct notifier_block *nb)
363-
{
364-
return raw_notifier_chain_register(&cpu_chain, nb);
365-
}
366-
367-
static int __cpu_notify(unsigned long val, unsigned int cpu, int nr_to_call,
368-
int *nr_calls)
369-
{
370-
unsigned long mod = cpuhp_tasks_frozen ? CPU_TASKS_FROZEN : 0;
371-
void *hcpu = (void *)(long)cpu;
372-
373-
int ret;
374-
375-
ret = __raw_notifier_call_chain(&cpu_chain, val | mod, hcpu, nr_to_call,
376-
nr_calls);
377-
378-
return notifier_to_errno(ret);
379-
}
380-
381-
static int cpu_notify(unsigned long val, unsigned int cpu)
382-
{
383-
return __cpu_notify(val, cpu, -1, NULL);
384-
}
385-
386-
static void cpu_notify_nofail(unsigned long val, unsigned int cpu)
387-
{
388-
BUG_ON(cpu_notify(val, cpu));
389-
}
390-
391345
/* Notifier wrappers for transitioning to state machine */
392-
static int notify_prepare(unsigned int cpu)
393-
{
394-
int nr_calls = 0;
395-
int ret;
396-
397-
ret = __cpu_notify(CPU_UP_PREPARE, cpu, -1, &nr_calls);
398-
if (ret) {
399-
nr_calls--;
400-
printk(KERN_WARNING "%s: attempt to bring up CPU %u failed\n",
401-
__func__, cpu);
402-
__cpu_notify(CPU_UP_CANCELED, cpu, nr_calls, NULL);
403-
}
404-
return ret;
405-
}
406-
407-
static int notify_online(unsigned int cpu)
408-
{
409-
cpu_notify(CPU_ONLINE, cpu);
410-
return 0;
411-
}
412346

413347
static int bringup_wait_for_ap(unsigned int cpu)
414348
{
@@ -433,10 +367,8 @@ static int bringup_cpu(unsigned int cpu)
433367
/* Arch-specific enabling code. */
434368
ret = __cpu_up(cpu, idle);
435369
irq_unlock_sparse();
436-
if (ret) {
437-
cpu_notify(CPU_UP_CANCELED, cpu);
370+
if (ret)
438371
return ret;
439-
}
440372
ret = bringup_wait_for_ap(cpu);
441373
BUG_ON(!cpu_online(cpu));
442374
return ret;
@@ -565,11 +497,6 @@ static void cpuhp_thread_fun(unsigned int cpu)
565497
BUG_ON(st->state < CPUHP_AP_ONLINE_IDLE);
566498

567499
undo_cpu_down(cpu, st);
568-
/*
569-
* This is a momentary workaround to keep the notifier users
570-
* happy. Will go away once we got rid of the notifiers.
571-
*/
572-
cpu_notify_nofail(CPU_DOWN_FAILED, cpu);
573500
st->rollback = false;
574501
} else {
575502
/* Cannot happen .... */
@@ -659,22 +586,6 @@ void __init cpuhp_threads_init(void)
659586
kthread_unpark(this_cpu_read(cpuhp_state.thread));
660587
}
661588

662-
EXPORT_SYMBOL(register_cpu_notifier);
663-
EXPORT_SYMBOL(__register_cpu_notifier);
664-
void unregister_cpu_notifier(struct notifier_block *nb)
665-
{
666-
cpu_maps_update_begin();
667-
raw_notifier_chain_unregister(&cpu_chain, nb);
668-
cpu_maps_update_done();
669-
}
670-
EXPORT_SYMBOL(unregister_cpu_notifier);
671-
672-
void __unregister_cpu_notifier(struct notifier_block *nb)
673-
{
674-
raw_notifier_chain_unregister(&cpu_chain, nb);
675-
}
676-
EXPORT_SYMBOL(__unregister_cpu_notifier);
677-
678589
#ifdef CONFIG_HOTPLUG_CPU
679590
/**
680591
* clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU
@@ -741,20 +652,6 @@ static inline void check_for_tasks(int dead_cpu)
741652
read_unlock(&tasklist_lock);
742653
}
743654

744-
static int notify_down_prepare(unsigned int cpu)
745-
{
746-
int err, nr_calls = 0;
747-
748-
err = __cpu_notify(CPU_DOWN_PREPARE, cpu, -1, &nr_calls);
749-
if (err) {
750-
nr_calls--;
751-
__cpu_notify(CPU_DOWN_FAILED, cpu, nr_calls, NULL);
752-
pr_warn("%s: attempt to take down CPU %u failed\n",
753-
__func__, cpu);
754-
}
755-
return err;
756-
}
757-
758655
/* Take this CPU down. */
759656
static int take_cpu_down(void *_param)
760657
{
@@ -833,13 +730,6 @@ static int takedown_cpu(unsigned int cpu)
833730
return 0;
834731
}
835732

836-
static int notify_dead(unsigned int cpu)
837-
{
838-
cpu_notify_nofail(CPU_DEAD, cpu);
839-
check_for_tasks(cpu);
840-
return 0;
841-
}
842-
843733
static void cpuhp_complete_idle_dead(void *arg)
844734
{
845735
struct cpuhp_cpu_state *st = arg;
@@ -863,9 +753,7 @@ void cpuhp_report_idle_dead(void)
863753
}
864754

865755
#else
866-
#define notify_down_prepare NULL
867756
#define takedown_cpu NULL
868-
#define notify_dead NULL
869757
#endif
870758

871759
#ifdef CONFIG_HOTPLUG_CPU
@@ -924,9 +812,6 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
924812
hasdied = prev_state != st->state && st->state == CPUHP_OFFLINE;
925813
out:
926814
cpu_hotplug_done();
927-
/* This post dead nonsense must die */
928-
if (!ret && hasdied)
929-
cpu_notify_nofail(CPU_POST_DEAD, cpu);
930815
return ret;
931816
}
932817

@@ -1291,17 +1176,6 @@ static struct cpuhp_step cpuhp_bp_states[] = {
12911176
.startup.single = rcutree_prepare_cpu,
12921177
.teardown.single = rcutree_dead_cpu,
12931178
},
1294-
/*
1295-
* Preparatory and dead notifiers. Will be replaced once the notifiers
1296-
* are converted to states.
1297-
*/
1298-
[CPUHP_NOTIFY_PREPARE] = {
1299-
.name = "notify:prepare",
1300-
.startup.single = notify_prepare,
1301-
.teardown.single = notify_dead,
1302-
.skip_onerr = true,
1303-
.cant_stop = true,
1304-
},
13051179
/*
13061180
* On the tear-down path, timers_dead_cpu() must be invoked
13071181
* before blk_mq_queue_reinit_notify() from notify_dead(),
@@ -1391,17 +1265,6 @@ static struct cpuhp_step cpuhp_ap_states[] = {
13911265
.startup.single = rcutree_online_cpu,
13921266
.teardown.single = rcutree_offline_cpu,
13931267
},
1394-
1395-
/*
1396-
* Online/down_prepare notifiers. Will be removed once the notifiers
1397-
* are converted to states.
1398-
*/
1399-
[CPUHP_AP_NOTIFY_ONLINE] = {
1400-
.name = "notify:online",
1401-
.startup.single = notify_online,
1402-
.teardown.single = notify_down_prepare,
1403-
.skip_onerr = true,
1404-
},
14051268
#endif
14061269
/*
14071270
* The dynamically registered state space is here

0 commit comments

Comments
 (0)