summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2018-06-07 04:53:01 -0400
committerIngo Molnar <mingo@kernel.org>2018-07-03 03:20:44 -0400
commit167a88677b05d6a810f23b871cfb2b5db1808e60 (patch)
tree7955852b5f7b1fc56d88ff09c5b67d068d251843
parent9cf57731b63e37ed995b46690adc604891a9a28f (diff)
smpboot: Remove cpumask from the API
Now that the sole use of the whole smpboot_*cpumask() API is gone, remove it. Suggested-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--include/linux/smpboot.h15
-rw-r--r--kernel/smpboot.c54
2 files changed, 6 insertions, 63 deletions
diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h
index c174844cf663..d0884b525001 100644
--- a/include/linux/smpboot.h
+++ b/include/linux/smpboot.h
@@ -25,8 +25,6 @@ struct smpboot_thread_data;
25 * parked (cpu offline) 25 * parked (cpu offline)
26 * @unpark: Optional unpark function, called when the thread is 26 * @unpark: Optional unpark function, called when the thread is
27 * unparked (cpu online) 27 * unparked (cpu online)
28 * @cpumask: Internal state. To update which threads are unparked,
29 * call smpboot_update_cpumask_percpu_thread().
30 * @selfparking: Thread is not parked by the park function. 28 * @selfparking: Thread is not parked by the park function.
31 * @thread_comm: The base name of the thread 29 * @thread_comm: The base name of the thread
32 */ 30 */
@@ -40,23 +38,12 @@ struct smp_hotplug_thread {
40 void (*cleanup)(unsigned int cpu, bool online); 38 void (*cleanup)(unsigned int cpu, bool online);
41 void (*park)(unsigned int cpu); 39 void (*park)(unsigned int cpu);
42 void (*unpark)(unsigned int cpu); 40 void (*unpark)(unsigned int cpu);
43 cpumask_var_t cpumask;
44 bool selfparking; 41 bool selfparking;
45 const char *thread_comm; 42 const char *thread_comm;
46}; 43};
47 44
48int smpboot_register_percpu_thread_cpumask(struct smp_hotplug_thread *plug_thread, 45int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread);
49 const struct cpumask *cpumask);
50
51static inline int
52smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
53{
54 return smpboot_register_percpu_thread_cpumask(plug_thread,
55 cpu_possible_mask);
56}
57 46
58void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread); 47void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread);
59void smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread,
60 const struct cpumask *);
61 48
62#endif 49#endif
diff --git a/kernel/smpboot.c b/kernel/smpboot.c
index 5043e7433f4b..c230c2dd48e1 100644
--- a/kernel/smpboot.c
+++ b/kernel/smpboot.c
@@ -238,8 +238,7 @@ int smpboot_unpark_threads(unsigned int cpu)
238 238
239 mutex_lock(&smpboot_threads_lock); 239 mutex_lock(&smpboot_threads_lock);
240 list_for_each_entry(cur, &hotplug_threads, list) 240 list_for_each_entry(cur, &hotplug_threads, list)
241 if (cpumask_test_cpu(cpu, cur->cpumask)) 241 smpboot_unpark_thread(cur, cpu);
242 smpboot_unpark_thread(cur, cpu);
243 mutex_unlock(&smpboot_threads_lock); 242 mutex_unlock(&smpboot_threads_lock);
244 return 0; 243 return 0;
245} 244}
@@ -280,34 +279,26 @@ static void smpboot_destroy_threads(struct smp_hotplug_thread *ht)
280} 279}
281 280
282/** 281/**
283 * smpboot_register_percpu_thread_cpumask - Register a per_cpu thread related 282 * smpboot_register_percpu_thread - Register a per_cpu thread related
284 * to hotplug 283 * to hotplug
285 * @plug_thread: Hotplug thread descriptor 284 * @plug_thread: Hotplug thread descriptor
286 * @cpumask: The cpumask where threads run
287 * 285 *
288 * Creates and starts the threads on all online cpus. 286 * Creates and starts the threads on all online cpus.
289 */ 287 */
290int smpboot_register_percpu_thread_cpumask(struct smp_hotplug_thread *plug_thread, 288int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
291 const struct cpumask *cpumask)
292{ 289{
293 unsigned int cpu; 290 unsigned int cpu;
294 int ret = 0; 291 int ret = 0;
295 292
296 if (!alloc_cpumask_var(&plug_thread->cpumask, GFP_KERNEL))
297 return -ENOMEM;
298 cpumask_copy(plug_thread->cpumask, cpumask);
299
300 get_online_cpus(); 293 get_online_cpus();
301 mutex_lock(&smpboot_threads_lock); 294 mutex_lock(&smpboot_threads_lock);
302 for_each_online_cpu(cpu) { 295 for_each_online_cpu(cpu) {
303 ret = __smpboot_create_thread(plug_thread, cpu); 296 ret = __smpboot_create_thread(plug_thread, cpu);
304 if (ret) { 297 if (ret) {
305 smpboot_destroy_threads(plug_thread); 298 smpboot_destroy_threads(plug_thread);
306 free_cpumask_var(plug_thread->cpumask);
307 goto out; 299 goto out;
308 } 300 }
309 if (cpumask_test_cpu(cpu, cpumask)) 301 smpboot_unpark_thread(plug_thread, cpu);
310 smpboot_unpark_thread(plug_thread, cpu);
311 } 302 }
312 list_add(&plug_thread->list, &hotplug_threads); 303 list_add(&plug_thread->list, &hotplug_threads);
313out: 304out:
@@ -315,7 +306,7 @@ out:
315 put_online_cpus(); 306 put_online_cpus();
316 return ret; 307 return ret;
317} 308}
318EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread_cpumask); 309EXPORT_SYMBOL_GPL(smpboot_register_percpu_thread);
319 310
320/** 311/**
321 * smpboot_unregister_percpu_thread - Unregister a per_cpu thread related to hotplug 312 * smpboot_unregister_percpu_thread - Unregister a per_cpu thread related to hotplug
@@ -331,44 +322,9 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
331 smpboot_destroy_threads(plug_thread); 322 smpboot_destroy_threads(plug_thread);
332 mutex_unlock(&smpboot_threads_lock); 323 mutex_unlock(&smpboot_threads_lock);
333 put_online_cpus(); 324 put_online_cpus();
334 free_cpumask_var(plug_thread->cpumask);
335} 325}
336EXPORT_SYMBOL_GPL(smpboot_unregister_percpu_thread); 326EXPORT_SYMBOL_GPL(smpboot_unregister_percpu_thread);
337 327
338/**
339 * smpboot_update_cpumask_percpu_thread - Adjust which per_cpu hotplug threads stay parked
340 * @plug_thread: Hotplug thread descriptor
341 * @new: Revised mask to use
342 *
343 * The cpumask field in the smp_hotplug_thread must not be updated directly
344 * by the client, but only by calling this function.
345 * This function can only be called on a registered smp_hotplug_thread.
346 */
347void smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread,
348 const struct cpumask *new)
349{
350 struct cpumask *old = plug_thread->cpumask;
351 static struct cpumask tmp;
352 unsigned int cpu;
353
354 lockdep_assert_cpus_held();
355 mutex_lock(&smpboot_threads_lock);
356
357 /* Park threads that were exclusively enabled on the old mask. */
358 cpumask_andnot(&tmp, old, new);
359 for_each_cpu_and(cpu, &tmp, cpu_online_mask)
360 smpboot_park_thread(plug_thread, cpu);
361
362 /* Unpark threads that are exclusively enabled on the new mask. */
363 cpumask_andnot(&tmp, new, old);
364 for_each_cpu_and(cpu, &tmp, cpu_online_mask)
365 smpboot_unpark_thread(plug_thread, cpu);
366
367 cpumask_copy(old, new);
368
369 mutex_unlock(&smpboot_threads_lock);
370}
371
372static DEFINE_PER_CPU(atomic_t, cpu_hotplug_state) = ATOMIC_INIT(CPU_POST_DEAD); 328static DEFINE_PER_CPU(atomic_t, cpu_hotplug_state) = ATOMIC_INIT(CPU_POST_DEAD);
373 329
374/* 330/*