]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
stop_machine: Kill smp_hotplug_thread->pre_unpark, introduce stop_machine_unpark()
authorOleg Nesterov <oleg@redhat.com>
Fri, 9 Oct 2015 16:00:49 +0000 (18:00 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 20 Oct 2015 08:23:55 +0000 (10:23 +0200)
1. Change smpboot_unpark_thread() to check ->selfparking, just
   like smpboot_park_thread() does.

2. Introduce stop_machine_unpark() which sets ->enabled and calls
   kthread_unpark().

3. Change smpboot_thread_call() and cpu_stop_init() to call
   stop_machine_unpark() by hand.

This way:

    - IMO the ->selfparking logic becomes more consistent.

    - We can kill the smp_hotplug_thread->pre_unpark() method.

    - We can easily unpark the stopper thread earlier. Say, we
      can move stop_machine_unpark() from smpboot_thread_call()
      to sched_cpu_active() as Peter suggests.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: heiko.carstens@de.ibm.com
Link: http://lkml.kernel.org/r/20151009160049.GA10166@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/linux/smpboot.h
include/linux/stop_machine.h
kernel/cpu.c
kernel/smpboot.c
kernel/stop_machine.c

index e6109a6cd8f65eb779163d1a084a6e0256a11db0..12910cf19869c7db32d1ca34ddda0931e80570d1 100644 (file)
@@ -24,9 +24,6 @@ struct smpboot_thread_data;
  *                     parked (cpu offline)
  * @unpark:            Optional unpark function, called when the thread is
  *                     unparked (cpu online)
- * @pre_unpark:                Optional unpark function, called before the thread is
- *                     unparked (cpu online). This is not guaranteed to be
- *                     called on the target cpu of the thread. Careful!
  * @cpumask:           Internal state.  To update which threads are unparked,
  *                     call smpboot_update_cpumask_percpu_thread().
  * @selfparking:       Thread is not parked by the park function.
@@ -42,7 +39,6 @@ struct smp_hotplug_thread {
        void                            (*cleanup)(unsigned int cpu, bool online);
        void                            (*park)(unsigned int cpu);
        void                            (*unpark)(unsigned int cpu);
-       void                            (*pre_unpark)(unsigned int cpu);
        cpumask_var_t                   cpumask;
        bool                            selfparking;
        const char                      *thread_comm;
index 7b76362b381ce9f70affb3facb1cde4328dee283..0adedca24c5bfbd4ca7a25b80641e76e0e638738 100644 (file)
@@ -34,6 +34,7 @@ void stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg,
 int stop_cpus(const struct cpumask *cpumask, cpu_stop_fn_t fn, void *arg);
 int try_stop_cpus(const struct cpumask *cpumask, cpu_stop_fn_t fn, void *arg);
 void stop_machine_park(int cpu);
+void stop_machine_unpark(int cpu);
 
 #else  /* CONFIG_SMP */
 
index c85df2775b735895d0637c416c712f507828dd9d..6467521e1e15a0637685387a100823487b953c50 100644 (file)
@@ -475,6 +475,7 @@ static int smpboot_thread_call(struct notifier_block *nfb,
 
        case CPU_DOWN_FAILED:
        case CPU_ONLINE:
+               stop_machine_unpark(cpu);
                smpboot_unpark_threads(cpu);
                break;
 
index a818cbc73e147382488cb0ea5bb5c490c6a46e15..d264f59bff56cb128edc68c5746280a2499752d5 100644 (file)
@@ -222,9 +222,8 @@ static void smpboot_unpark_thread(struct smp_hotplug_thread *ht, unsigned int cp
 {
        struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu);
 
-       if (ht->pre_unpark)
-               ht->pre_unpark(cpu);
-       kthread_unpark(tsk);
+       if (!ht->selfparking)
+               kthread_unpark(tsk);
 }
 
 void smpboot_unpark_threads(unsigned int cpu)
index 91fbb109de6c47245f9780a8545c4e97c8ac17f2..59096a55089f008ef30204a9712598b8cdf87d03 100644 (file)
@@ -513,6 +513,14 @@ static void cpu_stop_unpark(unsigned int cpu)
        spin_unlock_irq(&stopper->lock);
 }
 
+void stop_machine_unpark(int cpu)
+{
+       struct cpu_stopper *stopper = &per_cpu(cpu_stopper, cpu);
+
+       cpu_stop_unpark(cpu);
+       kthread_unpark(stopper->thread);
+}
+
 static struct smp_hotplug_thread cpu_stop_threads = {
        .store                  = &cpu_stopper.thread,
        .thread_should_run      = cpu_stop_should_run,
@@ -521,7 +529,6 @@ static struct smp_hotplug_thread cpu_stop_threads = {
        .create                 = cpu_stop_create,
        .setup                  = cpu_stop_unpark,
        .park                   = cpu_stop_park,
-       .pre_unpark             = cpu_stop_unpark,
        .selfparking            = true,
 };
 
@@ -537,6 +544,7 @@ static int __init cpu_stop_init(void)
        }
 
        BUG_ON(smpboot_register_percpu_thread(&cpu_stop_threads));
+       stop_machine_unpark(raw_smp_processor_id());
        stop_machine_initialized = true;
        return 0;
 }