public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Korty <joe.korty@ccur.com>
To: paulmck@linux.vnet.ibm.com
Cc: fweisbec@gmail.com, peterz@infradead.org, laijs@cn.fujitsu.com,
	mathieu.desnoyers@efficios.com, dhowells@redhat.com,
	loic.minier@linaro.org, dhaval.giani@gmail.com,
	tglx@linutronix.de, josh@joshtriplett.org,
	houston.jim@comcast.net, andi@firstfloor.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 11/24] jrcu: use xchg to toggle rcu_which
Date: Thu, 24 Mar 2011 13:48:02 -0400	[thread overview]
Message-ID: <20110324174802.GA18878@tsunami.ccur.com> (raw)

Use xchg rather than wmb()s to change the value
of rcu_which.

This may be better than wmb()s as xchg will not
let the insn counter advance past the xchg until
the exchanged result is visible to other cpus.

Signed-off-by: Joe Korty <joe.korty@ccur.com>

Index: b/kernel/jrcu.c
===================================================================
--- a/kernel/jrcu.c
+++ b/kernel/jrcu.c
@@ -371,14 +371,16 @@ static void __rcu_delimit_batches(struct
 		else
 			rd->wait = 0;
 	}
+	smp_wmb(); /* just paranoia, the below xchg should do this on all archs */
 
 	/*
-	 * Swap current and previous lists.  The other cpus must not see this
-	 * out-of-order w.r.t. the above emptying of each cpu's previous list,
-	 * hence the smp_wmb.
+	 * Swap current and previous lists.  The other cpus must not
+	 * see this out-of-order w.r.t. the above emptying of each cpu's
+	 * previous list.  The xchg accomplishes that and, as a side (but
+	 * seemingly unneeded) bonus, keeps this cpu from advancing its insn
+	 * counter until the results of that xchg are visible on other cpus.
 	 */
-	smp_wmb();
-	rcu_which = prev;
+	xchg(&rcu_which, prev); /* only place where rcu_which is written to */
 	rcu_stats.nbatches++;
 }
 

                 reply	other threads:[~2011-03-24 17:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20110324174802.GA18878@tsunami.ccur.com \
    --to=joe.korty@ccur.com \
    --cc=andi@firstfloor.org \
    --cc=dhaval.giani@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=houston.jim@comcast.net \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loic.minier@linaro.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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