All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Teach RCU that idle task is not quiscent state at boot
@ 2009-02-23 16:16 Paul E. McKenney
  2009-02-23 17:13 ` Ingo Molnar
  2009-02-23 20:43 ` [PATCH] v2 " Paul E. McKenney
  0 siblings, 2 replies; 21+ messages in thread
From: Paul E. McKenney @ 2009-02-23 16:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: vegard.nossum, mingo, stable, akpm, npiggin, penberg

This patch fixes a bug located by Vegard Nossum with the aid of
kmemcheck.

The boot CPU runs in the context of its idle thread during boot-up.
During this time, idle_cpu(0) will always return nonzero, which will
fool Classic and Hierarchical RCU into deciding that a large chunk of
the boot-up sequence is a big long quiescent state.  This in turn causes
RCU to prematurely end grace periods during this time.

This patch changes the rcutree.c and rcuclassic.c rcu_check_callbacks()
function to ignore the idle tasks as a quiescent state until the
system_state is no longer SYSTEM_BOOTING.  After this point, the idle
task really does represent a quiescent state.

In addition, this patch takes Nick Piggin's suggestion to make the
system_state global variable be __read_mostly.

Located-by: Vegard Nossum <vegard.nossum@gmail.com>
Tested-by: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---

 init/main.c         |    2 +-
 kernel/rcuclassic.c |    4 ++--
 kernel/rcutree.c    |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/init/main.c b/init/main.c
index 8442094..5067cfc 100644
--- a/init/main.c
+++ b/init/main.c
@@ -97,7 +97,7 @@ static inline void mark_rodata_ro(void) { }
 extern void tc_init(void);
 #endif
 
-enum system_states system_state;
+enum system_states system_state __read_mostly;
 EXPORT_SYMBOL(system_state);
 
 /*
diff --git a/kernel/rcuclassic.c b/kernel/rcuclassic.c
index bd5a900..909d04e 100644
--- a/kernel/rcuclassic.c
+++ b/kernel/rcuclassic.c
@@ -679,8 +679,8 @@ int rcu_needs_cpu(int cpu)
 void rcu_check_callbacks(int cpu, int user)
 {
 	if (user ||
-	    (idle_cpu(cpu) && !in_softirq() &&
-				hardirq_count() <= (1 << HARDIRQ_SHIFT))) {
+	    (idle_cpu(cpu) && (system_state != SYSTEM_BOOTING) &&
+	     !in_softirq() && hardirq_count() <= (1 << HARDIRQ_SHIFT))) {
 
 		/*
 		 * Get here if this CPU took its interrupt from user
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index b2fd602..da685ea 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -948,8 +948,8 @@ static void rcu_do_batch(struct rcu_data *rdp)
 void rcu_check_callbacks(int cpu, int user)
 {
 	if (user ||
-	    (idle_cpu(cpu) && !in_softirq() &&
-				hardirq_count() <= (1 << HARDIRQ_SHIFT))) {
+	    (idle_cpu(cpu) && (system_state != SYSTEM_BOOTING) &&
+	     !in_softirq() && hardirq_count() <= (1 << HARDIRQ_SHIFT))) {
 
 		/*
 		 * Get here if this CPU took its interrupt from user

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2009-02-26  3:09 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-23 16:16 [PATCH] Teach RCU that idle task is not quiscent state at boot Paul E. McKenney
2009-02-23 17:13 ` Ingo Molnar
2009-02-23 20:43 ` [PATCH] v2 " Paul E. McKenney
2009-02-24  4:02   ` Nick Piggin
2009-02-24  5:08     ` Paul E. McKenney
2009-02-24 14:50       ` Paul E. McKenney
2009-02-25  0:29   ` [PATCH] v3 " Paul E. McKenney
2009-02-25  4:12     ` Nick Piggin
2009-02-25  4:43       ` Paul E. McKenney
2009-02-25 14:19     ` [PATCH] v4 " Paul E. McKenney
2009-02-25 16:00       ` Ingo Molnar
2009-02-25 16:26         ` Nick Piggin
2009-02-25 17:12           ` Paul E. McKenney
2009-02-25 17:18             ` Nick Piggin
2009-02-25 17:36               ` Paul E. McKenney
2009-02-25 17:08         ` Paul E. McKenney
2009-02-26  3:09           ` Ingo Molnar
2009-02-25 18:38       ` Vegard Nossum
2009-02-25 19:01         ` Paul E. McKenney
2009-02-26  2:03       ` [PATCH] v5 " Paul E. McKenney
2009-02-26  3:08         ` Ingo Molnar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.