linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Christoph Lameter <cl@linux.com>
Cc: Tejun Heo <tj@kernel.org>,
	akpm@linuxfoundation.org, Dipankar Sarma <dipankar@in.ibm.com>,
	linux-arch@vger.kernel.org, Steven Rostedt <srostedt@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [gcv v3 10/35] rcu: Replace __get_cpu_var uses
Date: Wed, 4 Sep 2013 12:41:35 -0700	[thread overview]
Message-ID: <20130904194135.GD3966@linux.vnet.ibm.com> (raw)
In-Reply-To: <00000140e95815db-41b26a90-9bc9-490e-a313-e05364a152cb-000000@email.amazonses.com>

On Wed, Sep 04, 2013 at 02:19:59PM +0000, Christoph Lameter wrote:
> On Sat, 31 Aug 2013, Paul E. McKenney wrote:
> 
> > Queued for 3.13.  I had to rework for conflicts, please see below for
> > the update patch.
> 
> Looks fine to me. Can I drop the rcu patches from my patchset?

Yep, still queued for 3.13, and I even redid the change in
rcu_is_cpu_idle() to be the way you wanted it.  I wouldn't do that for
just anyone, you know!  ;-)

Current patch below.

							Thanx, Paul

------------------------------------------------------------------------

    rcu: Replace __get_cpu_var() uses
    
    __get_cpu_var() is used for multiple purposes in the kernel source. One
    of them is address calculation via the form &__get_cpu_var(x). This
    calculates the address for the instance of the percpu variable of the
    current processor based on an offset.
    
    Other use cases are for storing and retrieving data from the current
    processors percpu area.  __get_cpu_var() can be used as an lvalue when
    writing data or on the right side of an assignment.
    
    __get_cpu_var() is defined as :
    
    __get_cpu_var() always only does an address determination. However,
    store and retrieve operations could use a segment prefix (or global
    register on other platforms) to avoid the address calculation.
    
    this_cpu_write() and this_cpu_read() can directly take an offset into
    a percpu area and use optimized assembly code to read and write per
    cpu variables.
    
    This patch converts __get_cpu_var into either an explicit address
    calculation using this_cpu_ptr() or into a use of this_cpu operations
    that use the offset. Thereby address calcualtions are avoided and less
    registers are used when code is generated.
    
    At the end of the patchset all uses of __get_cpu_var have been removed
    so the macro is removed too.
    
    The patchset includes passes over all arches as well. Once these
    operations are used throughout then specialized macros can be defined in
    non -x86 arches as well in order to optimize per cpu access by f.e. using
    a global register that may be set to the per cpu base.
    
    Transformations done to __get_cpu_var()
    
    1. Determine the address of the percpu instance of the current processor.
    
    	DEFINE_PER_CPU(int, y);
    	int *x = &__get_cpu_var(y);
    
        Converts to
    
    	int *x = this_cpu_ptr(&y);
    
    2. Same as #1 but this time an array structure is involved.
    
    	DEFINE_PER_CPU(int, y[20]);
    	int *x = __get_cpu_var(y);
    
        Converts to
    
    	int *x = this_cpu_ptr(y);
    
    3. Retrieve the content of the current processors instance of a per cpu
       variable.
    
    	DEFINE_PER_CPU(int, u);
    	int x = __get_cpu_var(y)
    
       Converts to
    
    	int x = __this_cpu_read(y);
    
    4. Retrieve the content of a percpu struct
    
    	DEFINE_PER_CPU(struct mystruct, y);
    	struct mystruct x = __get_cpu_var(y);
    
       Converts to
    
    	memcpy(this_cpu_ptr(&x), y, sizeof(x));
    
    5. Assignment to a per cpu variable
    
    	DEFINE_PER_CPU(int, y)
    	__get_cpu_var(y) = x;
    
       Converts to
    
    	this_cpu_write(y, x);
    
    6. Increment/Decrement etc of a per cpu variable
    
    	DEFINE_PER_CPU(int, y);
    	__get_cpu_var(y)++
    
       Converts to
    
    	this_cpu_inc(y)
    
    Signed-off-by: Christoph Lameter <cl@linux.com>
    [ paulmck: Address conflicts. ]
    Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index a51985e..450b190 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -400,7 +400,7 @@ static void rcu_eqs_enter(bool user)
 	long long oldval;
 	struct rcu_dynticks *rdtp;
 
-	rdtp = &__get_cpu_var(rcu_dynticks);
+	rdtp = this_cpu_ptr(&rcu_dynticks);
 	oldval = rdtp->dynticks_nesting;
 	WARN_ON_ONCE((oldval & DYNTICK_TASK_NEST_MASK) == 0);
 	if ((oldval & DYNTICK_TASK_NEST_MASK) == DYNTICK_TASK_NEST_VALUE)
@@ -428,7 +428,7 @@ void rcu_idle_enter(void)
 
 	local_irq_save(flags);
 	rcu_eqs_enter(false);
-	rcu_sysidle_enter(&__get_cpu_var(rcu_dynticks), 0);
+	rcu_sysidle_enter(this_cpu_ptr(&rcu_dynticks), 0);
 	local_irq_restore(flags);
 }
 EXPORT_SYMBOL_GPL(rcu_idle_enter);
@@ -471,7 +471,7 @@ void rcu_irq_exit(void)
 	struct rcu_dynticks *rdtp;
 
 	local_irq_save(flags);
-	rdtp = &__get_cpu_var(rcu_dynticks);
+	rdtp = this_cpu_ptr(&rcu_dynticks);
 	oldval = rdtp->dynticks_nesting;
 	rdtp->dynticks_nesting--;
 	WARN_ON_ONCE(rdtp->dynticks_nesting < 0);
@@ -521,7 +521,7 @@ static void rcu_eqs_exit(bool user)
 	struct rcu_dynticks *rdtp;
 	long long oldval;
 
-	rdtp = &__get_cpu_var(rcu_dynticks);
+	rdtp = this_cpu_ptr(&rcu_dynticks);
 	oldval = rdtp->dynticks_nesting;
 	WARN_ON_ONCE(oldval < 0);
 	if (oldval & DYNTICK_TASK_NEST_MASK)
@@ -548,7 +548,7 @@ void rcu_idle_exit(void)
 
 	local_irq_save(flags);
 	rcu_eqs_exit(false);
-	rcu_sysidle_exit(&__get_cpu_var(rcu_dynticks), 0);
+	rcu_sysidle_exit(this_cpu_ptr(&rcu_dynticks), 0);
 	local_irq_restore(flags);
 }
 EXPORT_SYMBOL_GPL(rcu_idle_exit);
@@ -592,7 +592,7 @@ void rcu_irq_enter(void)
 	long long oldval;
 
 	local_irq_save(flags);
-	rdtp = &__get_cpu_var(rcu_dynticks);
+	rdtp = this_cpu_ptr(&rcu_dynticks);
 	oldval = rdtp->dynticks_nesting;
 	rdtp->dynticks_nesting++;
 	WARN_ON_ONCE(rdtp->dynticks_nesting == 0);
@@ -613,7 +613,7 @@ void rcu_irq_enter(void)
  */
 void rcu_nmi_enter(void)
 {
-	struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
+	struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
 
 	if (rdtp->dynticks_nmi_nesting == 0 &&
 	    (atomic_read(&rdtp->dynticks) & 0x1))
@@ -635,7 +635,7 @@ void rcu_nmi_enter(void)
  */
 void rcu_nmi_exit(void)
 {
-	struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
+	struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
 
 	if (rdtp->dynticks_nmi_nesting == 0 ||
 	    --rdtp->dynticks_nmi_nesting != 0)
@@ -658,7 +658,7 @@ int rcu_is_cpu_idle(void)
 	int ret;
 
 	preempt_disable();
-	ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
+	ret = (atomic_read(this_cpu_ptr(&rcu_dynticks.dynticks)) & 0x1) == 0;
 	preempt_enable();
 	return ret;
 }
@@ -696,7 +696,7 @@ bool rcu_lockdep_current_cpu_online(void)
 	if (in_nmi())
 		return 1;
 	preempt_disable();
-	rdp = &__get_cpu_var(rcu_sched_data);
+	rdp = this_cpu_ptr(&rcu_sched_data);
 	rnp = rdp->mynode;
 	ret = (rdp->grpmask & rnp->qsmaskinit) ||
 	      !rcu_scheduler_fully_active;
@@ -716,7 +716,7 @@ EXPORT_SYMBOL_GPL(rcu_lockdep_current_cpu_online);
  */
 static int rcu_is_cpu_rrupt_from_idle(void)
 {
-	return __get_cpu_var(rcu_dynticks).dynticks_nesting <= 1;
+	return __this_cpu_read(rcu_dynticks.dynticks_nesting) <= 1;
 }
 
 /*
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index 08b6e74..dc09fb0 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -660,7 +660,7 @@ static void rcu_preempt_check_callbacks(int cpu)
 
 static void rcu_preempt_do_callbacks(void)
 {
-	rcu_do_batch(&rcu_preempt_state, &__get_cpu_var(rcu_preempt_data));
+	rcu_do_batch(&rcu_preempt_state, this_cpu_ptr(&rcu_preempt_data));
 }
 
 #endif /* #ifdef CONFIG_RCU_BOOST */
@@ -1332,7 +1332,7 @@ static void invoke_rcu_callbacks_kthread(void)
  */
 static bool rcu_is_callbacks_kthread(void)
 {
-	return __get_cpu_var(rcu_cpu_kthread_task) == current;
+	return __this_cpu_read(rcu_cpu_kthread_task) == current;
 }
 
 #define RCU_BOOST_DELAY_JIFFIES DIV_ROUND_UP(CONFIG_RCU_BOOST_DELAY * HZ, 1000)
@@ -1382,8 +1382,8 @@ static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
 
 static void rcu_kthread_do_work(void)
 {
-	rcu_do_batch(&rcu_sched_state, &__get_cpu_var(rcu_sched_data));
-	rcu_do_batch(&rcu_bh_state, &__get_cpu_var(rcu_bh_data));
+	rcu_do_batch(&rcu_sched_state, this_cpu_ptr(&rcu_sched_data));
+	rcu_do_batch(&rcu_bh_state, this_cpu_ptr(&rcu_bh_data));
 	rcu_preempt_do_callbacks();
 }
 
@@ -1402,7 +1402,7 @@ static void rcu_cpu_kthread_park(unsigned int cpu)
 
 static int rcu_cpu_kthread_should_run(unsigned int cpu)
 {
-	return __get_cpu_var(rcu_cpu_has_work);
+	return __this_cpu_read(rcu_cpu_has_work);
 }
 
 /*
@@ -1412,8 +1412,8 @@ static int rcu_cpu_kthread_should_run(unsigned int cpu)
  */
 static void rcu_cpu_kthread(unsigned int cpu)
 {
-	unsigned int *statusp = &__get_cpu_var(rcu_cpu_kthread_status);
-	char work, *workp = &__get_cpu_var(rcu_cpu_has_work);
+	unsigned int *statusp = this_cpu_ptr(&rcu_cpu_kthread_status);
+	char work, *workp = this_cpu_ptr(&rcu_cpu_has_work);
 	int spincnt;
 
 	for (spincnt = 0; spincnt < 10; spincnt++) {
@@ -1638,7 +1638,7 @@ static bool rcu_try_advance_all_cbs(void)
 {
 	bool cbs_ready = false;
 	struct rcu_data *rdp;
-	struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
+	struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
 	struct rcu_node *rnp;
 	struct rcu_state *rsp;
 

  parent reply	other threads:[~2013-09-04 19:42 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20130828193457.140443630@linux.com>
2013-08-28 19:34 ` [gcv v3 01/35] x86: Use this_cpu_inc/dec for debug registers Christoph Lameter
2013-08-28 19:34 ` [gcv v3 02/35] percpu: Make __verify_pcu_ptr handle per cpu pointers to arrays Christoph Lameter
2013-08-28 19:46 ` [gcv v3 23/35] s390: Replace __get_cpu_var uses Christoph Lameter
2013-08-28 19:46   ` Christoph Lameter
2013-08-28 19:46 ` [gcv v3 20/35] zcache/zsmalloc: " Christoph Lameter
2013-08-28 19:46   ` Christoph Lameter
2013-08-28 19:46 ` [gcv v3 34/35] metag: " Christoph Lameter
2013-08-28 19:46   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 09/35] block: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 18/35] drivers/leds: " Christoph Lameter
2013-09-03 20:40   ` Bryan Wu
2013-08-28 19:48 ` [gcv v3 03/35] Coccinelle script for __get_cpu_var conversion Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 06/35] scheduler: Replace __get_cpu_var uses Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-29  7:58   ` Peter Zijlstra
2013-08-29 10:01     ` Ingo Molnar
2013-08-29 16:57       ` Christoph Lameter
2013-08-29 17:32         ` Steven Rostedt
2013-08-29 18:15           ` Christoph Lameter
2013-08-29 18:30             ` Steven Rostedt
2013-08-29 18:30               ` Steven Rostedt
2013-09-03 14:26               ` Christoph Lameter
2013-09-03 14:45                 ` Frederic Weisbecker
2013-09-03 15:44                   ` Steven Rostedt
2013-09-03 17:09                     ` Christoph Lameter
2013-08-30  6:54             ` Ingo Molnar
2013-08-28 19:48 ` [gcv v3 04/35] net: " Christoph Lameter
2013-08-28 19:48 ` [gcv v3 22/35] mips: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 12/35] watchdog: " Christoph Lameter
2013-08-28 19:48 ` [gcv v3 28/35] blackfin: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 32/35] arc: " Christoph Lameter
2013-08-29  6:33   ` Vineet Gupta
2013-08-29 16:43     ` Christoph Lameter
2013-09-04  7:46       ` Vineet Gupta
2013-09-04 14:14         ` Christoph Lameter
2013-09-05  5:01           ` Vineet Gupta
2013-09-05 14:19             ` Christoph Lameter
2013-09-05 14:29               ` Vineet Gupta
2013-09-05 14:29                 ` Vineet Gupta
2013-08-28 19:48 ` [gcv v3 16/35] drivers/oprofile: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 08/35] tracing: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-29 21:26   ` Steven Rostedt
2013-09-03 14:34     ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 25/35] powerpc: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 21:18   ` Geert Uytterhoeven
2013-08-29 16:41     ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 05/35] time: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 17/35] drivers/net/ethernet/tile: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 19/35] drivers: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-29 10:30   ` James Hogan
2013-08-28 19:48 ` [gcv v3 07/35] mm: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 35/35] Remove __get_cpu_var and __raw_get_cpu_var macros [only in 3.13] Christoph Lameter
2013-08-28 19:48 ` [gcv v3 13/35] kernel misc: Replace __get_cpu_var uses Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 11/35] percpu: " Christoph Lameter
2013-08-28 19:48 ` [gcv v3 10/35] rcu: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-31 20:36   ` Paul E. McKenney
2013-09-04 14:19     ` Christoph Lameter
2013-09-04 14:19       ` Christoph Lameter
2013-09-04 19:41       ` Paul E. McKenney [this message]
2013-09-04 19:51         ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 26/35] sparc: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 14/35] drivers/char: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 29/35] avr32: " Christoph Lameter
2013-08-28 19:48 ` [gcv v3 21/35] x86: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 24/35] ia64: " Christoph Lameter
2013-08-28 19:48   ` Christoph Lameter
2013-08-28 19:48 ` [gcv v3 27/35] arm: " Christoph Lameter
2013-08-28 19:54   ` Russell King - ARM Linux
2013-08-28 20:42     ` Christoph Lameter
2013-08-28 20:42       ` Christoph Lameter
2013-08-30 10:01   ` Will Deacon
2013-09-03 14:39     ` Christoph Lameter
2013-09-04  9:33       ` Will Deacon
2013-09-04  9:33         ` Will Deacon
2013-09-04 14:17         ` Christoph Lameter
2013-09-04 14:23           ` Will Deacon
2013-09-04 14:54             ` Christoph Lameter
2013-09-04 17:46               ` Will Deacon
2013-09-04 18:09                 ` Christoph Lameter
2013-09-04 18:21                   ` Will Deacon
2013-09-04 18:21                     ` Will Deacon
2013-09-04 18:31                     ` Christoph Lameter
     [not found]                     ` <alpine.DEB.2.02.1309041324530.26497@gentwo.org>
2013-09-04 20:58                       ` Christoph Lameter
2013-09-05 13:03                         ` Will Deacon
2013-09-05 13:03                           ` Will Deacon
2013-09-05 14:24                           ` Christoph Lameter
2013-09-05 17:28                             ` Will Deacon
2013-09-05 17:52                               ` Christoph Lameter
2013-09-06 11:04                                 ` Will Deacon
2013-09-06 15:39                                   ` Christoph Lameter
2013-08-28 20:06 ` [gcv v3 15/35] drivers/cpuidle: " Christoph Lameter
2013-08-28 20:06   ` Christoph Lameter
2013-08-28 20:06 ` [gcv v3 33/35] parisc: " Christoph Lameter
2013-08-28 20:06   ` Christoph Lameter
2013-08-28 20:06 ` [gcv v3 30/35] alpha: Replace __get_cpu_var Christoph Lameter
2013-08-28 20:46 ` [gcv v3 31/35] sh: Replace __get_cpu_var uses Christoph Lameter
2013-08-28 20:46   ` Christoph Lameter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130904194135.GD3966@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linuxfoundation.org \
    --cc=cl@linux.com \
    --cc=dipankar@in.ibm.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srostedt@redhat.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).