diff mbox

[tip/core/rcu,08/15] rcu: Apply for_each_rcu_flavor() to increment_cpu_stall_ticks()

Message ID 1346352988-32444-8-git-send-email-paulmck@linux.vnet.ibm.com
State Accepted
Commit 115f7a7ca0d412aab81acaaaa95eb1ab1c622e2f
Headers show

Commit Message

Paul E. McKenney Aug. 30, 2012, 6:56 p.m. UTC
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>

The increment_cpu_stall_ticks() function listed each RCU flavor
explicitly, with an ifdef to handle preemptible RCU.  This commit
therefore applies for_each_rcu_flavor() to save a line of code.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 kernel/rcutree_plugin.h |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

Comments

Josh Triplett Aug. 31, 2012, 6:15 p.m. UTC | #1
On Thu, Aug 30, 2012 at 11:56:21AM -0700, Paul E. McKenney wrote:
> From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> 
> The increment_cpu_stall_ticks() function listed each RCU flavor
> explicitly, with an ifdef to handle preemptible RCU.  This commit
> therefore applies for_each_rcu_flavor() to save a line of code.

And also mysteriously changes __get_cpu_var to __this_cpu_var without
documenting that (or the reason for it) in the commit message. :)

> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
>  kernel/rcutree_plugin.h |    9 ++++-----
>  1 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
> index 3ea60c9..139a803 100644
> --- a/kernel/rcutree_plugin.h
> +++ b/kernel/rcutree_plugin.h
> @@ -2196,11 +2196,10 @@ static void zero_cpu_stall_ticks(struct rcu_data *rdp)
>  /* Increment ->ticks_this_gp for all flavors of RCU. */
>  static void increment_cpu_stall_ticks(void)
>  {
> -	__get_cpu_var(rcu_sched_data).ticks_this_gp++;
> -	__get_cpu_var(rcu_bh_data).ticks_this_gp++;
> -#ifdef CONFIG_TREE_PREEMPT_RCU
> -	__get_cpu_var(rcu_preempt_data).ticks_this_gp++;
> -#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
> +	struct rcu_state *rsp;
> +
> +	for_each_rcu_flavor(rsp)
> +		__this_cpu_ptr(rsp->rda)->ticks_this_gp++;
>  }
>  
>  #else /* #ifdef CONFIG_RCU_CPU_STALL_INFO */
> -- 
> 1.7.8
>
Paul E. McKenney Sept. 4, 2012, 10:44 p.m. UTC | #2
On Fri, Aug 31, 2012 at 11:15:16AM -0700, Josh Triplett wrote:
> On Thu, Aug 30, 2012 at 11:56:21AM -0700, Paul E. McKenney wrote:
> > From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> > 
> > The increment_cpu_stall_ticks() function listed each RCU flavor
> > explicitly, with an ifdef to handle preemptible RCU.  This commit
> > therefore applies for_each_rcu_flavor() to save a line of code.
> 
> And also mysteriously changes __get_cpu_var to __this_cpu_var without
> documenting that (or the reason for it) in the commit message. :)

Good point!  The change is needed because of the need to switch from
using the given rcu_data per-CPU variable directly to accessing it via
each rcu_state structure's ->rda pointer.  Will update the commit log.

							Thanx, Paul

> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > ---
> >  kernel/rcutree_plugin.h |    9 ++++-----
> >  1 files changed, 4 insertions(+), 5 deletions(-)
> > 
> > diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
> > index 3ea60c9..139a803 100644
> > --- a/kernel/rcutree_plugin.h
> > +++ b/kernel/rcutree_plugin.h
> > @@ -2196,11 +2196,10 @@ static void zero_cpu_stall_ticks(struct rcu_data *rdp)
> >  /* Increment ->ticks_this_gp for all flavors of RCU. */
> >  static void increment_cpu_stall_ticks(void)
> >  {
> > -	__get_cpu_var(rcu_sched_data).ticks_this_gp++;
> > -	__get_cpu_var(rcu_bh_data).ticks_this_gp++;
> > -#ifdef CONFIG_TREE_PREEMPT_RCU
> > -	__get_cpu_var(rcu_preempt_data).ticks_this_gp++;
> > -#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
> > +	struct rcu_state *rsp;
> > +
> > +	for_each_rcu_flavor(rsp)
> > +		__this_cpu_ptr(rsp->rda)->ticks_this_gp++;
> >  }
> >  
> >  #else /* #ifdef CONFIG_RCU_CPU_STALL_INFO */
> > -- 
> > 1.7.8
> > 
>
diff mbox

Patch

diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index 3ea60c9..139a803 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -2196,11 +2196,10 @@  static void zero_cpu_stall_ticks(struct rcu_data *rdp)
 /* Increment ->ticks_this_gp for all flavors of RCU. */
 static void increment_cpu_stall_ticks(void)
 {
-	__get_cpu_var(rcu_sched_data).ticks_this_gp++;
-	__get_cpu_var(rcu_bh_data).ticks_this_gp++;
-#ifdef CONFIG_TREE_PREEMPT_RCU
-	__get_cpu_var(rcu_preempt_data).ticks_this_gp++;
-#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */
+	struct rcu_state *rsp;
+
+	for_each_rcu_flavor(rsp)
+		__this_cpu_ptr(rsp->rda)->ticks_this_gp++;
 }
 
 #else /* #ifdef CONFIG_RCU_CPU_STALL_INFO */