linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] rcu: cleanup: make rcutorture specific definitions depend on config value
@ 2014-04-20 21:57 Pranith Kumar
  0 siblings, 0 replies; 4+ messages in thread
From: Pranith Kumar @ 2014-04-20 21:57 UTC (permalink / raw)
  To: paulmck; +Cc: linux-kernel

make rcutorture specific variables in tree.c depend on CONFIG_RCU_TORTURE_TEST
This avoid having to have them when no torture tests are running.
Also cleanup some macros which are rcutorture specific.

Tested with rcutorture both in-built and as a module


Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 include/linux/rcupdate.h |   13 +++----------
 kernel/rcu/tree.c        |   29 +++++++++++++++++------------
 kernel/rcu/tree_trace.c  |    7 +++++++
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 00a7fd6..b49e46b 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -49,16 +49,8 @@
 extern int rcu_expedited; /* for sysctl */
 #ifdef CONFIG_RCU_TORTURE_TEST
 extern int rcutorture_runnable; /* for sysctl */
-#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
-
-#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
 void rcutorture_record_test_transition(void);
 void rcutorture_record_progress(unsigned long vernum);
-void do_trace_rcu_torture_read(const char *rcutorturename,
-			       struct rcu_head *rhp,
-			       unsigned long secs,
-			       unsigned long c_old,
-			       unsigned long c);
 #else
 static inline void rcutorture_record_test_transition(void)
 {
@@ -66,7 +58,9 @@ static inline void rcutorture_record_test_transition(void)
 static inline void rcutorture_record_progress(unsigned long vernum)
 {
 }
-#ifdef CONFIG_RCU_TRACE
+#endif /* CONFIG_RCU_TORTURE_TEST */
+
+#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) || defined(CONFIG_RCU_TRACE)
 void do_trace_rcu_torture_read(const char *rcutorturename,
 			       struct rcu_head *rhp,
 			       unsigned long secs,
@@ -76,7 +70,6 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
 #define do_trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \
 	do { } while (0)
 #endif
-#endif
 
 #define UINT_CMP_GE(a, b)	(UINT_MAX / 2 >= (a) - (b))
 #define UINT_CMP_LT(a, b)	(UINT_MAX / 2 < (a) - (b))
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 0c47e30..d1dc83b 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -161,18 +161,6 @@ static void invoke_rcu_core(void);
 static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp);
 
 /*
- * Track the rcutorture test sequence number and the update version
- * number within a given test.  The rcutorture_testseq is incremented
- * on every rcutorture module load and unload, so has an odd value
- * when a test is running.  The rcutorture_vernum is set to zero
- * when rcutorture starts and is incremented on each rcutorture update.
- * These variables enable correlating rcutorture output with the
- * RCU tracing information.
- */
-unsigned long rcutorture_testseq;
-unsigned long rcutorture_vernum;
-
-/*
  * Return true if an RCU grace period is in progress.  The ACCESS_ONCE()s
  * permit this function to be invoked without holding the root rcu_node
  * structure's ->lock, but of course results can be subject to change.
@@ -279,6 +267,21 @@ void rcu_bh_force_quiescent_state(void)
 }
 EXPORT_SYMBOL_GPL(rcu_bh_force_quiescent_state);
 
+#ifdef CONFIG_RCU_TORTURE_TEST
+
+/*
+ * Track the rcutorture test sequence number and the update version
+ * number within a given test.  The rcutorture_testseq is incremented
+ * on every rcutorture module load and unload, so has an odd value
+ * when a test is running.  The rcutorture_vernum is set to zero
+ * when rcutorture starts and is incremented on each rcutorture update.
+ * These variables enable correlating rcutorture output with the
+ * RCU tracing information.
+ */
+unsigned long rcutorture_testseq;
+unsigned long rcutorture_vernum;
+
+
 /*

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

* Re: [PATCH 1/1] rcu: cleanup: make rcutorture specific definitions depend on config value
@ 2014-04-21  0:07 Pranith Kumar
  2014-04-21 15:50 ` Paul E. McKenney
  0 siblings, 1 reply; 4+ messages in thread
From: Pranith Kumar @ 2014-04-21  0:07 UTC (permalink / raw)
  To: paulmck; +Cc: LKML

Seems that my previous mail was borked while copying the patch. Please find the fixed patch below:

make rcutorture specific variables in tree.c depend on CONFIG_RCU_TORTURE_TEST
This avoid having to have them when no torture tests are running.
Also cleanup some macros which are rcutorture specific.

Tested with rcutorture both in-built and as a module

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 include/linux/rcupdate.h | 13 +++---------
 kernel/rcu/tree.c        | 54 ++++++++++++++++++++++++++----------------------
 kernel/rcu/tree_trace.c  |  7 +++++++
 3 files changed, 39 insertions(+), 35 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 00a7fd6..b49e46b 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -49,16 +49,8 @@
 extern int rcu_expedited; /* for sysctl */
 #ifdef CONFIG_RCU_TORTURE_TEST
 extern int rcutorture_runnable; /* for sysctl */
-#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
-
-#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
 void rcutorture_record_test_transition(void);
 void rcutorture_record_progress(unsigned long vernum);
-void do_trace_rcu_torture_read(const char *rcutorturename,
-			       struct rcu_head *rhp,
-			       unsigned long secs,
-			       unsigned long c_old,
-			       unsigned long c);
 #else
 static inline void rcutorture_record_test_transition(void)
 {
@@ -66,7 +58,9 @@ static inline void rcutorture_record_test_transition(void)
 static inline void rcutorture_record_progress(unsigned long vernum)
 {
 }
-#ifdef CONFIG_RCU_TRACE
+#endif /* CONFIG_RCU_TORTURE_TEST */
+
+#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) || defined(CONFIG_RCU_TRACE)
 void do_trace_rcu_torture_read(const char *rcutorturename,
 			       struct rcu_head *rhp,
 			       unsigned long secs,
@@ -76,7 +70,6 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
 #define do_trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \
 	do { } while (0)
 #endif
-#endif
 
 #define UINT_CMP_GE(a, b)	(UINT_MAX / 2 >= (a) - (b))
 #define UINT_CMP_LT(a, b)	(UINT_MAX / 2 < (a) - (b))
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 0c47e30..b455cd4 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -160,6 +160,8 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
 static void invoke_rcu_core(void);
 static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp);
 
+#ifdef CONFIG_RCU_TORTURE_TEST
+
 /*
  * Track the rcutorture test sequence number and the update version
  * number within a given test.  The rcutorture_testseq is incremented
@@ -173,6 +175,33 @@ unsigned long rcutorture_testseq;
 unsigned long rcutorture_vernum;
 
 /*
+ * Record the number of times rcutorture tests have been initiated and
+ * terminated.  This information allows the debugfs tracing stats to be
+ * correlated to the rcutorture messages, even when the rcutorture module
+ * is being repeatedly loaded and unloaded.  In other words, we cannot
+ * store this state in rcutorture itself.
+ */
+void rcutorture_record_test_transition(void)
+{
+	rcutorture_testseq++;
+	rcutorture_vernum = 0;
+}
+EXPORT_SYMBOL_GPL(rcutorture_record_test_transition);
+
+/*
+ * Record the number of writer passes through the current rcutorture test.
+ * This is also used to correlate debugfs tracing stats with the rcutorture
+ * messages.
+ */
+void rcutorture_record_progress(unsigned long vernum)
+{
+	rcutorture_vernum++;
+}
+EXPORT_SYMBOL_GPL(rcutorture_record_progress);
+
+#endif /* CONFIG_RCU_TORTURE_TEST */
+
+/*
  * Return true if an RCU grace period is in progress.  The ACCESS_ONCE()s
  * permit this function to be invoked without holding the root rcu_node
  * structure's ->lock, but of course results can be subject to change.
@@ -280,31 +309,6 @@ void rcu_bh_force_quiescent_state(void)
 EXPORT_SYMBOL_GPL(rcu_bh_force_quiescent_state);
 
 /*
- * Record the number of times rcutorture tests have been initiated and
- * terminated.  This information allows the debugfs tracing stats to be
- * correlated to the rcutorture messages, even when the rcutorture module
- * is being repeatedly loaded and unloaded.  In other words, we cannot
- * store this state in rcutorture itself.
- */
-void rcutorture_record_test_transition(void)
-{
-	rcutorture_testseq++;
-	rcutorture_vernum = 0;
-}
-EXPORT_SYMBOL_GPL(rcutorture_record_test_transition);
-
-/*
- * Record the number of writer passes through the current rcutorture test.
- * This is also used to correlate debugfs tracing stats with the rcutorture
- * messages.
- */
-void rcutorture_record_progress(unsigned long vernum)
-{
-	rcutorture_vernum++;
-}
-EXPORT_SYMBOL_GPL(rcutorture_record_progress);
-
-/*
  * Force a quiescent state for RCU-sched.
  */
 void rcu_sched_force_quiescent_state(void)
diff --git a/kernel/rcu/tree_trace.c b/kernel/rcu/tree_trace.c
index 5cdc62e..3d10505 100644
--- a/kernel/rcu/tree_trace.c
+++ b/kernel/rcu/tree_trace.c
@@ -397,6 +397,8 @@ static const struct file_operations rcu_pending_fops = {
 	.release = seq_release,
 };
 
+#ifdef CONFIG_RCU_TORTURE_TEST
+
 static int show_rcutorture(struct seq_file *m, void *unused)
 {
 	seq_printf(m, "rcutorture test sequence: %lu %s\n",
@@ -420,6 +422,8 @@ static const struct file_operations rcutorture_fops = {
 	.release = single_release,
 };
 
+#endif /* CONFIG_RCU_TORTURE_TEST */
+
 static struct dentry *rcudir;
 
 static int __init rcutree_trace_init(void)
@@ -477,10 +481,13 @@ static int __init rcutree_trace_init(void)
 			goto free_out;
 	}
 
+#ifdef CONFIG_RCU_TORTURE_TEST
 	retval = debugfs_create_file("rcutorture", 0444, rcudir,
 						NULL, &rcutorture_fops);
 	if (!retval)
 		goto free_out;
+#endif
+
 	return 0;
 free_out:
 	debugfs_remove_recursive(rcudir);
-- 
1.9.1

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

* Re: [PATCH 1/1] rcu: cleanup: make rcutorture specific definitions depend on config value
  2014-04-21  0:07 [PATCH 1/1] rcu: cleanup: make rcutorture specific definitions depend on config value Pranith Kumar
@ 2014-04-21 15:50 ` Paul E. McKenney
  2014-04-21 18:08   ` Pranith Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2014-04-21 15:50 UTC (permalink / raw)
  To: Pranith Kumar; +Cc: LKML

On Sun, Apr 20, 2014 at 08:07:52PM -0400, Pranith Kumar wrote:
> Seems that my previous mail was borked while copying the patch. Please find the fixed patch below:
> 
> make rcutorture specific variables in tree.c depend on CONFIG_RCU_TORTURE_TEST
> This avoid having to have them when no torture tests are running.
> Also cleanup some macros which are rcutorture specific.
> 
> Tested with rcutorture both in-built and as a module
> 
> Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>

Good observation, but this approach prevents someone from building an
rcutorture module after the fact for a kernel that was built with
CONFIG_RCU_TORTURE_TEST=n.  So I have to say "no" on this one.

							Thanx, Paul

> ---
>  include/linux/rcupdate.h | 13 +++---------
>  kernel/rcu/tree.c        | 54 ++++++++++++++++++++++++++----------------------
>  kernel/rcu/tree_trace.c  |  7 +++++++
>  3 files changed, 39 insertions(+), 35 deletions(-)
> 
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 00a7fd6..b49e46b 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -49,16 +49,8 @@
>  extern int rcu_expedited; /* for sysctl */
>  #ifdef CONFIG_RCU_TORTURE_TEST
>  extern int rcutorture_runnable; /* for sysctl */
> -#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
> -
> -#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
>  void rcutorture_record_test_transition(void);
>  void rcutorture_record_progress(unsigned long vernum);
> -void do_trace_rcu_torture_read(const char *rcutorturename,
> -			       struct rcu_head *rhp,
> -			       unsigned long secs,
> -			       unsigned long c_old,
> -			       unsigned long c);
>  #else
>  static inline void rcutorture_record_test_transition(void)
>  {
> @@ -66,7 +58,9 @@ static inline void rcutorture_record_test_transition(void)
>  static inline void rcutorture_record_progress(unsigned long vernum)
>  {
>  }
> -#ifdef CONFIG_RCU_TRACE
> +#endif /* CONFIG_RCU_TORTURE_TEST */
> +
> +#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) || defined(CONFIG_RCU_TRACE)
>  void do_trace_rcu_torture_read(const char *rcutorturename,
>  			       struct rcu_head *rhp,
>  			       unsigned long secs,
> @@ -76,7 +70,6 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
>  #define do_trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \
>  	do { } while (0)
>  #endif
> -#endif
> 
>  #define UINT_CMP_GE(a, b)	(UINT_MAX / 2 >= (a) - (b))
>  #define UINT_CMP_LT(a, b)	(UINT_MAX / 2 < (a) - (b))
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 0c47e30..b455cd4 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -160,6 +160,8 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
>  static void invoke_rcu_core(void);
>  static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp);
> 
> +#ifdef CONFIG_RCU_TORTURE_TEST
> +
>  /*
>   * Track the rcutorture test sequence number and the update version
>   * number within a given test.  The rcutorture_testseq is incremented
> @@ -173,6 +175,33 @@ unsigned long rcutorture_testseq;
>  unsigned long rcutorture_vernum;
> 
>  /*
> + * Record the number of times rcutorture tests have been initiated and
> + * terminated.  This information allows the debugfs tracing stats to be
> + * correlated to the rcutorture messages, even when the rcutorture module
> + * is being repeatedly loaded and unloaded.  In other words, we cannot
> + * store this state in rcutorture itself.
> + */
> +void rcutorture_record_test_transition(void)
> +{
> +	rcutorture_testseq++;
> +	rcutorture_vernum = 0;
> +}
> +EXPORT_SYMBOL_GPL(rcutorture_record_test_transition);
> +
> +/*
> + * Record the number of writer passes through the current rcutorture test.
> + * This is also used to correlate debugfs tracing stats with the rcutorture
> + * messages.
> + */
> +void rcutorture_record_progress(unsigned long vernum)
> +{
> +	rcutorture_vernum++;
> +}
> +EXPORT_SYMBOL_GPL(rcutorture_record_progress);
> +
> +#endif /* CONFIG_RCU_TORTURE_TEST */
> +
> +/*
>   * Return true if an RCU grace period is in progress.  The ACCESS_ONCE()s
>   * permit this function to be invoked without holding the root rcu_node
>   * structure's ->lock, but of course results can be subject to change.
> @@ -280,31 +309,6 @@ void rcu_bh_force_quiescent_state(void)
>  EXPORT_SYMBOL_GPL(rcu_bh_force_quiescent_state);
> 
>  /*
> - * Record the number of times rcutorture tests have been initiated and
> - * terminated.  This information allows the debugfs tracing stats to be
> - * correlated to the rcutorture messages, even when the rcutorture module
> - * is being repeatedly loaded and unloaded.  In other words, we cannot
> - * store this state in rcutorture itself.
> - */
> -void rcutorture_record_test_transition(void)
> -{
> -	rcutorture_testseq++;
> -	rcutorture_vernum = 0;
> -}
> -EXPORT_SYMBOL_GPL(rcutorture_record_test_transition);
> -
> -/*
> - * Record the number of writer passes through the current rcutorture test.
> - * This is also used to correlate debugfs tracing stats with the rcutorture
> - * messages.
> - */
> -void rcutorture_record_progress(unsigned long vernum)
> -{
> -	rcutorture_vernum++;
> -}
> -EXPORT_SYMBOL_GPL(rcutorture_record_progress);
> -
> -/*
>   * Force a quiescent state for RCU-sched.
>   */
>  void rcu_sched_force_quiescent_state(void)
> diff --git a/kernel/rcu/tree_trace.c b/kernel/rcu/tree_trace.c
> index 5cdc62e..3d10505 100644
> --- a/kernel/rcu/tree_trace.c
> +++ b/kernel/rcu/tree_trace.c
> @@ -397,6 +397,8 @@ static const struct file_operations rcu_pending_fops = {
>  	.release = seq_release,
>  };
> 
> +#ifdef CONFIG_RCU_TORTURE_TEST
> +
>  static int show_rcutorture(struct seq_file *m, void *unused)
>  {
>  	seq_printf(m, "rcutorture test sequence: %lu %s\n",
> @@ -420,6 +422,8 @@ static const struct file_operations rcutorture_fops = {
>  	.release = single_release,
>  };
> 
> +#endif /* CONFIG_RCU_TORTURE_TEST */
> +
>  static struct dentry *rcudir;
> 
>  static int __init rcutree_trace_init(void)
> @@ -477,10 +481,13 @@ static int __init rcutree_trace_init(void)
>  			goto free_out;
>  	}
> 
> +#ifdef CONFIG_RCU_TORTURE_TEST
>  	retval = debugfs_create_file("rcutorture", 0444, rcudir,
>  						NULL, &rcutorture_fops);
>  	if (!retval)
>  		goto free_out;
> +#endif
> +
>  	return 0;
>  free_out:
>  	debugfs_remove_recursive(rcudir);
> -- 
> 1.9.1
> 


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

* Re: [PATCH 1/1] rcu: cleanup: make rcutorture specific definitions depend on config value
  2014-04-21 15:50 ` Paul E. McKenney
@ 2014-04-21 18:08   ` Pranith Kumar
  0 siblings, 0 replies; 4+ messages in thread
From: Pranith Kumar @ 2014-04-21 18:08 UTC (permalink / raw)
  To: Paul McKenney; +Cc: LKML

On Mon, Apr 21, 2014 at 11:50 AM, Paul E. McKenney
<paulmck@linux.vnet.ibm.com> wrote:
>
> Good observation, but this approach prevents someone from building an
> rcutorture module after the fact for a kernel that was built with
> CONFIG_RCU_TORTURE_TEST=n.  So I have to say "no" on this one.
>

OK, I did not consider that case!  I will keep my eyes open while
studying the code.

Regards,
-- 
Pranith

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

end of thread, other threads:[~2014-04-21 18:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-21  0:07 [PATCH 1/1] rcu: cleanup: make rcutorture specific definitions depend on config value Pranith Kumar
2014-04-21 15:50 ` Paul E. McKenney
2014-04-21 18:08   ` Pranith Kumar
  -- strict thread matches above, loose matches on Subject: below --
2014-04-20 21:57 Pranith Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).