public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
	laijs@cn.fujitsu.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca,
	niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org,
	rostedt@goodmis.org, Valdis.Kletnieks@vt.edu,
	dhowells@redhat.com, eric.dumazet@gmail.com, darren@dvhart.com,
	fweisbec@gmail.com, patches@linaro.org,
	"Paul E. McKenney" <paul.mckenney@linaro.org>
Subject: Re: [PATCH tip/core/rcu 09/15] rcu: Increasing rcu_barrier() concurrency
Date: Fri, 15 Jun 2012 16:31:51 -0700	[thread overview]
Message-ID: <20120615233151.GA7613@leaf> (raw)
In-Reply-To: <1339794370-28119-9-git-send-email-paulmck@linux.vnet.ibm.com>

On Fri, Jun 15, 2012 at 02:06:04PM -0700, Paul E. McKenney wrote:
> From: "Paul E. McKenney" <paul.mckenney@linaro.org>
> 
> The traditional rcu_barrier() implementation has serialized all requests,
> regardless of RCU flavor, and also does not coalesce concurrent requests.
> In the past, this has been good and sufficient.
> 
> However, systems are getting larger and use of rcu_barrier() has been
> increasing.  This commit therefore introduces a counter-based scheme
> that allows _rcu_barrier() calls for the same flavor of RCU to take
> advantage of each others' work.
> 
> Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
>  kernel/rcutree.c |   27 ++++++++++++++++++++++++++-
>  kernel/rcutree.h |    2 ++
>  2 files changed, 28 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> index 93358d4..7c299d3 100644
> --- a/kernel/rcutree.c
> +++ b/kernel/rcutree.c
> @@ -2291,13 +2291,32 @@ static void _rcu_barrier(struct rcu_state *rsp)
>  	unsigned long flags;
>  	struct rcu_data *rdp;
>  	struct rcu_data rd;
> +	unsigned long snap = ACCESS_ONCE(rsp->n_barrier_done);
> +	unsigned long snap_done;
>  
>  	init_rcu_head_on_stack(&rd.barrier_head);
>  
>  	/* Take mutex to serialize concurrent rcu_barrier() requests. */
>  	mutex_lock(&rsp->barrier_mutex);
>  
> -	smp_mb();  /* Prevent any prior operations from leaking in. */
> +	/*
> +	 * Ensure tht all prior references, including to ->n_barrier_done,
> +	 * are ordered before the _rcu_barrier() machinery.
> +	 */
> +	smp_mb();  /* See above block comment. */

If checkpatch complains about the lack of a comment to the right of a
barrier even when the barrier has a comment directly above it, that
seems like a bug in checkpatch that needs fixing, to prevent developers
from having to add noise like "See above block comment.". :)

Also: what type of barriers do mutex_lock and mutex_unlock imply?  I
assume they imply some weaker barrier than smp_mb, but I'd still assume
they imply *some* barrier.

> +	/* Recheck ->n_barrier_done to see if others did our work for us. */
> +	snap_done = ACCESS_ONCE(rsp->n_barrier_done);
> +	if (ULONG_CMP_GE(snap_done, ((snap + 1) & ~0x1) + 2)) {

This calculation seems sufficiently clever that it merits an explanatory
comment.

> +		smp_mb();
> +		mutex_unlock(&rsp->barrier_mutex);
> +		return;
> +	}
> +
> +	/* Increment ->n_barrier_done to avoid duplicate work. */
> +	ACCESS_ONCE(rsp->n_barrier_done)++;

Interesting dissonance here: the use of ACCESS_ONCE with ++ implies
exactly two accesses, rather than exactly one.  What makes it safe to
not use atomic_inc here, but not safe to drop the ACCESS_ONCE?
Potential use of a cached value read earlier in the function?

- Josh Triplett

  reply	other threads:[~2012-06-15 23:32 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-15 21:05 [PATCH tip/core/rcu 0/15] Improvements to rcu_barrier() and RT response on big systems Paul E. McKenney
2012-06-15 21:05 ` [PATCH tip/core/rcu 01/15] rcu: Control RCU_FANOUT_LEAF from boot-time parameter Paul E. McKenney
2012-06-15 21:05   ` [PATCH tip/core/rcu 02/15] rcu: Size rcu_node tree from nr_cpu_ids rather than NR_CPUS Paul E. McKenney
2012-06-15 21:47     ` Josh Triplett
2012-06-16  0:37       ` Paul E. McKenney
2012-06-16  5:17         ` Josh Triplett
2012-06-16  6:38           ` Paul E. McKenney
2012-06-16  9:17             ` Josh Triplett
2012-06-16 14:44               ` Paul E. McKenney
2012-06-16 14:51                 ` Paul E. McKenney
2012-06-16 20:31                   ` Josh Triplett
2012-06-15 21:05   ` [PATCH tip/core/rcu 03/15] rcu: Prevent excessive line length in RCU_STATE_INITIALIZER() Paul E. McKenney
2012-06-15 21:48     ` Josh Triplett
2012-06-15 21:05   ` [PATCH tip/core/rcu 04/15] rcu: Place pointer to call_rcu() in rcu_data structure Paul E. McKenney
2012-06-15 22:08     ` Josh Triplett
2012-06-15 21:06   ` [PATCH tip/core/rcu 05/15] rcu: Move _rcu_barrier()'s rcu_head structures to rcu_data structures Paul E. McKenney
2012-06-15 22:19     ` Josh Triplett
2012-06-15 21:06   ` [PATCH tip/core/rcu 06/15] rcu: Move rcu_barrier_cpu_count to rcu_state structure Paul E. McKenney
2012-06-15 22:44     ` Josh Triplett
2012-06-15 21:06   ` [PATCH tip/core/rcu 07/15] rcu: Move rcu_barrier_completion " Paul E. McKenney
2012-06-15 22:51     ` Josh Triplett
2012-06-15 21:06   ` [PATCH tip/core/rcu 08/15] rcu: Move rcu_barrier_mutex " Paul E. McKenney
2012-06-15 22:55     ` Josh Triplett
2012-06-15 21:06   ` [PATCH tip/core/rcu 09/15] rcu: Increasing rcu_barrier() concurrency Paul E. McKenney
2012-06-15 23:31     ` Josh Triplett [this message]
2012-06-16  0:21       ` Steven Rostedt
2012-06-16  0:49         ` Paul E. McKenney
2012-06-16  0:48       ` Paul E. McKenney
2012-06-15 21:06   ` [PATCH tip/core/rcu 10/15] rcu: Add tracing for _rcu_barrier() Paul E. McKenney
2012-06-15 23:35     ` Josh Triplett
2012-06-15 21:06   ` [PATCH tip/core/rcu 11/15] rcu: Add rcu_barrier() statistics to debugfs tracing Paul E. McKenney
2012-06-15 23:38     ` Josh Triplett
2012-06-15 21:06   ` [PATCH tip/core/rcu 12/15] rcu: Remove unneeded __rcu_process_callbacks() argument Paul E. McKenney
2012-06-15 23:37     ` Josh Triplett
2012-06-15 21:06   ` [PATCH tip/core/rcu 13/15] rcu: Introduce for_each_rcu_flavor() and use it Paul E. McKenney
2012-06-15 23:52     ` Josh Triplett
2012-06-16  1:01       ` Paul E. McKenney
2012-06-16  5:35         ` Josh Triplett
2012-06-16  6:36           ` Paul E. McKenney
2012-06-15 21:06   ` [PATCH tip/core/rcu 14/15] rcu: Use for_each_rcu_flavor() in TREE_RCU tracing Paul E. McKenney
2012-06-15 23:59     ` Josh Triplett
2012-06-16  0:56       ` Paul E. McKenney
2012-06-16  5:22         ` Josh Triplett
2012-06-16  6:42           ` Paul E. McKenney
2012-06-15 21:06   ` [PATCH tip/core/rcu 15/15] rcu: RCU_SAVE_DYNTICK code no longer ever dead Paul E. McKenney
2012-06-16  0:02     ` Josh Triplett
2012-06-16  0:04       ` Josh Triplett
2012-06-16  1:04         ` Paul E. McKenney
2012-06-15 21:43   ` [PATCH tip/core/rcu 01/15] rcu: Control RCU_FANOUT_LEAF from boot-time parameter Josh Triplett
2012-06-15 22:10     ` Paul E. McKenney

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=20120615233151.GA7613@leaf \
    --to=josh@joshtriplett.org \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=darren@dvhart.com \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=eric.dumazet@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mingo@elte.hu \
    --cc=niv@us.ibm.com \
    --cc=patches@linaro.org \
    --cc=paul.mckenney@linaro.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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