[RFC PATCH 06/15] nohz_task: Keep the tick if rcu needs it

From: Frederic Weisbecker
Date: Mon Dec 20 2010 - 10:26:54 EST


When a nohz task is running, don't stop the tick if RCU
needs the CPU to notify a quiescent state or if it has
callbacks to handle.

Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Anton Blanchard <anton@xxxxxxxxxxx>
Cc: Tim Pepper <lnxninja@xxxxxxxxxxxxxxxxxx>
---
include/linux/rcupdate.h | 1 +
kernel/rcutree.c | 3 +--
kernel/sched.c | 6 ++++++
3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 03cda7b..262d48b 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -122,6 +122,7 @@ extern void rcu_init(void);
extern void rcu_sched_qs(int cpu);
extern void rcu_bh_qs(int cpu);
extern void rcu_check_callbacks(int cpu, int user);
+extern int rcu_pending(int cpu);
struct notifier_block;

#ifdef CONFIG_NO_HZ
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index ccdc04c..44dce3f 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -149,7 +149,6 @@ module_param(rcu_cpu_stall_suppress, int, 0644);
#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */

static void force_quiescent_state(struct rcu_state *rsp, int relaxed);
-static int rcu_pending(int cpu);

/*
* Return the number of RCU-sched batches processed thus far for debug & stats.
@@ -1634,7 +1633,7 @@ static int __rcu_pending(struct rcu_state *rsp, struct rcu_data *rdp)
* by the current CPU, returning 1 if so. This function is part of the
* RCU implementation; it is -not- an exported member of the RCU API.
*/
-static int rcu_pending(int cpu)
+int rcu_pending(int cpu)
{
return __rcu_pending(&rcu_sched_state, &per_cpu(rcu_sched_data, cpu)) ||
__rcu_pending(&rcu_bh_state, &per_cpu(rcu_bh_data, cpu)) ||
diff --git a/kernel/sched.c b/kernel/sched.c
index 6dbae46..45bd6e2 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2470,10 +2470,16 @@ static void nohz_task_cpu_update(void *unused)
int nohz_task_can_stop_tick(void)
{
struct rq *rq = this_rq();
+ int cpu;

if (rq->nr_running > 1)
return 0;

+ cpu = smp_processor_id();
+
+ if (rcu_pending(cpu) || rcu_needs_cpu(cpu))
+ return 0;
+
return 1;
}

--
1.7.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/