Re: [PATCH tip/core/rcu 1/2] rcu: Provide RCU CPU stall warnings for tiny RCU

2013-01-28 Thread Paul E. McKenney
On Sun, Jan 27, 2013 at 09:57:08PM +1100, Josh Triplett wrote:
> On Sat, Jan 26, 2013 at 04:23:46PM -0800, Paul E. McKenney wrote:
> > From: "Paul E. McKenney" 
> > 
> > Tiny RCU has historically omitted RCU CPU stall warnings in order to
> > reduce memory requirements, however, lack of these warnings caused
> > Thomas Gleixner some debugging pain recently.  Therefore, this commit
> > adds RCU CPU stall warnings to tiny RCU if RCU_TRACE=y.  This keeps
> > the memory footprint small, while still enabling CPU stall warnings
> > in kernels built to enable them.
> > 
> > Updated to include Josh Triplett's suggested use of RCU_STALL_COMMON
> > config variable to simplify #if expressions.
> > 
> > Reported-by: Thomas Gleixner 
> > Signed-off-by: Paul E. McKenney 
> > Signed-off-by: Paul E. McKenney 
> 
> One suggestion below; with that change,
> Reviewed-by: Josh Triplett 
> 
> > --- a/init/Kconfig
> > +++ b/init/Kconfig
> > @@ -486,6 +486,14 @@ config PREEMPT_RCU
> >   This option enables preemptible-RCU code that is common between
> >   the TREE_PREEMPT_RCU and TINY_PREEMPT_RCU implementations.
> >  
> > +config RCU_STALL_COMMON
> > +   def_bool ( TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE )
> > +   help
> > + This option enables RCU CPU stall code that is common between
> > + the TINY and TREE variants of RCU.  The purpose is to allow
> > + the tiny variants to disable RCU CPU stall warnings, while
> > + making these warnings mandatory for the tree variants.
> > +
> [...]
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -970,7 +970,7 @@ config RCU_TORTURE_TEST_RUNNABLE
> >  
> >  config RCU_CPU_STALL_TIMEOUT
> > int "RCU CPU stall timeout in seconds"
> > -   depends on TREE_RCU || TREE_PREEMPT_RCU
> > +   depends on TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE
> 
> depends on RCU_STALL_COMMON

Good catch, fixed!

Thanx, Paul

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


Re: [PATCH tip/core/rcu 1/2] rcu: Provide RCU CPU stall warnings for tiny RCU

2013-01-28 Thread Paul E. McKenney
On Sun, Jan 27, 2013 at 09:57:08PM +1100, Josh Triplett wrote:
 On Sat, Jan 26, 2013 at 04:23:46PM -0800, Paul E. McKenney wrote:
  From: Paul E. McKenney paul.mcken...@linaro.org
  
  Tiny RCU has historically omitted RCU CPU stall warnings in order to
  reduce memory requirements, however, lack of these warnings caused
  Thomas Gleixner some debugging pain recently.  Therefore, this commit
  adds RCU CPU stall warnings to tiny RCU if RCU_TRACE=y.  This keeps
  the memory footprint small, while still enabling CPU stall warnings
  in kernels built to enable them.
  
  Updated to include Josh Triplett's suggested use of RCU_STALL_COMMON
  config variable to simplify #if expressions.
  
  Reported-by: Thomas Gleixner t...@linutronix.de
  Signed-off-by: Paul E. McKenney paul.mcken...@linaro.org
  Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com
 
 One suggestion below; with that change,
 Reviewed-by: Josh Triplett j...@joshtriplett.org
 
  --- a/init/Kconfig
  +++ b/init/Kconfig
  @@ -486,6 +486,14 @@ config PREEMPT_RCU
This option enables preemptible-RCU code that is common between
the TREE_PREEMPT_RCU and TINY_PREEMPT_RCU implementations.
   
  +config RCU_STALL_COMMON
  +   def_bool ( TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE )
  +   help
  + This option enables RCU CPU stall code that is common between
  + the TINY and TREE variants of RCU.  The purpose is to allow
  + the tiny variants to disable RCU CPU stall warnings, while
  + making these warnings mandatory for the tree variants.
  +
 [...]
  --- a/lib/Kconfig.debug
  +++ b/lib/Kconfig.debug
  @@ -970,7 +970,7 @@ config RCU_TORTURE_TEST_RUNNABLE
   
   config RCU_CPU_STALL_TIMEOUT
  int RCU CPU stall timeout in seconds
  -   depends on TREE_RCU || TREE_PREEMPT_RCU
  +   depends on TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE
 
 depends on RCU_STALL_COMMON

Good catch, fixed!

Thanx, Paul

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


Re: [PATCH tip/core/rcu 1/2] rcu: Provide RCU CPU stall warnings for tiny RCU

2013-01-27 Thread Josh Triplett
On Sat, Jan 26, 2013 at 04:23:46PM -0800, Paul E. McKenney wrote:
> From: "Paul E. McKenney" 
> 
> Tiny RCU has historically omitted RCU CPU stall warnings in order to
> reduce memory requirements, however, lack of these warnings caused
> Thomas Gleixner some debugging pain recently.  Therefore, this commit
> adds RCU CPU stall warnings to tiny RCU if RCU_TRACE=y.  This keeps
> the memory footprint small, while still enabling CPU stall warnings
> in kernels built to enable them.
> 
> Updated to include Josh Triplett's suggested use of RCU_STALL_COMMON
> config variable to simplify #if expressions.
> 
> Reported-by: Thomas Gleixner 
> Signed-off-by: Paul E. McKenney 
> Signed-off-by: Paul E. McKenney 

One suggestion below; with that change,
Reviewed-by: Josh Triplett 

> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -486,6 +486,14 @@ config PREEMPT_RCU
> This option enables preemptible-RCU code that is common between
> the TREE_PREEMPT_RCU and TINY_PREEMPT_RCU implementations.
>  
> +config RCU_STALL_COMMON
> + def_bool ( TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE )
> + help
> +   This option enables RCU CPU stall code that is common between
> +   the TINY and TREE variants of RCU.  The purpose is to allow
> +   the tiny variants to disable RCU CPU stall warnings, while
> +   making these warnings mandatory for the tree variants.
> +
[...]
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -970,7 +970,7 @@ config RCU_TORTURE_TEST_RUNNABLE
>  
>  config RCU_CPU_STALL_TIMEOUT
>   int "RCU CPU stall timeout in seconds"
> - depends on TREE_RCU || TREE_PREEMPT_RCU
> + depends on TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE

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


Re: [PATCH tip/core/rcu 1/2] rcu: Provide RCU CPU stall warnings for tiny RCU

2013-01-27 Thread Josh Triplett
On Sat, Jan 26, 2013 at 04:23:46PM -0800, Paul E. McKenney wrote:
 From: Paul E. McKenney paul.mcken...@linaro.org
 
 Tiny RCU has historically omitted RCU CPU stall warnings in order to
 reduce memory requirements, however, lack of these warnings caused
 Thomas Gleixner some debugging pain recently.  Therefore, this commit
 adds RCU CPU stall warnings to tiny RCU if RCU_TRACE=y.  This keeps
 the memory footprint small, while still enabling CPU stall warnings
 in kernels built to enable them.
 
 Updated to include Josh Triplett's suggested use of RCU_STALL_COMMON
 config variable to simplify #if expressions.
 
 Reported-by: Thomas Gleixner t...@linutronix.de
 Signed-off-by: Paul E. McKenney paul.mcken...@linaro.org
 Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com

One suggestion below; with that change,
Reviewed-by: Josh Triplett j...@joshtriplett.org

 --- a/init/Kconfig
 +++ b/init/Kconfig
 @@ -486,6 +486,14 @@ config PREEMPT_RCU
 This option enables preemptible-RCU code that is common between
 the TREE_PREEMPT_RCU and TINY_PREEMPT_RCU implementations.
  
 +config RCU_STALL_COMMON
 + def_bool ( TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE )
 + help
 +   This option enables RCU CPU stall code that is common between
 +   the TINY and TREE variants of RCU.  The purpose is to allow
 +   the tiny variants to disable RCU CPU stall warnings, while
 +   making these warnings mandatory for the tree variants.
 +
[...]
 --- a/lib/Kconfig.debug
 +++ b/lib/Kconfig.debug
 @@ -970,7 +970,7 @@ config RCU_TORTURE_TEST_RUNNABLE
  
  config RCU_CPU_STALL_TIMEOUT
   int RCU CPU stall timeout in seconds
 - depends on TREE_RCU || TREE_PREEMPT_RCU
 + depends on TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE

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


[PATCH tip/core/rcu 1/2] rcu: Provide RCU CPU stall warnings for tiny RCU

2013-01-26 Thread Paul E. McKenney
From: "Paul E. McKenney" 

Tiny RCU has historically omitted RCU CPU stall warnings in order to
reduce memory requirements, however, lack of these warnings caused
Thomas Gleixner some debugging pain recently.  Therefore, this commit
adds RCU CPU stall warnings to tiny RCU if RCU_TRACE=y.  This keeps
the memory footprint small, while still enabling CPU stall warnings
in kernels built to enable them.

Updated to include Josh Triplett's suggested use of RCU_STALL_COMMON
config variable to simplify #if expressions.

Reported-by: Thomas Gleixner 
Signed-off-by: Paul E. McKenney 
Signed-off-by: Paul E. McKenney 
---
 init/Kconfig|8 ++
 kernel/rcu.h|7 ++
 kernel/rcupdate.c   |   51 ++
 kernel/rcutiny.c|6 +++-
 kernel/rcutiny_plugin.h |   56 +++
 kernel/rcutree.c|   46 ++
 kernel/rcutree.h|5 
 lib/Kconfig.debug   |2 +-
 8 files changed, 130 insertions(+), 51 deletions(-)

diff --git a/init/Kconfig b/init/Kconfig
index 7d30240..a5e90e1 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -486,6 +486,14 @@ config PREEMPT_RCU
  This option enables preemptible-RCU code that is common between
  the TREE_PREEMPT_RCU and TINY_PREEMPT_RCU implementations.
 
+config RCU_STALL_COMMON
+   def_bool ( TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE )
+   help
+ This option enables RCU CPU stall code that is common between
+ the TINY and TREE variants of RCU.  The purpose is to allow
+ the tiny variants to disable RCU CPU stall warnings, while
+ making these warnings mandatory for the tree variants.
+
 config CONTEXT_TRACKING
bool
 
diff --git a/kernel/rcu.h b/kernel/rcu.h
index 20dfba5..7f8e759 100644
--- a/kernel/rcu.h
+++ b/kernel/rcu.h
@@ -111,4 +111,11 @@ static inline bool __rcu_reclaim(char *rn, struct rcu_head 
*head)
 
 extern int rcu_expedited;
 
+#ifdef CONFIG_RCU_STALL_COMMON
+
+extern int rcu_cpu_stall_suppress;
+int rcu_jiffies_till_stall_check(void);
+
+#endif /* #ifdef CONFIG_RCU_STALL_COMMON */
+
 #endif /* __LINUX_RCU_H */
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index a2cf761..076730d 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -412,3 +412,54 @@ EXPORT_SYMBOL_GPL(do_trace_rcu_torture_read);
 #else
 #define do_trace_rcu_torture_read(rcutorturename, rhp) do { } while (0)
 #endif
+
+#ifdef CONFIG_RCU_STALL_COMMON
+
+#ifdef CONFIG_PROVE_RCU
+#define RCU_STALL_DELAY_DELTA (5 * HZ)
+#else
+#define RCU_STALL_DELAY_DELTA 0
+#endif
+
+int rcu_cpu_stall_suppress __read_mostly; /* 1 = suppress stall warnings. */
+int rcu_cpu_stall_timeout __read_mostly = CONFIG_RCU_CPU_STALL_TIMEOUT;
+
+module_param(rcu_cpu_stall_suppress, int, 0644);
+module_param(rcu_cpu_stall_timeout, int, 0644);
+
+int rcu_jiffies_till_stall_check(void)
+{
+   int till_stall_check = ACCESS_ONCE(rcu_cpu_stall_timeout);
+
+   /*
+* Limit check must be consistent with the Kconfig limits
+* for CONFIG_RCU_CPU_STALL_TIMEOUT.
+*/
+   if (till_stall_check < 3) {
+   ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
+   till_stall_check = 3;
+   } else if (till_stall_check > 300) {
+   ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
+   till_stall_check = 300;
+   }
+   return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
+}
+
+static int rcu_panic(struct notifier_block *this, unsigned long ev, void *ptr)
+{
+   rcu_cpu_stall_suppress = 1;
+   return NOTIFY_DONE;
+}
+
+static struct notifier_block rcu_panic_block = {
+   .notifier_call = rcu_panic,
+};
+
+static int __init check_cpu_stall_init(void)
+{
+   atomic_notifier_chain_register(_notifier_list, _panic_block);
+   return 0;
+}
+early_initcall(check_cpu_stall_init);
+
+#endif /* #ifdef CONFIG_RCU_STALL_COMMON */
diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
index e7dce58..b899df3 100644
--- a/kernel/rcutiny.c
+++ b/kernel/rcutiny.c
@@ -51,10 +51,10 @@ static void __call_rcu(struct rcu_head *head,
   void (*func)(struct rcu_head *rcu),
   struct rcu_ctrlblk *rcp);
 
-#include "rcutiny_plugin.h"
-
 static long long rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
 
+#include "rcutiny_plugin.h"
+
 /* Common code for rcu_idle_enter() and rcu_irq_exit(), see kernel/rcutree.c. 
*/
 static void rcu_idle_enter_common(long long newval)
 {
@@ -205,6 +205,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
  */
 static int rcu_qsctr_help(struct rcu_ctrlblk *rcp)
 {
+   reset_cpu_stall_ticks(rcp);
if (rcp->rcucblist != NULL &&
rcp->donetail != rcp->curtail) {
rcp->donetail = rcp->curtail;
@@ -251,6 +252,7 @@ void rcu_bh_qs(int cpu)
  */
 void rcu_check_callbacks(int cpu, int user)
 {
+   check_cpu_stalls();
if (user || 

[PATCH tip/core/rcu 1/2] rcu: Provide RCU CPU stall warnings for tiny RCU

2013-01-26 Thread Paul E. McKenney
From: Paul E. McKenney paul.mcken...@linaro.org

Tiny RCU has historically omitted RCU CPU stall warnings in order to
reduce memory requirements, however, lack of these warnings caused
Thomas Gleixner some debugging pain recently.  Therefore, this commit
adds RCU CPU stall warnings to tiny RCU if RCU_TRACE=y.  This keeps
the memory footprint small, while still enabling CPU stall warnings
in kernels built to enable them.

Updated to include Josh Triplett's suggested use of RCU_STALL_COMMON
config variable to simplify #if expressions.

Reported-by: Thomas Gleixner t...@linutronix.de
Signed-off-by: Paul E. McKenney paul.mcken...@linaro.org
Signed-off-by: Paul E. McKenney paul...@linux.vnet.ibm.com
---
 init/Kconfig|8 ++
 kernel/rcu.h|7 ++
 kernel/rcupdate.c   |   51 ++
 kernel/rcutiny.c|6 +++-
 kernel/rcutiny_plugin.h |   56 +++
 kernel/rcutree.c|   46 ++
 kernel/rcutree.h|5 
 lib/Kconfig.debug   |2 +-
 8 files changed, 130 insertions(+), 51 deletions(-)

diff --git a/init/Kconfig b/init/Kconfig
index 7d30240..a5e90e1 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -486,6 +486,14 @@ config PREEMPT_RCU
  This option enables preemptible-RCU code that is common between
  the TREE_PREEMPT_RCU and TINY_PREEMPT_RCU implementations.
 
+config RCU_STALL_COMMON
+   def_bool ( TREE_RCU || TREE_PREEMPT_RCU || RCU_TRACE )
+   help
+ This option enables RCU CPU stall code that is common between
+ the TINY and TREE variants of RCU.  The purpose is to allow
+ the tiny variants to disable RCU CPU stall warnings, while
+ making these warnings mandatory for the tree variants.
+
 config CONTEXT_TRACKING
bool
 
diff --git a/kernel/rcu.h b/kernel/rcu.h
index 20dfba5..7f8e759 100644
--- a/kernel/rcu.h
+++ b/kernel/rcu.h
@@ -111,4 +111,11 @@ static inline bool __rcu_reclaim(char *rn, struct rcu_head 
*head)
 
 extern int rcu_expedited;
 
+#ifdef CONFIG_RCU_STALL_COMMON
+
+extern int rcu_cpu_stall_suppress;
+int rcu_jiffies_till_stall_check(void);
+
+#endif /* #ifdef CONFIG_RCU_STALL_COMMON */
+
 #endif /* __LINUX_RCU_H */
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index a2cf761..076730d 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -412,3 +412,54 @@ EXPORT_SYMBOL_GPL(do_trace_rcu_torture_read);
 #else
 #define do_trace_rcu_torture_read(rcutorturename, rhp) do { } while (0)
 #endif
+
+#ifdef CONFIG_RCU_STALL_COMMON
+
+#ifdef CONFIG_PROVE_RCU
+#define RCU_STALL_DELAY_DELTA (5 * HZ)
+#else
+#define RCU_STALL_DELAY_DELTA 0
+#endif
+
+int rcu_cpu_stall_suppress __read_mostly; /* 1 = suppress stall warnings. */
+int rcu_cpu_stall_timeout __read_mostly = CONFIG_RCU_CPU_STALL_TIMEOUT;
+
+module_param(rcu_cpu_stall_suppress, int, 0644);
+module_param(rcu_cpu_stall_timeout, int, 0644);
+
+int rcu_jiffies_till_stall_check(void)
+{
+   int till_stall_check = ACCESS_ONCE(rcu_cpu_stall_timeout);
+
+   /*
+* Limit check must be consistent with the Kconfig limits
+* for CONFIG_RCU_CPU_STALL_TIMEOUT.
+*/
+   if (till_stall_check  3) {
+   ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
+   till_stall_check = 3;
+   } else if (till_stall_check  300) {
+   ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
+   till_stall_check = 300;
+   }
+   return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
+}
+
+static int rcu_panic(struct notifier_block *this, unsigned long ev, void *ptr)
+{
+   rcu_cpu_stall_suppress = 1;
+   return NOTIFY_DONE;
+}
+
+static struct notifier_block rcu_panic_block = {
+   .notifier_call = rcu_panic,
+};
+
+static int __init check_cpu_stall_init(void)
+{
+   atomic_notifier_chain_register(panic_notifier_list, rcu_panic_block);
+   return 0;
+}
+early_initcall(check_cpu_stall_init);
+
+#endif /* #ifdef CONFIG_RCU_STALL_COMMON */
diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
index e7dce58..b899df3 100644
--- a/kernel/rcutiny.c
+++ b/kernel/rcutiny.c
@@ -51,10 +51,10 @@ static void __call_rcu(struct rcu_head *head,
   void (*func)(struct rcu_head *rcu),
   struct rcu_ctrlblk *rcp);
 
-#include rcutiny_plugin.h
-
 static long long rcu_dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
 
+#include rcutiny_plugin.h
+
 /* Common code for rcu_idle_enter() and rcu_irq_exit(), see kernel/rcutree.c. 
*/
 static void rcu_idle_enter_common(long long newval)
 {
@@ -205,6 +205,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
  */
 static int rcu_qsctr_help(struct rcu_ctrlblk *rcp)
 {
+   reset_cpu_stall_ticks(rcp);
if (rcp-rcucblist != NULL 
rcp-donetail != rcp-curtail) {
rcp-donetail = rcp-curtail;
@@ -251,6 +252,7 @@ void rcu_bh_qs(int cpu)
  */
 void