Skip to content

Commit 931ef16

Browse files
committed
cpu/hotplug: Unpark smpboot threads from the state machine
Handle the smpboot threads in the state machine. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: linux-arch@vger.kernel.org Cc: Rik van Riel <riel@redhat.com> Cc: Rafael Wysocki <rafael.j.wysocki@intel.com> Cc: "Srivatsa S. Bhat" <srivatsa@mit.edu> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Sebastian Siewior <bigeasy@linutronix.de> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Tejun Heo <tj@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Paul McKenney <paulmck@linux.vnet.ibm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul Turner <pjt@google.com> Link: http://lkml.kernel.org/r/20160226182341.295777684@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 949338e commit 931ef16

File tree

6 files changed

+13
-45
lines changed

6 files changed

+13
-45
lines changed

include/linux/cpu.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ enum {
7878
/* migration should happen before other stuff but after perf */
7979
CPU_PRI_PERF = 20,
8080
CPU_PRI_MIGRATION = 10,
81-
CPU_PRI_SMPBOOT = 9,
81+
8282
/* bring up workqueues before normal notifiers and down after */
8383
CPU_PRI_WORKQUEUE_UP = 5,
8484
CPU_PRI_WORKQUEUE_DOWN = -5,
@@ -172,7 +172,6 @@ static inline void __unregister_cpu_notifier(struct notifier_block *nb)
172172
}
173173
#endif
174174

175-
void smpboot_thread_init(void);
176175
int cpu_up(unsigned int cpu);
177176
void notify_cpu_starting(unsigned int cpu);
178177
extern void cpu_maps_update_begin(void);
@@ -221,10 +220,6 @@ static inline void cpu_notifier_register_done(void)
221220
{
222221
}
223222

224-
static inline void smpboot_thread_init(void)
225-
{
226-
}
227-
228223
#endif /* CONFIG_SMP */
229224
extern struct bus_type cpu_subsys;
230225

include/linux/cpuhotplug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enum cpuhp_state {
1111
CPUHP_AP_ONLINE,
1212
CPUHP_TEARDOWN_CPU,
1313
CPUHP_CPU_SET_ACTIVE,
14+
CPUHP_SMPBOOT_THREADS,
1415
CPUHP_NOTIFY_ONLINE,
1516
CPUHP_ONLINE_DYN,
1617
CPUHP_ONLINE_DYN_END = CPUHP_ONLINE_DYN + 30,

init/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ static noinline void __init_refok rest_init(void)
388388
int pid;
389389

390390
rcu_scheduler_starting();
391-
smpboot_thread_init();
392391
/*
393392
* We need to spawn init first so that it obtains pid 1, however
394393
* the init task will end up wanting to create kthreads, which, if

kernel/cpu.c

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,6 @@ static int takedown_cpu(unsigned int cpu)
481481
else
482482
synchronize_rcu();
483483

484-
smpboot_park_threads(cpu);
485-
486484
/*
487485
* Prevent irq alloc/free while the dying cpu reorganizes the
488486
* interrupt affinities.
@@ -612,38 +610,6 @@ int cpu_down(unsigned int cpu)
612610
EXPORT_SYMBOL(cpu_down);
613611
#endif /*CONFIG_HOTPLUG_CPU*/
614612

615-
/*
616-
* Unpark per-CPU smpboot kthreads at CPU-online time.
617-
*/
618-
static int smpboot_thread_call(struct notifier_block *nfb,
619-
unsigned long action, void *hcpu)
620-
{
621-
int cpu = (long)hcpu;
622-
623-
switch (action & ~CPU_TASKS_FROZEN) {
624-
625-
case CPU_DOWN_FAILED:
626-
case CPU_ONLINE:
627-
smpboot_unpark_threads(cpu);
628-
break;
629-
630-
default:
631-
break;
632-
}
633-
634-
return NOTIFY_OK;
635-
}
636-
637-
static struct notifier_block smpboot_thread_notifier = {
638-
.notifier_call = smpboot_thread_call,
639-
.priority = CPU_PRI_SMPBOOT,
640-
};
641-
642-
void smpboot_thread_init(void)
643-
{
644-
register_cpu_notifier(&smpboot_thread_notifier);
645-
}
646-
647613
/**
648614
* notify_cpu_starting(cpu) - call the CPU_STARTING notifiers
649615
* @cpu: cpu that just started
@@ -959,6 +925,11 @@ static struct cpuhp_step cpuhp_bp_states[] = {
959925
.startup = cpuhp_set_cpu_active,
960926
.teardown = NULL,
961927
},
928+
[CPUHP_SMPBOOT_THREADS] = {
929+
.name = "smpboot:threads",
930+
.startup = smpboot_unpark_threads,
931+
.teardown = smpboot_park_threads,
932+
},
962933
[CPUHP_NOTIFY_ONLINE] = {
963934
.name = "notify:online",
964935
.startup = notify_online,

kernel/smpboot.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static void smpboot_unpark_thread(struct smp_hotplug_thread *ht, unsigned int cp
226226
kthread_unpark(tsk);
227227
}
228228

229-
void smpboot_unpark_threads(unsigned int cpu)
229+
int smpboot_unpark_threads(unsigned int cpu)
230230
{
231231
struct smp_hotplug_thread *cur;
232232

@@ -235,6 +235,7 @@ void smpboot_unpark_threads(unsigned int cpu)
235235
if (cpumask_test_cpu(cpu, cur->cpumask))
236236
smpboot_unpark_thread(cur, cpu);
237237
mutex_unlock(&smpboot_threads_lock);
238+
return 0;
238239
}
239240

240241
static void smpboot_park_thread(struct smp_hotplug_thread *ht, unsigned int cpu)
@@ -245,14 +246,15 @@ static void smpboot_park_thread(struct smp_hotplug_thread *ht, unsigned int cpu)
245246
kthread_park(tsk);
246247
}
247248

248-
void smpboot_park_threads(unsigned int cpu)
249+
int smpboot_park_threads(unsigned int cpu)
249250
{
250251
struct smp_hotplug_thread *cur;
251252

252253
mutex_lock(&smpboot_threads_lock);
253254
list_for_each_entry_reverse(cur, &hotplug_threads, list)
254255
smpboot_park_thread(cur, cpu);
255256
mutex_unlock(&smpboot_threads_lock);
257+
return 0;
256258
}
257259

258260
static void smpboot_destroy_threads(struct smp_hotplug_thread *ht)

kernel/smpboot.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static inline void idle_threads_init(void) { }
1414
#endif
1515

1616
int smpboot_create_threads(unsigned int cpu);
17-
void smpboot_park_threads(unsigned int cpu);
18-
void smpboot_unpark_threads(unsigned int cpu);
17+
int smpboot_park_threads(unsigned int cpu);
18+
int smpboot_unpark_threads(unsigned int cpu);
1919

2020
#endif

0 commit comments

Comments
 (0)