rcu: Simplify rcu_pending()/rcu_check_callbacks() API
[deliverable/linux.git] / kernel / rcupreempt.c
index beb0e659adcc60be60bcc1efd2c6e9ca45367afe..0053ce56e326c61bcaf4bccfadf9785a3507f837 100644 (file)
@@ -159,7 +159,9 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_dyntick_sched, rcu_dyntick_sched
        .dynticks = 1,
 };
 
-void rcu_qsctr_inc(int cpu)
+static int rcu_pending(int cpu);
+
+void rcu_sched_qs(int cpu)
 {
        struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
 
@@ -548,7 +550,7 @@ void rcu_irq_enter(void)
  * rcu_irq_exit - Called from exiting Hard irq context.
  *
  * If the CPU was idle with dynamic ticks active, update the
- * rcu_dyntick_sched.dynticks to put let the RCU handling be
+ * rcu_dyntick_sched.dynticks to let the RCU handling be
  * aware that the CPU is going back to idle with no ticks.
  */
 void rcu_irq_exit(void)
@@ -849,7 +851,7 @@ rcu_try_flip_waitzero(void)
        /* Check to see if the sum of the "last" counters is zero. */
 
        RCU_TRACE_ME(rcupreempt_trace_try_flip_z1);
-       for_each_cpu(cpu, to_cpumask(rcu_cpu_online_map))
+       for_each_possible_cpu(cpu)
                sum += RCU_DATA_CPU(cpu)->rcu_flipctr[lastidx];
        if (sum != 0) {
                RCU_TRACE_ME(rcupreempt_trace_try_flip_ze1);
@@ -961,26 +963,30 @@ static void rcu_check_mb(int cpu)
 void rcu_check_callbacks(int cpu, int user)
 {
        unsigned long flags;
-       struct rcu_data *rdp = RCU_DATA_CPU(cpu);
+       struct rcu_data *rdp;
+
+       if (!rcu_pending(cpu))
+               return; /* if nothing for RCU to do. */
 
        /*
         * If this CPU took its interrupt from user mode or from the
         * idle loop, and this is not a nested interrupt, then
         * this CPU has to have exited all prior preept-disable
-        * sections of code.  So increment the counter to note this.
+        * sections of code.  So invoke rcu_sched_qs() to note this.
         *
         * The memory barrier is needed to handle the case where
         * writes from a preempt-disable section of code get reordered
         * into schedule() by this CPU's write buffer.  So the memory
-        * barrier makes sure that the rcu_qsctr_inc() is seen by other
+        * barrier makes sure that the rcu_sched_qs() is seen by other
         * CPUs to happen after any such write.
         */
 
+       rdp = RCU_DATA_CPU(cpu);
        if (user ||
            (idle_cpu(cpu) && !in_softirq() &&
             hardirq_count() <= (1 << HARDIRQ_SHIFT))) {
                smp_mb();       /* Guard against aggressive schedule(). */
-               rcu_qsctr_inc(cpu);
+               rcu_sched_qs(cpu);
        }
 
        rcu_check_mb(cpu);
@@ -1067,12 +1073,6 @@ void rcu_offline_cpu(int cpu)
                           /*  seen -after- acknowledgement. */
        }
 
-       RCU_DATA_ME()->rcu_flipctr[0] += RCU_DATA_CPU(cpu)->rcu_flipctr[0];
-       RCU_DATA_ME()->rcu_flipctr[1] += RCU_DATA_CPU(cpu)->rcu_flipctr[1];
-
-       RCU_DATA_CPU(cpu)->rcu_flipctr[0] = 0;
-       RCU_DATA_CPU(cpu)->rcu_flipctr[1] = 0;
-
        cpumask_clear_cpu(cpu, to_cpumask(rcu_cpu_online_map));
 
        spin_unlock_irqrestore(&rcu_ctrlblk.fliplock, flags);
@@ -1388,7 +1388,7 @@ int rcu_needs_cpu(int cpu)
                rdp->waitschedlist != NULL);
 }
 
-int rcu_pending(int cpu)
+static int rcu_pending(int cpu)
 {
        struct rcu_data *rdp = RCU_DATA_CPU(cpu);
 
@@ -1417,8 +1417,8 @@ int rcu_pending(int cpu)
        return 0;
 }
 
-static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
-                               unsigned long action, void *hcpu)
+int __cpuinit rcu_cpu_notify(struct notifier_block *self,
+                            unsigned long action, void *hcpu)
 {
        long cpu = (long)hcpu;
 
@@ -1439,10 +1439,6 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata rcu_nb = {
-       .notifier_call = rcu_cpu_notify,
-};
-
 void __init __rcu_init(void)
 {
        int cpu;
@@ -1471,23 +1467,6 @@ void __init __rcu_init(void)
                rdp->waitschedtail = &rdp->waitschedlist;
                rdp->rcu_sched_sleeping = 0;
        }
-       register_cpu_notifier(&rcu_nb);
-
-       /*
-        * We don't need protection against CPU-Hotplug here
-        * since
-        * a) If a CPU comes online while we are iterating over the
-        *    cpu_online_mask below, we would only end up making a
-        *    duplicate call to rcu_online_cpu() which sets the corresponding
-        *    CPU's mask in the rcu_cpu_online_map.
-        *
-        * b) A CPU cannot go offline at this point in time since the user
-        *    does not have access to the sysfs interface, nor do we
-        *    suspend the system.
-        */
-       for_each_online_cpu(cpu)
-               rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE, (void *)(long) cpu);
-
        open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
 }
 
This page took 0.024953 seconds and 5 git commands to generate.