aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-03 22:43:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-03 22:43:08 -0400
commit597f03f9d133e9837d00965016170271d4f87dcf (patch)
tree33bdb5c1104d5b466387f4ae98748c5f4ddd29bb /kernel
parent999dcbe2414e15e19cdc1f91497d01f262c6e1cf (diff)
parent0bf71e4d02ffec8ab9a6adecca61d3eed74fc99d (diff)
Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull CPU hotplug updates from Thomas Gleixner: "Yet another batch of cpu hotplug core updates and conversions: - Provide core infrastructure for multi instance drivers so the drivers do not have to keep custom lists. - Convert custom lists to the new infrastructure. The block-mq custom list conversion comes through the block tree and makes the diffstat tip over to more lines removed than added. - Handle unbalanced hotplug enable/disable calls more gracefully. - Remove the obsolete CPU_STARTING/DYING notifier support. - Convert another batch of notifier users. The relayfs changes which conflicted with the conversion have been shipped to me by Andrew. The remaining lot is targeted for 4.10 so that we finally can remove the rest of the notifiers" * 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (46 commits) cpufreq: Fix up conversion to hotplug state machine blk/mq: Reserve hotplug states for block multiqueue x86/apic/uv: Convert to hotplug state machine s390/mm/pfault: Convert to hotplug state machine mips/loongson/smp: Convert to hotplug state machine mips/octeon/smp: Convert to hotplug state machine fault-injection/cpu: Convert to hotplug state machine padata: Convert to hotplug state machine cpufreq: Convert to hotplug state machine ACPI/processor: Convert to hotplug state machine virtio scsi: Convert to hotplug state machine oprofile/timer: Convert to hotplug state machine block/softirq: Convert to hotplug state machine lib/irq_poll: Convert to hotplug state machine x86/microcode: Convert to hotplug state machine sh/SH-X3 SMP: Convert to hotplug state machine ia64/mca: Convert to hotplug state machine ARM/OMAP/wakeupgen: Convert to hotplug state machine ARM/shmobile: Convert to hotplug state machine arm64/FP/SIMD: Convert to hotplug state machine ...
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cpu.c512
-rw-r--r--kernel/padata.c88
-rw-r--r--kernel/relay.c124
-rw-r--r--kernel/softirq.c27
4 files changed, 438 insertions, 313 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 92c2451db415..5df20d6d1520 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -23,6 +23,8 @@
23#include <linux/tick.h> 23#include <linux/tick.h>
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/smpboot.h> 25#include <linux/smpboot.h>
26#include <linux/relay.h>
27#include <linux/slab.h>
26 28
27#include <trace/events/power.h> 29#include <trace/events/power.h>
28#define CREATE_TRACE_POINTS 30#define CREATE_TRACE_POINTS
@@ -37,8 +39,9 @@
37 * @thread: Pointer to the hotplug thread 39 * @thread: Pointer to the hotplug thread
38 * @should_run: Thread should execute 40 * @should_run: Thread should execute
39 * @rollback: Perform a rollback 41 * @rollback: Perform a rollback
40 * @cb_stat: The state for a single callback (install/uninstall) 42 * @single: Single callback invocation
41 * @cb: Single callback function (install/uninstall) 43 * @bringup: Single callback bringup or teardown selector
44 * @cb_state: The state for a single callback (install/uninstall)
42 * @result: Result of the operation 45 * @result: Result of the operation
43 * @done: Signal completion to the issuer of the task 46 * @done: Signal completion to the issuer of the task
44 */ 47 */
@@ -49,8 +52,10 @@ struct cpuhp_cpu_state {
49 struct task_struct *thread; 52 struct task_struct *thread;
50 bool should_run; 53 bool should_run;
51 bool rollback; 54 bool rollback;
55 bool single;
56 bool bringup;
57 struct hlist_node *node;
52 enum cpuhp_state cb_state; 58 enum cpuhp_state cb_state;
53 int (*cb)(unsigned int cpu);
54 int result; 59 int result;
55 struct completion done; 60 struct completion done;
56#endif 61#endif
@@ -68,35 +73,103 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state);
68 * @cant_stop: Bringup/teardown can't be stopped at this step 73 * @cant_stop: Bringup/teardown can't be stopped at this step
69 */ 74 */
70struct cpuhp_step { 75struct cpuhp_step {
71 const char *name; 76 const char *name;
72 int (*startup)(unsigned int cpu); 77 union {
73 int (*teardown)(unsigned int cpu); 78 int (*single)(unsigned int cpu);
74 bool skip_onerr; 79 int (*multi)(unsigned int cpu,
75 bool cant_stop; 80 struct hlist_node *node);
81 } startup;
82 union {
83 int (*single)(unsigned int cpu);
84 int (*multi)(unsigned int cpu,
85 struct hlist_node *node);
86 } teardown;
87 struct hlist_head list;
88 bool skip_onerr;
89 bool cant_stop;
90 bool multi_instance;
76}; 91};
77 92
78static DEFINE_MUTEX(cpuhp_state_mutex); 93static DEFINE_MUTEX(cpuhp_state_mutex);
79static struct cpuhp_step cpuhp_bp_states[]; 94static struct cpuhp_step cpuhp_bp_states[];
80static struct cpuhp_step cpuhp_ap_states[]; 95static struct cpuhp_step cpuhp_ap_states[];
81 96
97static bool cpuhp_is_ap_state(enum cpuhp_state state)
98{
99 /*
100 * The extra check for CPUHP_TEARDOWN_CPU is only for documentation
101 * purposes as that state is handled explicitly in cpu_down.
102 */
103 return state > CPUHP_BRINGUP_CPU && state != CPUHP_TEARDOWN_CPU;
104}
105
106static struct cpuhp_step *cpuhp_get_step(enum cpuhp_state state)
107{
108 struct cpuhp_step *sp;
109
110 sp = cpuhp_is_ap_state(state) ? cpuhp_ap_states : cpuhp_bp_states;
111 return sp + state;
112}
113
82/** 114/**
83 * cpuhp_invoke_callback _ Invoke the callbacks for a given state 115 * cpuhp_invoke_callback _ Invoke the callbacks for a given state
84 * @cpu: The cpu for which the callback should be invoked 116 * @cpu: The cpu for which the callback should be invoked
85 * @step: The step in the state machine 117 * @step: The step in the state machine
86 * @cb: The callback function to invoke 118 * @bringup: True if the bringup callback should be invoked
87 * 119 *
88 * Called from cpu hotplug and from the state register machinery 120 * Called from cpu hotplug and from the state register machinery.
89 */ 121 */
90static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state step, 122static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state state,
91 int (*cb)(unsigned int)) 123 bool bringup, struct hlist_node *node)
92{ 124{
93 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); 125 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
94 int ret = 0; 126 struct cpuhp_step *step = cpuhp_get_step(state);
95 127 int (*cbm)(unsigned int cpu, struct hlist_node *node);
96 if (cb) { 128 int (*cb)(unsigned int cpu);
97 trace_cpuhp_enter(cpu, st->target, step, cb); 129 int ret, cnt;
130
131 if (!step->multi_instance) {
132 cb = bringup ? step->startup.single : step->teardown.single;
133 if (!cb)
134 return 0;
135 trace_cpuhp_enter(cpu, st->target, state, cb);
98 ret = cb(cpu); 136 ret = cb(cpu);
99 trace_cpuhp_exit(cpu, st->state, step, ret); 137 trace_cpuhp_exit(cpu, st->state, state, ret);
138 return ret;
139 }
140 cbm = bringup ? step->startup.multi : step->teardown.multi;
141 if (!cbm)
142 return 0;
143
144 /* Single invocation for instance add/remove */
145 if (node) {
146 trace_cpuhp_multi_enter(cpu, st->target, state, cbm, node);
147 ret = cbm(cpu, node);
148 trace_cpuhp_exit(cpu, st->state, state, ret);
149 return ret;
150 }
151
152 /* State transition. Invoke on all instances */
153 cnt = 0;
154 hlist_for_each(node, &step->list) {
155 trace_cpuhp_multi_enter(cpu, st->target, state, cbm, node);
156 ret = cbm(cpu, node);
157 trace_cpuhp_exit(cpu, st->state, state, ret);
158 if (ret)
159 goto err;
160 cnt++;
161 }
162 return 0;
163err:
164 /* Rollback the instances if one failed */
165 cbm = !bringup ? step->startup.multi : step->teardown.multi;
166 if (!cbm)
167 return ret;
168
169 hlist_for_each(node, &step->list) {
170 if (!cnt--)
171 break;
172 cbm(cpu, node);
100 } 173 }
101 return ret; 174 return ret;
102} 175}
@@ -260,10 +333,17 @@ void cpu_hotplug_disable(void)
260} 333}
261EXPORT_SYMBOL_GPL(cpu_hotplug_disable); 334EXPORT_SYMBOL_GPL(cpu_hotplug_disable);
262 335
336static void __cpu_hotplug_enable(void)
337{
338 if (WARN_ONCE(!cpu_hotplug_disabled, "Unbalanced cpu hotplug enable\n"))
339 return;
340 cpu_hotplug_disabled--;
341}
342
263void cpu_hotplug_enable(void) 343void cpu_hotplug_enable(void)
264{ 344{
265 cpu_maps_update_begin(); 345 cpu_maps_update_begin();
266 WARN_ON(--cpu_hotplug_disabled < 0); 346 __cpu_hotplug_enable();
267 cpu_maps_update_done(); 347 cpu_maps_update_done();
268} 348}
269EXPORT_SYMBOL_GPL(cpu_hotplug_enable); 349EXPORT_SYMBOL_GPL(cpu_hotplug_enable);
@@ -330,12 +410,6 @@ static int notify_online(unsigned int cpu)
330 return 0; 410 return 0;
331} 411}
332 412
333static int notify_starting(unsigned int cpu)
334{
335 cpu_notify(CPU_STARTING, cpu);
336 return 0;
337}
338
339static int bringup_wait_for_ap(unsigned int cpu) 413static int bringup_wait_for_ap(unsigned int cpu)
340{ 414{
341 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); 415 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
@@ -349,8 +423,16 @@ static int bringup_cpu(unsigned int cpu)
349 struct task_struct *idle = idle_thread_get(cpu); 423 struct task_struct *idle = idle_thread_get(cpu);
350 int ret; 424 int ret;
351 425
426 /*
427 * Some architectures have to walk the irq descriptors to
428 * setup the vector space for the cpu which comes online.
429 * Prevent irq alloc/free across the bringup.
430 */
431 irq_lock_sparse();
432
352 /* Arch-specific enabling code. */ 433 /* Arch-specific enabling code. */
353 ret = __cpu_up(cpu, idle); 434 ret = __cpu_up(cpu, idle);
435 irq_unlock_sparse();
354 if (ret) { 436 if (ret) {
355 cpu_notify(CPU_UP_CANCELED, cpu); 437 cpu_notify(CPU_UP_CANCELED, cpu);
356 return ret; 438 return ret;
@@ -363,62 +445,55 @@ static int bringup_cpu(unsigned int cpu)
363/* 445/*
364 * Hotplug state machine related functions 446 * Hotplug state machine related functions
365 */ 447 */
366static void undo_cpu_down(unsigned int cpu, struct cpuhp_cpu_state *st, 448static void undo_cpu_down(unsigned int cpu, struct cpuhp_cpu_state *st)
367 struct cpuhp_step *steps)
368{ 449{
369 for (st->state++; st->state < st->target; st->state++) { 450 for (st->state++; st->state < st->target; st->state++) {
370 struct cpuhp_step *step = steps + st->state; 451 struct cpuhp_step *step = cpuhp_get_step(st->state);
371 452
372 if (!step->skip_onerr) 453 if (!step->skip_onerr)
373 cpuhp_invoke_callback(cpu, st->state, step->startup); 454 cpuhp_invoke_callback(cpu, st->state, true, NULL);
374 } 455 }
375} 456}
376 457
377static int cpuhp_down_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st, 458static int cpuhp_down_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,
378 struct cpuhp_step *steps, enum cpuhp_state target) 459 enum cpuhp_state target)
379{ 460{
380 enum cpuhp_state prev_state = st->state; 461 enum cpuhp_state prev_state = st->state;
381 int ret = 0; 462 int ret = 0;
382 463
383 for (; st->state > target; st->state--) { 464 for (; st->state > target; st->state--) {
384 struct cpuhp_step *step = steps + st->state; 465 ret = cpuhp_invoke_callback(cpu, st->state, false, NULL);
385
386 ret = cpuhp_invoke_callback(cpu, st->state, step->teardown);
387 if (ret) { 466 if (ret) {
388 st->target = prev_state; 467 st->target = prev_state;
389 undo_cpu_down(cpu, st, steps); 468 undo_cpu_down(cpu, st);
390 break; 469 break;
391 } 470 }
392 } 471 }
393 return ret; 472 return ret;
394} 473}
395 474
396static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st, 475static void undo_cpu_up(unsigned int cpu, struct cpuhp_cpu_state *st)
397 struct cpuhp_step *steps)
398{ 476{
399 for (st->state--; st->state > st->target; st->state--) { 477 for (st->state--; st->state > st->target; st->state--) {
400 struct cpuhp_step *step = steps + st->state; 478 struct cpuhp_step *step = cpuhp_get_step(st->state);
401 479
402 if (!step->skip_onerr) 480 if (!step->skip_onerr)
403 cpuhp_invoke_callback(cpu, st->state, step->teardown); 481 cpuhp_invoke_callback(cpu, st->state, false, NULL);
404 } 482 }
405} 483}
406 484
407static int cpuhp_up_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st, 485static int cpuhp_up_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st,
408 struct cpuhp_step *steps, enum cpuhp_state target) 486 enum cpuhp_state target)
409{ 487{
410 enum cpuhp_state prev_state = st->state; 488 enum cpuhp_state prev_state = st->state;
411 int ret = 0; 489 int ret = 0;
412 490
413 while (st->state < target) { 491 while (st->state < target) {
414 struct cpuhp_step *step;
415
416 st->state++; 492 st->state++;
417 step = steps + st->state; 493 ret = cpuhp_invoke_callback(cpu, st->state, true, NULL);
418 ret = cpuhp_invoke_callback(cpu, st->state, step->startup);
419 if (ret) { 494 if (ret) {
420 st->target = prev_state; 495 st->target = prev_state;
421 undo_cpu_up(cpu, st, steps); 496 undo_cpu_up(cpu, st);
422 break; 497 break;
423 } 498 }
424 } 499 }
@@ -447,13 +522,13 @@ static int cpuhp_ap_offline(unsigned int cpu, struct cpuhp_cpu_state *st)
447{ 522{
448 enum cpuhp_state target = max((int)st->target, CPUHP_TEARDOWN_CPU); 523 enum cpuhp_state target = max((int)st->target, CPUHP_TEARDOWN_CPU);
449 524
450 return cpuhp_down_callbacks(cpu, st, cpuhp_ap_states, target); 525 return cpuhp_down_callbacks(cpu, st, target);
451} 526}
452 527
453/* Execute the online startup callbacks. Used to be CPU_ONLINE */ 528/* Execute the online startup callbacks. Used to be CPU_ONLINE */
454static int cpuhp_ap_online(unsigned int cpu, struct cpuhp_cpu_state *st) 529static int cpuhp_ap_online(unsigned int cpu, struct cpuhp_cpu_state *st)
455{ 530{
456 return cpuhp_up_callbacks(cpu, st, cpuhp_ap_states, st->target); 531 return cpuhp_up_callbacks(cpu, st, st->target);
457} 532}
458 533
459/* 534/*
@@ -476,18 +551,20 @@ static void cpuhp_thread_fun(unsigned int cpu)
476 st->should_run = false; 551 st->should_run = false;
477 552
478 /* Single callback invocation for [un]install ? */ 553 /* Single callback invocation for [un]install ? */
479 if (st->cb) { 554 if (st->single) {
480 if (st->cb_state < CPUHP_AP_ONLINE) { 555 if (st->cb_state < CPUHP_AP_ONLINE) {
481 local_irq_disable(); 556 local_irq_disable();
482 ret = cpuhp_invoke_callback(cpu, st->cb_state, st->cb); 557 ret = cpuhp_invoke_callback(cpu, st->cb_state,
558 st->bringup, st->node);
483 local_irq_enable(); 559 local_irq_enable();
484 } else { 560 } else {
485 ret = cpuhp_invoke_callback(cpu, st->cb_state, st->cb); 561 ret = cpuhp_invoke_callback(cpu, st->cb_state,
562 st->bringup, st->node);
486 } 563 }
487 } else if (st->rollback) { 564 } else if (st->rollback) {
488 BUG_ON(st->state < CPUHP_AP_ONLINE_IDLE); 565 BUG_ON(st->state < CPUHP_AP_ONLINE_IDLE);
489 566
490 undo_cpu_down(cpu, st, cpuhp_ap_states); 567 undo_cpu_down(cpu, st);
491 /* 568 /*
492 * This is a momentary workaround to keep the notifier users 569 * This is a momentary workaround to keep the notifier users
493 * happy. Will go away once we got rid of the notifiers. 570 * happy. Will go away once we got rid of the notifiers.
@@ -509,8 +586,9 @@ static void cpuhp_thread_fun(unsigned int cpu)
509} 586}
510 587
511/* Invoke a single callback on a remote cpu */ 588/* Invoke a single callback on a remote cpu */
512static int cpuhp_invoke_ap_callback(int cpu, enum cpuhp_state state, 589static int
513 int (*cb)(unsigned int)) 590cpuhp_invoke_ap_callback(int cpu, enum cpuhp_state state, bool bringup,
591 struct hlist_node *node)
514{ 592{
515 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); 593 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
516 594
@@ -522,10 +600,13 @@ static int cpuhp_invoke_ap_callback(int cpu, enum cpuhp_state state,
522 * we invoke the thread function directly. 600 * we invoke the thread function directly.
523 */ 601 */
524 if (!st->thread) 602 if (!st->thread)
525 return cpuhp_invoke_callback(cpu, state, cb); 603 return cpuhp_invoke_callback(cpu, state, bringup, node);
526 604
527 st->cb_state = state; 605 st->cb_state = state;
528 st->cb = cb; 606 st->single = true;
607 st->bringup = bringup;
608 st->node = node;
609
529 /* 610 /*
530 * Make sure the above stores are visible before should_run becomes 611 * Make sure the above stores are visible before should_run becomes
531 * true. Paired with the mb() above in cpuhp_thread_fun() 612 * true. Paired with the mb() above in cpuhp_thread_fun()
@@ -541,7 +622,7 @@ static int cpuhp_invoke_ap_callback(int cpu, enum cpuhp_state state,
541static void __cpuhp_kick_ap_work(struct cpuhp_cpu_state *st) 622static void __cpuhp_kick_ap_work(struct cpuhp_cpu_state *st)
542{ 623{
543 st->result = 0; 624 st->result = 0;
544 st->cb = NULL; 625 st->single = false;
545 /* 626 /*
546 * Make sure the above stores are visible before should_run becomes 627 * Make sure the above stores are visible before should_run becomes
547 * true. Paired with the mb() above in cpuhp_thread_fun() 628 * true. Paired with the mb() above in cpuhp_thread_fun()
@@ -674,12 +755,6 @@ static int notify_down_prepare(unsigned int cpu)
674 return err; 755 return err;
675} 756}
676 757
677static int notify_dying(unsigned int cpu)
678{
679 cpu_notify(CPU_DYING, cpu);
680 return 0;
681}
682
683/* Take this CPU down. */ 758/* Take this CPU down. */
684static int take_cpu_down(void *_param) 759static int take_cpu_down(void *_param)
685{ 760{
@@ -692,12 +767,16 @@ static int take_cpu_down(void *_param)
692 if (err < 0) 767 if (err < 0)
693 return err; 768 return err;
694 769
770 /*
771 * We get here while we are in CPUHP_TEARDOWN_CPU state and we must not
772 * do this step again.
773 */
774 WARN_ON(st->state != CPUHP_TEARDOWN_CPU);
775 st->state--;
695 /* Invoke the former CPU_DYING callbacks */ 776 /* Invoke the former CPU_DYING callbacks */
696 for (; st->state > target; st->state--) { 777 for (; st->state > target; st->state--)
697 struct cpuhp_step *step = cpuhp_ap_states + st->state; 778 cpuhp_invoke_callback(cpu, st->state, false, NULL);
698 779
699 cpuhp_invoke_callback(cpu, st->state, step->teardown);
700 }
701 /* Give up timekeeping duties */ 780 /* Give up timekeeping duties */
702 tick_handover_do_timer(); 781 tick_handover_do_timer();
703 /* Park the stopper thread */ 782 /* Park the stopper thread */
@@ -734,7 +813,7 @@ static int takedown_cpu(unsigned int cpu)
734 BUG_ON(cpu_online(cpu)); 813 BUG_ON(cpu_online(cpu));
735 814
736 /* 815 /*
737 * The migration_call() CPU_DYING callback will have removed all 816 * The CPUHP_AP_SCHED_MIGRATE_DYING callback will have removed all
738 * runnable tasks from the cpu, there's only the idle task left now 817 * runnable tasks from the cpu, there's only the idle task left now
739 * that the migration thread is done doing the stop_machine thing. 818 * that the migration thread is done doing the stop_machine thing.
740 * 819 *
@@ -787,7 +866,6 @@ void cpuhp_report_idle_dead(void)
787#define notify_down_prepare NULL 866#define notify_down_prepare NULL
788#define takedown_cpu NULL 867#define takedown_cpu NULL
789#define notify_dead NULL 868#define notify_dead NULL
790#define notify_dying NULL
791#endif 869#endif
792 870
793#ifdef CONFIG_HOTPLUG_CPU 871#ifdef CONFIG_HOTPLUG_CPU
@@ -836,7 +914,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen,
836 * The AP brought itself down to CPUHP_TEARDOWN_CPU. So we need 914 * The AP brought itself down to CPUHP_TEARDOWN_CPU. So we need
837 * to do the further cleanups. 915 * to do the further cleanups.
838 */ 916 */
839 ret = cpuhp_down_callbacks(cpu, st, cpuhp_bp_states, target); 917 ret = cpuhp_down_callbacks(cpu, st, target);
840 if (ret && st->state > CPUHP_TEARDOWN_CPU && st->state < prev_state) { 918 if (ret && st->state > CPUHP_TEARDOWN_CPU && st->state < prev_state) {
841 st->target = prev_state; 919 st->target = prev_state;
842 st->rollback = true; 920 st->rollback = true;
@@ -877,10 +955,9 @@ EXPORT_SYMBOL(cpu_down);
877#endif /*CONFIG_HOTPLUG_CPU*/ 955#endif /*CONFIG_HOTPLUG_CPU*/
878 956
879/** 957/**
880 * notify_cpu_starting(cpu) - call the CPU_STARTING notifiers 958 * notify_cpu_starting(cpu) - Invoke the callbacks on the starting CPU
881 * @cpu: cpu that just started 959 * @cpu: cpu that just started
882 * 960 *
883 * This function calls the cpu_chain notifiers with CPU_STARTING.
884 * It must be called by the arch code on the new cpu, before the new cpu 961 * It must be called by the arch code on the new cpu, before the new cpu
885 * enables interrupts and before the "boot" cpu returns from __cpu_up(). 962 * enables interrupts and before the "boot" cpu returns from __cpu_up().
886 */ 963 */
@@ -891,11 +968,8 @@ void notify_cpu_starting(unsigned int cpu)
891 968
892 rcu_cpu_starting(cpu); /* Enables RCU usage on this CPU. */ 969 rcu_cpu_starting(cpu); /* Enables RCU usage on this CPU. */
893 while (st->state < target) { 970 while (st->state < target) {
894 struct cpuhp_step *step;
895
896 st->state++; 971 st->state++;
897 step = cpuhp_ap_states + st->state; 972 cpuhp_invoke_callback(cpu, st->state, true, NULL);
898 cpuhp_invoke_callback(cpu, st->state, step->startup);
899 } 973 }
900} 974}
901 975
@@ -980,7 +1054,7 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
980 * responsible for bringing it up to the target state. 1054 * responsible for bringing it up to the target state.
981 */ 1055 */
982 target = min((int)target, CPUHP_BRINGUP_CPU); 1056 target = min((int)target, CPUHP_BRINGUP_CPU);
983 ret = cpuhp_up_callbacks(cpu, st, cpuhp_bp_states, target); 1057 ret = cpuhp_up_callbacks(cpu, st, target);
984out: 1058out:
985 cpu_hotplug_done(); 1059 cpu_hotplug_done();
986 return ret; 1060 return ret;
@@ -1083,7 +1157,7 @@ void enable_nonboot_cpus(void)
1083 1157
1084 /* Allow everyone to use the CPU hotplug again */ 1158 /* Allow everyone to use the CPU hotplug again */
1085 cpu_maps_update_begin(); 1159 cpu_maps_update_begin();
1086 WARN_ON(--cpu_hotplug_disabled < 0); 1160 __cpu_hotplug_enable();
1087 if (cpumask_empty(frozen_cpus)) 1161 if (cpumask_empty(frozen_cpus))
1088 goto out; 1162 goto out;
1089 1163
@@ -1172,40 +1246,50 @@ core_initcall(cpu_hotplug_pm_sync_init);
1172static struct cpuhp_step cpuhp_bp_states[] = { 1246static struct cpuhp_step cpuhp_bp_states[] = {
1173 [CPUHP_OFFLINE] = { 1247 [CPUHP_OFFLINE] = {
1174 .name = "offline", 1248 .name = "offline",
1175 .startup = NULL, 1249 .startup.single = NULL,
1176 .teardown = NULL, 1250 .teardown.single = NULL,
1177 }, 1251 },
1178#ifdef CONFIG_SMP 1252#ifdef CONFIG_SMP
1179 [CPUHP_CREATE_THREADS]= { 1253 [CPUHP_CREATE_THREADS]= {
1180 .name = "threads:create", 1254 .name = "threads:prepare",
1181 .startup = smpboot_create_threads, 1255 .startup.single = smpboot_create_threads,
1182 .teardown = NULL, 1256 .teardown.single = NULL,
1183 .cant_stop = true, 1257 .cant_stop = true,
1184 }, 1258 },
1185 [CPUHP_PERF_PREPARE] = { 1259 [CPUHP_PERF_PREPARE] = {
1186 .name = "perf prepare", 1260 .name = "perf:prepare",
1187 .startup = perf_event_init_cpu, 1261 .startup.single = perf_event_init_cpu,
1188 .teardown = perf_event_exit_cpu, 1262 .teardown.single = perf_event_exit_cpu,
1189 }, 1263 },
1190 [CPUHP_WORKQUEUE_PREP] = { 1264 [CPUHP_WORKQUEUE_PREP] = {
1191 .name = "workqueue prepare", 1265 .name = "workqueue:prepare",
1192 .startup = workqueue_prepare_cpu, 1266 .startup.single = workqueue_prepare_cpu,
1193 .teardown = NULL, 1267 .teardown.single = NULL,
1194 }, 1268 },
1195 [CPUHP_HRTIMERS_PREPARE] = { 1269 [CPUHP_HRTIMERS_PREPARE] = {
1196 .name = "hrtimers prepare", 1270 .name = "hrtimers:prepare",
1197 .startup = hrtimers_prepare_cpu, 1271 .startup.single = hrtimers_prepare_cpu,
1198 .teardown = hrtimers_dead_cpu, 1272 .teardown.single = hrtimers_dead_cpu,
1199 }, 1273 },
1200 [CPUHP_SMPCFD_PREPARE] = { 1274 [CPUHP_SMPCFD_PREPARE] = {
1201 .name = "SMPCFD prepare", 1275 .name = "smpcfd:prepare",
1202 .startup = smpcfd_prepare_cpu, 1276 .startup.single = smpcfd_prepare_cpu,
1203 .teardown = smpcfd_dead_cpu, 1277 .teardown.single = smpcfd_dead_cpu,
1278 },
1279 [CPUHP_RELAY_PREPARE] = {
1280 .name = "relay:prepare",
1281 .startup.single = relay_prepare_cpu,
1282 .teardown.single = NULL,
1283 },
1284 [CPUHP_SLAB_PREPARE] = {
1285 .name = "slab:prepare",
1286 .startup.single = slab_prepare_cpu,
1287 .teardown.single = slab_dead_cpu,
1204 }, 1288 },
1205 [CPUHP_RCUTREE_PREP] = { 1289 [CPUHP_RCUTREE_PREP] = {
1206 .name = "RCU-tree prepare", 1290 .name = "RCU/tree:prepare",
1207 .startup = rcutree_prepare_cpu, 1291 .startup.single = rcutree_prepare_cpu,
1208 .teardown = rcutree_dead_cpu, 1292 .teardown.single = rcutree_dead_cpu,
1209 }, 1293 },
1210 /* 1294 /*
1211 * Preparatory and dead notifiers. Will be replaced once the notifiers 1295 * Preparatory and dead notifiers. Will be replaced once the notifiers
@@ -1213,8 +1297,8 @@ static struct cpuhp_step cpuhp_bp_states[] = {
1213 */ 1297 */
1214 [CPUHP_NOTIFY_PREPARE] = { 1298 [CPUHP_NOTIFY_PREPARE] = {
1215 .name = "notify:prepare", 1299 .name = "notify:prepare",
1216 .startup = notify_prepare, 1300 .startup.single = notify_prepare,
1217 .teardown = notify_dead, 1301 .teardown.single = notify_dead,
1218 .skip_onerr = true, 1302 .skip_onerr = true,
1219 .cant_stop = true, 1303 .cant_stop = true,
1220 }, 1304 },
@@ -1224,20 +1308,21 @@ static struct cpuhp_step cpuhp_bp_states[] = {
1224 * otherwise a RCU stall occurs. 1308 * otherwise a RCU stall occurs.
1225 */ 1309 */
1226 [CPUHP_TIMERS_DEAD] = { 1310 [CPUHP_TIMERS_DEAD] = {
1227 .name = "timers dead", 1311 .name = "timers:dead",
1228 .startup = NULL, 1312 .startup.single = NULL,
1229 .teardown = timers_dead_cpu, 1313 .teardown.single = timers_dead_cpu,
1230 }, 1314 },
1231 /* Kicks the plugged cpu into life */ 1315 /* Kicks the plugged cpu into life */
1232 [CPUHP_BRINGUP_CPU] = { 1316 [CPUHP_BRINGUP_CPU] = {
1233 .name = "cpu:bringup", 1317 .name = "cpu:bringup",
1234 .startup = bringup_cpu, 1318 .startup.single = bringup_cpu,
1235 .teardown = NULL, 1319 .teardown.single = NULL,
1236 .cant_stop = true, 1320 .cant_stop = true,
1237 }, 1321 },
1238 [CPUHP_AP_SMPCFD_DYING] = { 1322 [CPUHP_AP_SMPCFD_DYING] = {
1239 .startup = NULL, 1323 .name = "smpcfd:dying",
1240 .teardown = smpcfd_dying_cpu, 1324 .startup.single = NULL,
1325 .teardown.single = smpcfd_dying_cpu,
1241 }, 1326 },
1242 /* 1327 /*
1243 * Handled on controll processor until the plugged processor manages 1328 * Handled on controll processor until the plugged processor manages
@@ -1245,8 +1330,8 @@ static struct cpuhp_step cpuhp_bp_states[] = {
1245 */ 1330 */
1246 [CPUHP_TEARDOWN_CPU] = { 1331 [CPUHP_TEARDOWN_CPU] = {
1247 .name = "cpu:teardown", 1332 .name = "cpu:teardown",
1248 .startup = NULL, 1333 .startup.single = NULL,
1249 .teardown = takedown_cpu, 1334 .teardown.single = takedown_cpu,
1250 .cant_stop = true, 1335 .cant_stop = true,
1251 }, 1336 },
1252#else 1337#else
@@ -1272,24 +1357,13 @@ static struct cpuhp_step cpuhp_ap_states[] = {
1272 /* First state is scheduler control. Interrupts are disabled */ 1357 /* First state is scheduler control. Interrupts are disabled */
1273 [CPUHP_AP_SCHED_STARTING] = { 1358 [CPUHP_AP_SCHED_STARTING] = {
1274 .name = "sched:starting", 1359 .name = "sched:starting",
1275 .startup = sched_cpu_starting, 1360 .startup.single = sched_cpu_starting,
1276 .teardown = sched_cpu_dying, 1361 .teardown.single = sched_cpu_dying,
1277 }, 1362 },
1278 [CPUHP_AP_RCUTREE_DYING] = { 1363 [CPUHP_AP_RCUTREE_DYING] = {
1279 .startup = NULL, 1364 .name = "RCU/tree:dying",
1280 .teardown = rcutree_dying_cpu, 1365 .startup.single = NULL,
1281 }, 1366 .teardown.single = rcutree_dying_cpu,
1282 /*
1283 * Low level startup/teardown notifiers. Run with interrupts
1284 * disabled. Will be removed once the notifiers are converted to
1285 * states.
1286 */
1287 [CPUHP_AP_NOTIFY_STARTING] = {
1288 .name = "notify:starting",
1289 .startup = notify_starting,
1290 .teardown = notify_dying,
1291 .skip_onerr = true,
1292 .cant_stop = true,
1293 }, 1367 },
1294 /* Entry state on starting. Interrupts enabled from here on. Transient 1368 /* Entry state on starting. Interrupts enabled from here on. Transient
1295 * state for synchronsization */ 1369 * state for synchronsization */
@@ -1298,24 +1372,24 @@ static struct cpuhp_step cpuhp_ap_states[] = {
1298 }, 1372 },
1299 /* Handle smpboot threads park/unpark */ 1373 /* Handle smpboot threads park/unpark */
1300 [CPUHP_AP_SMPBOOT_THREADS] = { 1374 [CPUHP_AP_SMPBOOT_THREADS] = {
1301 .name = "smpboot:threads", 1375 .name = "smpboot/threads:online",
1302 .startup = smpboot_unpark_threads, 1376 .startup.single = smpboot_unpark_threads,
1303 .teardown = NULL, 1377 .teardown.single = NULL,
1304 }, 1378 },
1305 [CPUHP_AP_PERF_ONLINE] = { 1379 [CPUHP_AP_PERF_ONLINE] = {
1306 .name = "perf online", 1380 .name = "perf:online",
1307 .startup = perf_event_init_cpu, 1381 .startup.single = perf_event_init_cpu,
1308 .teardown = perf_event_exit_cpu, 1382 .teardown.single = perf_event_exit_cpu,
1309 }, 1383 },
1310 [CPUHP_AP_WORKQUEUE_ONLINE] = { 1384 [CPUHP_AP_WORKQUEUE_ONLINE] = {
1311 .name = "workqueue online", 1385 .name = "workqueue:online",
1312 .startup = workqueue_online_cpu, 1386 .startup.single = workqueue_online_cpu,
1313 .teardown = workqueue_offline_cpu, 1387 .teardown.single = workqueue_offline_cpu,
1314 }, 1388 },
1315 [CPUHP_AP_RCUTREE_ONLINE] = { 1389 [CPUHP_AP_RCUTREE_ONLINE] = {
1316 .name = "RCU-tree online", 1390 .name = "RCU/tree:online",
1317 .startup = rcutree_online_cpu, 1391 .startup.single = rcutree_online_cpu,
1318 .teardown = rcutree_offline_cpu, 1392 .teardown.single = rcutree_offline_cpu,
1319 }, 1393 },
1320 1394
1321 /* 1395 /*
@@ -1324,8 +1398,8 @@ static struct cpuhp_step cpuhp_ap_states[] = {
1324 */ 1398 */
1325 [CPUHP_AP_NOTIFY_ONLINE] = { 1399 [CPUHP_AP_NOTIFY_ONLINE] = {
1326 .name = "notify:online", 1400 .name = "notify:online",
1327 .startup = notify_online, 1401 .startup.single = notify_online,
1328 .teardown = notify_down_prepare, 1402 .teardown.single = notify_down_prepare,
1329 .skip_onerr = true, 1403 .skip_onerr = true,
1330 }, 1404 },
1331#endif 1405#endif
@@ -1337,16 +1411,16 @@ static struct cpuhp_step cpuhp_ap_states[] = {
1337 /* Last state is scheduler control setting the cpu active */ 1411 /* Last state is scheduler control setting the cpu active */
1338 [CPUHP_AP_ACTIVE] = { 1412 [CPUHP_AP_ACTIVE] = {
1339 .name = "sched:active", 1413 .name = "sched:active",
1340 .startup = sched_cpu_activate, 1414 .startup.single = sched_cpu_activate,
1341 .teardown = sched_cpu_deactivate, 1415 .teardown.single = sched_cpu_deactivate,
1342 }, 1416 },
1343#endif 1417#endif
1344 1418
1345 /* CPU is fully up and running. */ 1419 /* CPU is fully up and running. */
1346 [CPUHP_ONLINE] = { 1420 [CPUHP_ONLINE] = {
1347 .name = "online", 1421 .name = "online",
1348 .startup = NULL, 1422 .startup.single = NULL,
1349 .teardown = NULL, 1423 .teardown.single = NULL,
1350 }, 1424 },
1351}; 1425};
1352 1426
@@ -1358,54 +1432,42 @@ static int cpuhp_cb_check(enum cpuhp_state state)
1358 return 0; 1432 return 0;
1359} 1433}
1360 1434
1361static bool cpuhp_is_ap_state(enum cpuhp_state state)
1362{
1363 /*
1364 * The extra check for CPUHP_TEARDOWN_CPU is only for documentation
1365 * purposes as that state is handled explicitely in cpu_down.
1366 */
1367 return state > CPUHP_BRINGUP_CPU && state != CPUHP_TEARDOWN_CPU;
1368}
1369
1370static struct cpuhp_step *cpuhp_get_step(enum cpuhp_state state)
1371{
1372 struct cpuhp_step *sp;
1373
1374 sp = cpuhp_is_ap_state(state) ? cpuhp_ap_states : cpuhp_bp_states;
1375 return sp + state;
1376}
1377
1378static void cpuhp_store_callbacks(enum cpuhp_state state, 1435static void cpuhp_store_callbacks(enum cpuhp_state state,
1379 const char *name, 1436 const char *name,
1380 int (*startup)(unsigned int cpu), 1437 int (*startup)(unsigned int cpu),
1381 int (*teardown)(unsigned int cpu)) 1438 int (*teardown)(unsigned int cpu),
1439 bool multi_instance)
1382{ 1440{
1383 /* (Un)Install the callbacks for further cpu hotplug operations */ 1441 /* (Un)Install the callbacks for further cpu hotplug operations */
1384 struct cpuhp_step *sp; 1442 struct cpuhp_step *sp;
1385 1443
1386 mutex_lock(&cpuhp_state_mutex); 1444 mutex_lock(&cpuhp_state_mutex);
1387 sp = cpuhp_get_step(state); 1445 sp = cpuhp_get_step(state);
1388 sp->startup = startup; 1446 sp->startup.single = startup;
1389 sp->teardown = teardown; 1447 sp->teardown.single = teardown;
1390 sp->name = name; 1448 sp->name = name;
1449 sp->multi_instance = multi_instance;
1450 INIT_HLIST_HEAD(&sp->list);
1391 mutex_unlock(&cpuhp_state_mutex); 1451 mutex_unlock(&cpuhp_state_mutex);
1392} 1452}
1393 1453
1394static void *cpuhp_get_teardown_cb(enum cpuhp_state state) 1454static void *cpuhp_get_teardown_cb(enum cpuhp_state state)
1395{ 1455{
1396 return cpuhp_get_step(state)->teardown; 1456 return cpuhp_get_step(state)->teardown.single;
1397} 1457}
1398 1458
1399/* 1459/*
1400 * Call the startup/teardown function for a step either on the AP or 1460 * Call the startup/teardown function for a step either on the AP or
1401 * on the current CPU. 1461 * on the current CPU.
1402 */ 1462 */
1403static int cpuhp_issue_call(int cpu, enum cpuhp_state state, 1463static int cpuhp_issue_call(int cpu, enum cpuhp_state state, bool bringup,
1404 int (*cb)(unsigned int), bool bringup) 1464 struct hlist_node *node)
1405{ 1465{
1466 struct cpuhp_step *sp = cpuhp_get_step(state);
1406 int ret; 1467 int ret;
1407 1468
1408 if (!cb) 1469 if ((bringup && !sp->startup.single) ||
1470 (!bringup && !sp->teardown.single))
1409 return 0; 1471 return 0;
1410 /* 1472 /*
1411 * The non AP bound callbacks can fail on bringup. On teardown 1473 * The non AP bound callbacks can fail on bringup. On teardown
@@ -1413,11 +1475,11 @@ static int cpuhp_issue_call(int cpu, enum cpuhp_state state,
1413 */ 1475 */
1414#ifdef CONFIG_SMP 1476#ifdef CONFIG_SMP
1415 if (cpuhp_is_ap_state(state)) 1477 if (cpuhp_is_ap_state(state))
1416 ret = cpuhp_invoke_ap_callback(cpu, state, cb); 1478 ret = cpuhp_invoke_ap_callback(cpu, state, bringup, node);
1417 else 1479 else
1418 ret = cpuhp_invoke_callback(cpu, state, cb); 1480 ret = cpuhp_invoke_callback(cpu, state, bringup, node);
1419#else 1481#else
1420 ret = cpuhp_invoke_callback(cpu, state, cb); 1482 ret = cpuhp_invoke_callback(cpu, state, bringup, node);
1421#endif 1483#endif
1422 BUG_ON(ret && !bringup); 1484 BUG_ON(ret && !bringup);
1423 return ret; 1485 return ret;
@@ -1429,13 +1491,10 @@ static int cpuhp_issue_call(int cpu, enum cpuhp_state state,
1429 * Note: The teardown callbacks for rollback are not allowed to fail! 1491 * Note: The teardown callbacks for rollback are not allowed to fail!
1430 */ 1492 */
1431static void cpuhp_rollback_install(int failedcpu, enum cpuhp_state state, 1493static void cpuhp_rollback_install(int failedcpu, enum cpuhp_state state,
1432 int (*teardown)(unsigned int cpu)) 1494 struct hlist_node *node)
1433{ 1495{
1434 int cpu; 1496 int cpu;
1435 1497
1436 if (!teardown)
1437 return;
1438
1439 /* Roll back the already executed steps on the other cpus */ 1498 /* Roll back the already executed steps on the other cpus */
1440 for_each_present_cpu(cpu) { 1499 for_each_present_cpu(cpu) {
1441 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); 1500 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
@@ -1446,7 +1505,7 @@ static void cpuhp_rollback_install(int failedcpu, enum cpuhp_state state,
1446 1505
1447 /* Did we invoke the startup call on that cpu ? */ 1506 /* Did we invoke the startup call on that cpu ? */
1448 if (cpustate >= state) 1507 if (cpustate >= state)
1449 cpuhp_issue_call(cpu, state, teardown, false); 1508 cpuhp_issue_call(cpu, state, false, node);
1450 } 1509 }
1451} 1510}
1452 1511
@@ -1473,6 +1532,52 @@ static int cpuhp_reserve_state(enum cpuhp_state state)
1473 return -ENOSPC; 1532 return -ENOSPC;
1474} 1533}
1475 1534
1535int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node,
1536 bool invoke)
1537{
1538 struct cpuhp_step *sp;
1539 int cpu;
1540 int ret;
1541
1542 sp = cpuhp_get_step(state);
1543 if (sp->multi_instance == false)
1544 return -EINVAL;
1545
1546 get_online_cpus();
1547
1548 if (!invoke || !sp->startup.multi)
1549 goto add_node;
1550
1551 /*
1552 * Try to call the startup callback for each present cpu
1553 * depending on the hotplug state of the cpu.
1554 */
1555 for_each_present_cpu(cpu) {
1556 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
1557 int cpustate = st->state;
1558
1559 if (cpustate < state)
1560 continue;
1561
1562 ret = cpuhp_issue_call(cpu, state, true, node);
1563 if (ret) {
1564 if (sp->teardown.multi)
1565 cpuhp_rollback_install(cpu, state, node);
1566 goto err;
1567 }
1568 }
1569add_node:
1570 ret = 0;
1571 mutex_lock(&cpuhp_state_mutex);
1572 hlist_add_head(node, &sp->list);
1573 mutex_unlock(&cpuhp_state_mutex);
1574
1575err:
1576 put_online_cpus();
1577 return ret;
1578}
1579EXPORT_SYMBOL_GPL(__cpuhp_state_add_instance);
1580
1476/** 1581/**
1477 * __cpuhp_setup_state - Setup the callbacks for an hotplug machine state 1582 * __cpuhp_setup_state - Setup the callbacks for an hotplug machine state
1478 * @state: The state to setup 1583 * @state: The state to setup
@@ -1486,7 +1591,8 @@ static int cpuhp_reserve_state(enum cpuhp_state state)
1486int __cpuhp_setup_state(enum cpuhp_state state, 1591int __cpuhp_setup_state(enum cpuhp_state state,
1487 const char *name, bool invoke, 1592 const char *name, bool invoke,
1488 int (*startup)(unsigned int cpu), 1593 int (*startup)(unsigned int cpu),
1489 int (*teardown)(unsigned int cpu)) 1594 int (*teardown)(unsigned int cpu),
1595 bool multi_instance)
1490{ 1596{
1491 int cpu, ret = 0; 1597 int cpu, ret = 0;
1492 int dyn_state = 0; 1598 int dyn_state = 0;
@@ -1505,7 +1611,7 @@ int __cpuhp_setup_state(enum cpuhp_state state,
1505 state = ret; 1611 state = ret;
1506 } 1612 }
1507 1613
1508 cpuhp_store_callbacks(state, name, startup, teardown); 1614 cpuhp_store_callbacks(state, name, startup, teardown, multi_instance);
1509 1615
1510 if (!invoke || !startup) 1616 if (!invoke || !startup)
1511 goto out; 1617 goto out;
@@ -1521,10 +1627,11 @@ int __cpuhp_setup_state(enum cpuhp_state state,
1521 if (cpustate < state) 1627 if (cpustate < state)
1522 continue; 1628 continue;
1523 1629
1524 ret = cpuhp_issue_call(cpu, state, startup, true); 1630 ret = cpuhp_issue_call(cpu, state, true, NULL);
1525 if (ret) { 1631 if (ret) {
1526 cpuhp_rollback_install(cpu, state, teardown); 1632 if (teardown)
1527 cpuhp_store_callbacks(state, NULL, NULL, NULL); 1633 cpuhp_rollback_install(cpu, state, NULL);
1634 cpuhp_store_callbacks(state, NULL, NULL, NULL, false);
1528 goto out; 1635 goto out;
1529 } 1636 }
1530 } 1637 }
@@ -1536,6 +1643,42 @@ out:
1536} 1643}
1537EXPORT_SYMBOL(__cpuhp_setup_state); 1644EXPORT_SYMBOL(__cpuhp_setup_state);
1538 1645
1646int __cpuhp_state_remove_instance(enum cpuhp_state state,
1647 struct hlist_node *node, bool invoke)
1648{
1649 struct cpuhp_step *sp = cpuhp_get_step(state);
1650 int cpu;
1651
1652 BUG_ON(cpuhp_cb_check(state));
1653
1654 if (!sp->multi_instance)
1655 return -EINVAL;
1656
1657 get_online_cpus();
1658 if (!invoke || !cpuhp_get_teardown_cb(state))
1659 goto remove;
1660 /*
1661 * Call the teardown callback for each present cpu depending
1662 * on the hotplug state of the cpu. This function is not
1663 * allowed to fail currently!
1664 */
1665 for_each_present_cpu(cpu) {
1666 struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
1667 int cpustate = st->state;
1668
1669 if (cpustate >= state)
1670 cpuhp_issue_call(cpu, state, false, node);
1671 }
1672
1673remove:
1674 mutex_lock(&cpuhp_state_mutex);
1675 hlist_del(node);
1676 mutex_unlock(&cpuhp_state_mutex);
1677 put_online_cpus();
1678
1679 return 0;
1680}
1681EXPORT_SYMBOL_GPL(__cpuhp_state_remove_instance);
1539/** 1682/**
1540 * __cpuhp_remove_state - Remove the callbacks for an hotplug machine state 1683 * __cpuhp_remove_state - Remove the callbacks for an hotplug machine state
1541 * @state: The state to remove 1684 * @state: The state to remove
@@ -1547,14 +1690,21 @@ EXPORT_SYMBOL(__cpuhp_setup_state);
1547 */ 1690 */
1548void __cpuhp_remove_state(enum cpuhp_state state, bool invoke) 1691void __cpuhp_remove_state(enum cpuhp_state state, bool invoke)
1549{ 1692{
1550 int (*teardown)(unsigned int cpu) = cpuhp_get_teardown_cb(state); 1693 struct cpuhp_step *sp = cpuhp_get_step(state);
1551 int cpu; 1694 int cpu;
1552 1695
1553 BUG_ON(cpuhp_cb_check(state)); 1696 BUG_ON(cpuhp_cb_check(state));
1554 1697
1555 get_online_cpus(); 1698 get_online_cpus();
1556 1699
1557 if (!invoke || !teardown) 1700 if (sp->multi_instance) {
1701 WARN(!hlist_empty(&sp->list),
1702 "Error: Removing state %d which has instances left.\n",
1703 state);
1704 goto remove;
1705 }
1706
1707 if (!invoke || !cpuhp_get_teardown_cb(state))
1558 goto remove; 1708 goto remove;
1559 1709
1560 /* 1710 /*
@@ -1567,10 +1717,10 @@ void __cpuhp_remove_state(enum cpuhp_state state, bool invoke)
1567 int cpustate = st->state; 1717 int cpustate = st->state;
1568 1718
1569 if (cpustate >= state) 1719 if (cpustate >= state)
1570 cpuhp_issue_call(cpu, state, teardown, false); 1720 cpuhp_issue_call(cpu, state, false, NULL);
1571 } 1721 }
1572remove: 1722remove:
1573 cpuhp_store_callbacks(state, NULL, NULL, NULL); 1723 cpuhp_store_callbacks(state, NULL, NULL, NULL, false);
1574 put_online_cpus(); 1724 put_online_cpus();
1575} 1725}
1576EXPORT_SYMBOL(__cpuhp_remove_state); 1726EXPORT_SYMBOL(__cpuhp_remove_state);
diff --git a/kernel/padata.c b/kernel/padata.c
index 993278895ccc..7848f0566403 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -30,6 +30,7 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/sysfs.h> 31#include <linux/sysfs.h>
32#include <linux/rcupdate.h> 32#include <linux/rcupdate.h>
33#include <linux/module.h>
33 34
34#define MAX_OBJ_NUM 1000 35#define MAX_OBJ_NUM 1000
35 36
@@ -769,52 +770,43 @@ static inline int pinst_has_cpu(struct padata_instance *pinst, int cpu)
769 cpumask_test_cpu(cpu, pinst->cpumask.cbcpu); 770 cpumask_test_cpu(cpu, pinst->cpumask.cbcpu);
770} 771}
771 772
772 773static int padata_cpu_online(unsigned int cpu, struct hlist_node *node)
773static int padata_cpu_callback(struct notifier_block *nfb,
774 unsigned long action, void *hcpu)
775{ 774{
776 int err;
777 struct padata_instance *pinst; 775 struct padata_instance *pinst;
778 int cpu = (unsigned long)hcpu; 776 int ret;
779 777
780 pinst = container_of(nfb, struct padata_instance, cpu_notifier); 778 pinst = hlist_entry_safe(node, struct padata_instance, node);
779 if (!pinst_has_cpu(pinst, cpu))
780 return 0;
781 781
782 switch (action) { 782 mutex_lock(&pinst->lock);
783 case CPU_ONLINE: 783 ret = __padata_add_cpu(pinst, cpu);
784 case CPU_ONLINE_FROZEN: 784 mutex_unlock(&pinst->lock);
785 case CPU_DOWN_FAILED: 785 return ret;
786 case CPU_DOWN_FAILED_FROZEN: 786}
787 if (!pinst_has_cpu(pinst, cpu))
788 break;
789 mutex_lock(&pinst->lock);
790 err = __padata_add_cpu(pinst, cpu);
791 mutex_unlock(&pinst->lock);
792 if (err)
793 return notifier_from_errno(err);
794 break;
795 787
796 case CPU_DOWN_PREPARE: 788static int padata_cpu_prep_down(unsigned int cpu, struct hlist_node *node)
797 case CPU_DOWN_PREPARE_FROZEN: 789{
798 case CPU_UP_CANCELED: 790 struct padata_instance *pinst;
799 case CPU_UP_CANCELED_FROZEN: 791 int ret;
800 if (!pinst_has_cpu(pinst, cpu)) 792
801 break; 793 pinst = hlist_entry_safe(node, struct padata_instance, node);
802 mutex_lock(&pinst->lock); 794 if (!pinst_has_cpu(pinst, cpu))
803 err = __padata_remove_cpu(pinst, cpu); 795 return 0;
804 mutex_unlock(&pinst->lock);
805 if (err)
806 return notifier_from_errno(err);
807 break;
808 }
809 796
810 return NOTIFY_OK; 797 mutex_lock(&pinst->lock);
798 ret = __padata_remove_cpu(pinst, cpu);
799 mutex_unlock(&pinst->lock);
800 return ret;
811} 801}
802
803static enum cpuhp_state hp_online;
812#endif 804#endif
813 805
814static void __padata_free(struct padata_instance *pinst) 806static void __padata_free(struct padata_instance *pinst)
815{ 807{
816#ifdef CONFIG_HOTPLUG_CPU 808#ifdef CONFIG_HOTPLUG_CPU
817 unregister_hotcpu_notifier(&pinst->cpu_notifier); 809 cpuhp_state_remove_instance_nocalls(hp_online, &pinst->node);
818#endif 810#endif
819 811
820 padata_stop(pinst); 812 padata_stop(pinst);
@@ -1012,11 +1004,8 @@ struct padata_instance *padata_alloc(struct workqueue_struct *wq,
1012 mutex_init(&pinst->lock); 1004 mutex_init(&pinst->lock);
1013 1005
1014#ifdef CONFIG_HOTPLUG_CPU 1006#ifdef CONFIG_HOTPLUG_CPU
1015 pinst->cpu_notifier.notifier_call = padata_cpu_callback; 1007 cpuhp_state_add_instance_nocalls(hp_online, &pinst->node);
1016 pinst->cpu_notifier.priority = 0;
1017 register_hotcpu_notifier(&pinst->cpu_notifier);
1018#endif 1008#endif
1019
1020 return pinst; 1009 return pinst;
1021 1010
1022err_free_masks: 1011err_free_masks:
@@ -1039,3 +1028,26 @@ void padata_free(struct padata_instance *pinst)
1039 kobject_put(&pinst->kobj); 1028 kobject_put(&pinst->kobj);
1040} 1029}
1041EXPORT_SYMBOL(padata_free); 1030EXPORT_SYMBOL(padata_free);
1031
1032#ifdef CONFIG_HOTPLUG_CPU
1033
1034static __init int padata_driver_init(void)
1035{
1036 int ret;
1037
1038 ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN, "padata:online",
1039 padata_cpu_online,
1040 padata_cpu_prep_down);
1041 if (ret < 0)
1042 return ret;
1043 hp_online = ret;
1044 return 0;
1045}
1046module_init(padata_driver_init);
1047
1048static __exit void padata_driver_exit(void)
1049{
1050 cpuhp_remove_multi_state(hp_online);
1051}
1052module_exit(padata_driver_exit);
1053#endif
diff --git a/kernel/relay.c b/kernel/relay.c
index d797502140b9..fc9b4a4af463 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -214,7 +214,7 @@ static void relay_destroy_buf(struct rchan_buf *buf)
214 __free_page(buf->page_array[i]); 214 __free_page(buf->page_array[i]);
215 relay_free_page_array(buf->page_array); 215 relay_free_page_array(buf->page_array);
216 } 216 }
217 chan->buf[buf->cpu] = NULL; 217 *per_cpu_ptr(chan->buf, buf->cpu) = NULL;
218 kfree(buf->padding); 218 kfree(buf->padding);
219 kfree(buf); 219 kfree(buf);
220 kref_put(&chan->kref, relay_destroy_channel); 220 kref_put(&chan->kref, relay_destroy_channel);
@@ -382,20 +382,21 @@ static void __relay_reset(struct rchan_buf *buf, unsigned int init)
382 */ 382 */
383void relay_reset(struct rchan *chan) 383void relay_reset(struct rchan *chan)
384{ 384{
385 struct rchan_buf *buf;
385 unsigned int i; 386 unsigned int i;
386 387
387 if (!chan) 388 if (!chan)
388 return; 389 return;
389 390
390 if (chan->is_global && chan->buf[0]) { 391 if (chan->is_global && (buf = *per_cpu_ptr(chan->buf, 0))) {
391 __relay_reset(chan->buf[0], 0); 392 __relay_reset(buf, 0);
392 return; 393 return;
393 } 394 }
394 395
395 mutex_lock(&relay_channels_mutex); 396 mutex_lock(&relay_channels_mutex);
396 for_each_possible_cpu(i) 397 for_each_possible_cpu(i)
397 if (chan->buf[i]) 398 if ((buf = *per_cpu_ptr(chan->buf, i)))
398 __relay_reset(chan->buf[i], 0); 399 __relay_reset(buf, 0);
399 mutex_unlock(&relay_channels_mutex); 400 mutex_unlock(&relay_channels_mutex);
400} 401}
401EXPORT_SYMBOL_GPL(relay_reset); 402EXPORT_SYMBOL_GPL(relay_reset);
@@ -440,7 +441,7 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)
440 struct dentry *dentry; 441 struct dentry *dentry;
441 442
442 if (chan->is_global) 443 if (chan->is_global)
443 return chan->buf[0]; 444 return *per_cpu_ptr(chan->buf, 0);
444 445
445 buf = relay_create_buf(chan); 446 buf = relay_create_buf(chan);
446 if (!buf) 447 if (!buf)
@@ -464,7 +465,7 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)
464 __relay_reset(buf, 1); 465 __relay_reset(buf, 1);
465 466
466 if(chan->is_global) { 467 if(chan->is_global) {
467 chan->buf[0] = buf; 468 *per_cpu_ptr(chan->buf, 0) = buf;
468 buf->cpu = 0; 469 buf->cpu = 0;
469 } 470 }
470 471
@@ -512,46 +513,25 @@ static void setup_callbacks(struct rchan *chan,
512 chan->cb = cb; 513 chan->cb = cb;
513} 514}
514 515
515/** 516int relay_prepare_cpu(unsigned int cpu)
516 * relay_hotcpu_callback - CPU hotplug callback
517 * @nb: notifier block
518 * @action: hotplug action to take
519 * @hcpu: CPU number
520 *
521 * Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD)
522 */
523static int relay_hotcpu_callback(struct notifier_block *nb,
524 unsigned long action,
525 void *hcpu)
526{ 517{
527 unsigned int hotcpu = (unsigned long)hcpu;
528 struct rchan *chan; 518 struct rchan *chan;
519 struct rchan_buf *buf;
529 520
530 switch(action) { 521 mutex_lock(&relay_channels_mutex);
531 case CPU_UP_PREPARE: 522 list_for_each_entry(chan, &relay_channels, list) {
532 case CPU_UP_PREPARE_FROZEN: 523 if ((buf = *per_cpu_ptr(chan->buf, cpu)))
533 mutex_lock(&relay_channels_mutex); 524 continue;
534 list_for_each_entry(chan, &relay_channels, list) { 525 buf = relay_open_buf(chan, cpu);
535 if (chan->buf[hotcpu]) 526 if (!buf) {
536 continue; 527 pr_err("relay: cpu %d buffer creation failed\n", cpu);
537 chan->buf[hotcpu] = relay_open_buf(chan, hotcpu); 528 mutex_unlock(&relay_channels_mutex);
538 if(!chan->buf[hotcpu]) { 529 return -ENOMEM;
539 printk(KERN_ERR
540 "relay_hotcpu_callback: cpu %d buffer "
541 "creation failed\n", hotcpu);
542 mutex_unlock(&relay_channels_mutex);
543 return notifier_from_errno(-ENOMEM);
544 }
545 } 530 }
546 mutex_unlock(&relay_channels_mutex); 531 *per_cpu_ptr(chan->buf, cpu) = buf;
547 break;
548 case CPU_DEAD:
549 case CPU_DEAD_FROZEN:
550 /* No need to flush the cpu : will be flushed upon
551 * final relay_flush() call. */
552 break;
553 } 532 }
554 return NOTIFY_OK; 533 mutex_unlock(&relay_channels_mutex);
534 return 0;
555} 535}
556 536
557/** 537/**
@@ -583,6 +563,7 @@ struct rchan *relay_open(const char *base_filename,
583{ 563{
584 unsigned int i; 564 unsigned int i;
585 struct rchan *chan; 565 struct rchan *chan;
566 struct rchan_buf *buf;
586 567
587 if (!(subbuf_size && n_subbufs)) 568 if (!(subbuf_size && n_subbufs))
588 return NULL; 569 return NULL;
@@ -593,6 +574,7 @@ struct rchan *relay_open(const char *base_filename,
593 if (!chan) 574 if (!chan)
594 return NULL; 575 return NULL;
595 576
577 chan->buf = alloc_percpu(struct rchan_buf *);
596 chan->version = RELAYFS_CHANNEL_VERSION; 578 chan->version = RELAYFS_CHANNEL_VERSION;
597 chan->n_subbufs = n_subbufs; 579 chan->n_subbufs = n_subbufs;
598 chan->subbuf_size = subbuf_size; 580 chan->subbuf_size = subbuf_size;
@@ -608,9 +590,10 @@ struct rchan *relay_open(const char *base_filename,
608 590
609 mutex_lock(&relay_channels_mutex); 591 mutex_lock(&relay_channels_mutex);
610 for_each_online_cpu(i) { 592 for_each_online_cpu(i) {
611 chan->buf[i] = relay_open_buf(chan, i); 593 buf = relay_open_buf(chan, i);
612 if (!chan->buf[i]) 594 if (!buf)
613 goto free_bufs; 595 goto free_bufs;
596 *per_cpu_ptr(chan->buf, i) = buf;
614 } 597 }
615 list_add(&chan->list, &relay_channels); 598 list_add(&chan->list, &relay_channels);
616 mutex_unlock(&relay_channels_mutex); 599 mutex_unlock(&relay_channels_mutex);
@@ -619,8 +602,8 @@ struct rchan *relay_open(const char *base_filename,
619 602
620free_bufs: 603free_bufs:
621 for_each_possible_cpu(i) { 604 for_each_possible_cpu(i) {
622 if (chan->buf[i]) 605 if ((buf = *per_cpu_ptr(chan->buf, i)))
623 relay_close_buf(chan->buf[i]); 606 relay_close_buf(buf);
624 } 607 }
625 608
626 kref_put(&chan->kref, relay_destroy_channel); 609 kref_put(&chan->kref, relay_destroy_channel);
@@ -666,6 +649,7 @@ int relay_late_setup_files(struct rchan *chan,
666 unsigned int i, curr_cpu; 649 unsigned int i, curr_cpu;
667 unsigned long flags; 650 unsigned long flags;
668 struct dentry *dentry; 651 struct dentry *dentry;
652 struct rchan_buf *buf;
669 struct rchan_percpu_buf_dispatcher disp; 653 struct rchan_percpu_buf_dispatcher disp;
670 654
671 if (!chan || !base_filename) 655 if (!chan || !base_filename)
@@ -684,10 +668,11 @@ int relay_late_setup_files(struct rchan *chan,
684 668
685 if (chan->is_global) { 669 if (chan->is_global) {
686 err = -EINVAL; 670 err = -EINVAL;
687 if (!WARN_ON_ONCE(!chan->buf[0])) { 671 buf = *per_cpu_ptr(chan->buf, 0);
688 dentry = relay_create_buf_file(chan, chan->buf[0], 0); 672 if (!WARN_ON_ONCE(!buf)) {
673 dentry = relay_create_buf_file(chan, buf, 0);
689 if (dentry && !WARN_ON_ONCE(!chan->is_global)) { 674 if (dentry && !WARN_ON_ONCE(!chan->is_global)) {
690 relay_set_buf_dentry(chan->buf[0], dentry); 675 relay_set_buf_dentry(buf, dentry);
691 err = 0; 676 err = 0;
692 } 677 }
693 } 678 }
@@ -702,13 +687,14 @@ int relay_late_setup_files(struct rchan *chan,
702 * on all currently online CPUs. 687 * on all currently online CPUs.
703 */ 688 */
704 for_each_online_cpu(i) { 689 for_each_online_cpu(i) {
705 if (unlikely(!chan->buf[i])) { 690 buf = *per_cpu_ptr(chan->buf, i);
691 if (unlikely(!buf)) {
706 WARN_ONCE(1, KERN_ERR "CPU has no buffer!\n"); 692 WARN_ONCE(1, KERN_ERR "CPU has no buffer!\n");
707 err = -EINVAL; 693 err = -EINVAL;
708 break; 694 break;
709 } 695 }
710 696
711 dentry = relay_create_buf_file(chan, chan->buf[i], i); 697 dentry = relay_create_buf_file(chan, buf, i);
712 if (unlikely(!dentry)) { 698 if (unlikely(!dentry)) {
713 err = -EINVAL; 699 err = -EINVAL;
714 break; 700 break;
@@ -716,10 +702,10 @@ int relay_late_setup_files(struct rchan *chan,
716 702
717 if (curr_cpu == i) { 703 if (curr_cpu == i) {
718 local_irq_save(flags); 704 local_irq_save(flags);
719 relay_set_buf_dentry(chan->buf[i], dentry); 705 relay_set_buf_dentry(buf, dentry);
720 local_irq_restore(flags); 706 local_irq_restore(flags);
721 } else { 707 } else {
722 disp.buf = chan->buf[i]; 708 disp.buf = buf;
723 disp.dentry = dentry; 709 disp.dentry = dentry;
724 smp_mb(); 710 smp_mb();
725 /* relay_channels_mutex must be held, so wait. */ 711 /* relay_channels_mutex must be held, so wait. */
@@ -822,11 +808,10 @@ void relay_subbufs_consumed(struct rchan *chan,
822 if (!chan) 808 if (!chan)
823 return; 809 return;
824 810
825 if (cpu >= NR_CPUS || !chan->buf[cpu] || 811 buf = *per_cpu_ptr(chan->buf, cpu);
826 subbufs_consumed > chan->n_subbufs) 812 if (cpu >= NR_CPUS || !buf || subbufs_consumed > chan->n_subbufs)
827 return; 813 return;
828 814
829 buf = chan->buf[cpu];
830 if (subbufs_consumed > buf->subbufs_produced - buf->subbufs_consumed) 815 if (subbufs_consumed > buf->subbufs_produced - buf->subbufs_consumed)
831 buf->subbufs_consumed = buf->subbufs_produced; 816 buf->subbufs_consumed = buf->subbufs_produced;
832 else 817 else
@@ -842,18 +827,19 @@ EXPORT_SYMBOL_GPL(relay_subbufs_consumed);
842 */ 827 */
843void relay_close(struct rchan *chan) 828void relay_close(struct rchan *chan)
844{ 829{
830 struct rchan_buf *buf;
845 unsigned int i; 831 unsigned int i;
846 832
847 if (!chan) 833 if (!chan)
848 return; 834 return;
849 835
850 mutex_lock(&relay_channels_mutex); 836 mutex_lock(&relay_channels_mutex);
851 if (chan->is_global && chan->buf[0]) 837 if (chan->is_global && (buf = *per_cpu_ptr(chan->buf, 0)))
852 relay_close_buf(chan->buf[0]); 838 relay_close_buf(buf);
853 else 839 else
854 for_each_possible_cpu(i) 840 for_each_possible_cpu(i)
855 if (chan->buf[i]) 841 if ((buf = *per_cpu_ptr(chan->buf, i)))
856 relay_close_buf(chan->buf[i]); 842 relay_close_buf(buf);
857 843
858 if (chan->last_toobig) 844 if (chan->last_toobig)
859 printk(KERN_WARNING "relay: one or more items not logged " 845 printk(KERN_WARNING "relay: one or more items not logged "
@@ -874,20 +860,21 @@ EXPORT_SYMBOL_GPL(relay_close);
874 */ 860 */
875void relay_flush(struct rchan *chan) 861void relay_flush(struct rchan *chan)
876{ 862{
863 struct rchan_buf *buf;
877 unsigned int i; 864 unsigned int i;
878 865
879 if (!chan) 866 if (!chan)
880 return; 867 return;
881 868
882 if (chan->is_global && chan->buf[0]) { 869 if (chan->is_global && (buf = *per_cpu_ptr(chan->buf, 0))) {
883 relay_switch_subbuf(chan->buf[0], 0); 870 relay_switch_subbuf(buf, 0);
884 return; 871 return;
885 } 872 }
886 873
887 mutex_lock(&relay_channels_mutex); 874 mutex_lock(&relay_channels_mutex);
888 for_each_possible_cpu(i) 875 for_each_possible_cpu(i)
889 if (chan->buf[i]) 876 if ((buf = *per_cpu_ptr(chan->buf, i)))
890 relay_switch_subbuf(chan->buf[i], 0); 877 relay_switch_subbuf(buf, 0);
891 mutex_unlock(&relay_channels_mutex); 878 mutex_unlock(&relay_channels_mutex);
892} 879}
893EXPORT_SYMBOL_GPL(relay_flush); 880EXPORT_SYMBOL_GPL(relay_flush);
@@ -1377,12 +1364,3 @@ const struct file_operations relay_file_operations = {
1377 .splice_read = relay_file_splice_read, 1364 .splice_read = relay_file_splice_read,
1378}; 1365};
1379EXPORT_SYMBOL_GPL(relay_file_operations); 1366EXPORT_SYMBOL_GPL(relay_file_operations);
1380
1381static __init int relay_init(void)
1382{
1383
1384 hotcpu_notifier(relay_hotcpu_callback, 0);
1385 return 0;
1386}
1387
1388early_initcall(relay_init);
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 8ed90e3a88d6..66762645f9e8 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -714,7 +714,7 @@ void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu)
714 BUG(); 714 BUG();
715} 715}
716 716
717static void takeover_tasklets(unsigned int cpu) 717static int takeover_tasklets(unsigned int cpu)
718{ 718{
719 /* CPU is dead, so no lock needed. */ 719 /* CPU is dead, so no lock needed. */
720 local_irq_disable(); 720 local_irq_disable();
@@ -737,27 +737,12 @@ static void takeover_tasklets(unsigned int cpu)
737 raise_softirq_irqoff(HI_SOFTIRQ); 737 raise_softirq_irqoff(HI_SOFTIRQ);
738 738
739 local_irq_enable(); 739 local_irq_enable();
740 return 0;
740} 741}
742#else
743#define takeover_tasklets NULL
741#endif /* CONFIG_HOTPLUG_CPU */ 744#endif /* CONFIG_HOTPLUG_CPU */
742 745
743static int cpu_callback(struct notifier_block *nfb, unsigned long action,
744 void *hcpu)
745{
746 switch (action) {
747#ifdef CONFIG_HOTPLUG_CPU
748 case CPU_DEAD:
749 case CPU_DEAD_FROZEN:
750 takeover_tasklets((unsigned long)hcpu);
751 break;
752#endif /* CONFIG_HOTPLUG_CPU */
753 }
754 return NOTIFY_OK;
755}
756
757static struct notifier_block cpu_nfb = {
758 .notifier_call = cpu_callback
759};
760
761static struct smp_hotplug_thread softirq_threads = { 746static struct smp_hotplug_thread softirq_threads = {
762 .store = &ksoftirqd, 747 .store = &ksoftirqd,
763 .thread_should_run = ksoftirqd_should_run, 748 .thread_should_run = ksoftirqd_should_run,
@@ -767,8 +752,8 @@ static struct smp_hotplug_thread softirq_threads = {
767 752
768static __init int spawn_ksoftirqd(void) 753static __init int spawn_ksoftirqd(void)
769{ 754{
770 register_cpu_notifier(&cpu_nfb); 755 cpuhp_setup_state_nocalls(CPUHP_SOFTIRQ_DEAD, "softirq:dead", NULL,
771 756 takeover_tasklets);
772 BUG_ON(smpboot_register_percpu_thread(&softirq_threads)); 757 BUG_ON(smpboot_register_percpu_thread(&softirq_threads));
773 758
774 return 0; 759 return 0;