aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paul.mckenney@linaro.org>2011-04-14 15:13:53 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2011-05-06 02:16:55 -0400
commit0f962a5e7277c34987b77dc82fc9aefcedc95e27 (patch)
treeb265d93dcc8f2669f8fb9b353344b9f6cc354728
parent27f4d28057adf98750cf863c40baefb12f5b6d21 (diff)
rcu: Force per-rcu_node kthreads off of the outgoing CPU
The scheduler has had some heartburn in the past when too many real-time kthreads were affinitied to the outgoing CPU. So, this commit lightens the load by forcing the per-rcu_node and the boost kthreads off of the outgoing CPU. Note that RCU's per-CPU kthread remains on the outgoing CPU until the bitter end, as it must in order to preserve correctness. Also avoid disabling hardirqs across calls to set_cpus_allowed_ptr(), given that this function can block. Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
-rw-r--r--kernel/rcutree.c24
-rw-r--r--kernel/rcutree_plugin.h8
2 files changed, 24 insertions, 8 deletions
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 28fd92a9e0d0..51eef4193e7c 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -95,7 +95,7 @@ static DEFINE_PER_CPU(wait_queue_head_t, rcu_cpu_wq);
95static DEFINE_PER_CPU(char, rcu_cpu_has_work); 95static DEFINE_PER_CPU(char, rcu_cpu_has_work);
96static char rcu_kthreads_spawnable; 96static char rcu_kthreads_spawnable;
97 97
98static void rcu_node_kthread_setaffinity(struct rcu_node *rnp); 98static void rcu_node_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu);
99static void invoke_rcu_cpu_kthread(void); 99static void invoke_rcu_cpu_kthread(void);
100 100
101#define RCU_KTHREAD_PRIO 1 /* RT priority for per-CPU kthreads. */ 101#define RCU_KTHREAD_PRIO 1 /* RT priority for per-CPU kthreads. */
@@ -1099,7 +1099,7 @@ static void __rcu_offline_cpu(int cpu, struct rcu_state *rsp)
1099 kthread_stop(t); 1099 kthread_stop(t);
1100 rcu_stop_boost_kthread(rnp); 1100 rcu_stop_boost_kthread(rnp);
1101 } else 1101 } else
1102 rcu_node_kthread_setaffinity(rnp); 1102 rcu_node_kthread_setaffinity(rnp, -1);
1103} 1103}
1104 1104
1105/* 1105/*
@@ -1644,8 +1644,12 @@ static int rcu_node_kthread(void *arg)
1644 * Set the per-rcu_node kthread's affinity to cover all CPUs that are 1644 * Set the per-rcu_node kthread's affinity to cover all CPUs that are
1645 * served by the rcu_node in question. The CPU hotplug lock is still 1645 * served by the rcu_node in question. The CPU hotplug lock is still
1646 * held, so the value of rnp->qsmaskinit will be stable. 1646 * held, so the value of rnp->qsmaskinit will be stable.
1647 *
1648 * We don't include outgoingcpu in the affinity set, use -1 if there is
1649 * no outgoing CPU. If there are no CPUs left in the affinity set,
1650 * this function allows the kthread to execute on any CPU.
1647 */ 1651 */
1648static void rcu_node_kthread_setaffinity(struct rcu_node *rnp) 1652static void rcu_node_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
1649{ 1653{
1650 cpumask_var_t cm; 1654 cpumask_var_t cm;
1651 int cpu; 1655 int cpu;
@@ -1657,8 +1661,14 @@ static void rcu_node_kthread_setaffinity(struct rcu_node *rnp)
1657 return; 1661 return;
1658 cpumask_clear(cm); 1662 cpumask_clear(cm);
1659 for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++, mask >>= 1) 1663 for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++, mask >>= 1)
1660 if (mask & 0x1) 1664 if ((mask & 0x1) && cpu != outgoingcpu)
1661 cpumask_set_cpu(cpu, cm); 1665 cpumask_set_cpu(cpu, cm);
1666 if (cpumask_weight(cm) == 0) {
1667 cpumask_setall(cm);
1668 for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++)
1669 cpumask_clear_cpu(cpu, cm);
1670 WARN_ON_ONCE(cpumask_weight(cm) == 0);
1671 }
1662 set_cpus_allowed_ptr(rnp->node_kthread_task, cm); 1672 set_cpus_allowed_ptr(rnp->node_kthread_task, cm);
1663 rcu_boost_kthread_setaffinity(rnp, cm); 1673 rcu_boost_kthread_setaffinity(rnp, cm);
1664 free_cpumask_var(cm); 1674 free_cpumask_var(cm);
@@ -2154,7 +2164,11 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
2154 rcu_online_kthreads(cpu); 2164 rcu_online_kthreads(cpu);
2155 break; 2165 break;
2156 case CPU_ONLINE: 2166 case CPU_ONLINE:
2157 rcu_node_kthread_setaffinity(rnp); 2167 case CPU_DOWN_FAILED:
2168 rcu_node_kthread_setaffinity(rnp, -1);
2169 break;
2170 case CPU_DOWN_PREPARE:
2171 rcu_node_kthread_setaffinity(rnp, cpu);
2158 break; 2172 break;
2159 case CPU_DYING: 2173 case CPU_DYING:
2160 case CPU_DYING_FROZEN: 2174 case CPU_DYING_FROZEN:
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index 5964f82e2d96..4e486255df63 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -1212,17 +1212,19 @@ static void rcu_initiate_boost(struct rcu_node *rnp)
1212 } 1212 }
1213} 1213}
1214 1214
1215/*
1216 * Set the affinity of the boost kthread. The CPU-hotplug locks are
1217 * held, so no one should be messing with the existence of the boost
1218 * kthread.
1219 */
1215static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, 1220static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp,
1216 cpumask_var_t cm) 1221 cpumask_var_t cm)
1217{ 1222{
1218 unsigned long flags;
1219 struct task_struct *t; 1223 struct task_struct *t;
1220 1224
1221 raw_spin_lock_irqsave(&rnp->lock, flags);
1222 t = rnp->boost_kthread_task; 1225 t = rnp->boost_kthread_task;
1223 if (t != NULL) 1226 if (t != NULL)
1224 set_cpus_allowed_ptr(rnp->boost_kthread_task, cm); 1227 set_cpus_allowed_ptr(rnp->boost_kthread_task, cm);
1225 raw_spin_unlock_irqrestore(&rnp->lock, flags);
1226} 1228}
1227 1229
1228#define RCU_BOOST_DELAY_JIFFIES DIV_ROUND_UP(CONFIG_RCU_BOOST_DELAY * HZ, 1000) 1230#define RCU_BOOST_DELAY_JIFFIES DIV_ROUND_UP(CONFIG_RCU_BOOST_DELAY * HZ, 1000)