linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: josh@joshtriplett.org
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
	laijs@cn.fujitsu.com, dipankar@in.ibm.com,
	akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
	tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org,
	dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com,
	fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com
Subject: Re: [PATCH v2 tip/core/rcu 03/10] rcu: Add synchronous grace-period waiting for RCU-tasks
Date: Thu, 31 Jul 2014 09:58:52 -0700	[thread overview]
Message-ID: <20140731165852.GD12697@cloud> (raw)
In-Reply-To: <1406767182-4356-3-git-send-email-paulmck@linux.vnet.ibm.com>

On Wed, Jul 30, 2014 at 05:39:35PM -0700, Paul E. McKenney wrote:
> From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> 
> It turns out to be easier to add the synchronous grace-period waiting
> functions to RCU-tasks than to work around their absense in rcutorture,
> so this commit adds them.  The key point is that the existence of
> call_rcu_tasks() means that rcutorture needs an rcu_barrier_tasks().
> 
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

With rcu_barrier_tasks being a trivial wrapper, why not just let
rcutorture call synchronize_rcu_tasks directly?

>  include/linux/rcupdate.h |  2 ++
>  kernel/rcu/update.c      | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 57 insertions(+)
> 
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 3299ff98ad03..17c7e25c38be 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -216,6 +216,8 @@ void synchronize_sched(void);
>   * memory ordering guarantees.
>   */
>  void call_rcu_tasks(struct rcu_head *head, void (*func)(struct rcu_head *head));
> +void synchronize_rcu_tasks(void);
> +void rcu_barrier_tasks(void);
>  
>  #ifdef CONFIG_PREEMPT_RCU
>  
> diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
> index b92268647a01..c8d304dc6d8a 100644
> --- a/kernel/rcu/update.c
> +++ b/kernel/rcu/update.c
> @@ -387,6 +387,61 @@ void call_rcu_tasks(struct rcu_head *rhp, void (*func)(struct rcu_head *rhp))
>  }
>  EXPORT_SYMBOL_GPL(call_rcu_tasks);
>  
> +/**
> + * synchronize_rcu_tasks - wait until an rcu-tasks grace period has elapsed.
> + *
> + * Control will return to the caller some time after a full rcu-tasks
> + * grace period has elapsed, in other words after all currently
> + * executing rcu-tasks read-side critical sections have elapsed.  These
> + * read-side critical sections are delimited by calls to schedule(),
> + * cond_resched_rcu_qs(), idle execution, userspace execution, calls
> + * to synchronize_rcu_tasks(), and (in theory, anyway) cond_resched().
> + *
> + * This is a very specialized primitive, intended only for a few uses in
> + * tracing and other situations requiring manipulation of function
> + * preambles and profiling hooks.  The synchronize_rcu_tasks() function
> + * is not (yet) intended for heavy use from multiple CPUs.
> + *
> + * Note that this guarantee implies further memory-ordering guarantees.
> + * On systems with more than one CPU, when synchronize_rcu_tasks() returns,
> + * each CPU is guaranteed to have executed a full memory barrier since the
> + * end of its last RCU-tasks read-side critical section whose beginning
> + * preceded the call to synchronize_rcu_tasks().  In addition, each CPU
> + * having an RCU-tasks read-side critical section that extends beyond
> + * the return from synchronize_rcu_tasks() is guaranteed to have executed
> + * a full memory barrier after the beginning of synchronize_rcu_tasks()
> + * and before the beginning of that RCU-tasks read-side critical section.
> + * Note that these guarantees include CPUs that are offline, idle, or
> + * executing in user mode, as well as CPUs that are executing in the kernel.
> + *
> + * Furthermore, if CPU A invoked synchronize_rcu_tasks(), which returned
> + * to its caller on CPU B, then both CPU A and CPU B are guaranteed
> + * to have executed a full memory barrier during the execution of
> + * synchronize_rcu_tasks() -- even if CPU A and CPU B are the same CPU
> + * (but again only if the system has more than one CPU).
> + */
> +void synchronize_rcu_tasks(void)
> +{
> +	/* Complain if the scheduler has not started.  */
> +	rcu_lockdep_assert(!rcu_scheduler_active,
> +			   "synchronize_rcu_tasks called too soon");
> +
> +	/* Wait for the grace period. */
> +	wait_rcu_gp(call_rcu_tasks);
> +}
> +
> +/**
> + * rcu_barrier_tasks - Wait for in-flight call_rcu_tasks() callbacks.
> + *
> + * Although the current implementation is guaranteed to wait, it is not
> + * obligated to, for example, if there are no pending callbacks.
> + */
> +void rcu_barrier_tasks(void)
> +{
> +	/* There is only one callback queue, so this is easy.  ;-) */
> +	synchronize_rcu_tasks();
> +}
> +
>  /* RCU-tasks kthread that detects grace periods and invokes callbacks. */
>  static int __noreturn rcu_tasks_kthread(void *arg)
>  {
> -- 
> 1.8.1.5
> 

  reply	other threads:[~2014-07-31 16:58 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-31  0:39 [PATCH v2 tip/core/rcu 0/10] RCU-tasks implementation Paul E. McKenney
2014-07-31  0:39 ` [PATCH v2 tip/core/rcu 01/10] rcu: Add call_rcu_tasks() Paul E. McKenney
2014-07-31  0:39   ` [PATCH v2 tip/core/rcu 02/10] rcu: Provide cond_resched_rcu_qs() to force quiescent states in long loops Paul E. McKenney
2014-07-31  0:39   ` [PATCH v2 tip/core/rcu 03/10] rcu: Add synchronous grace-period waiting for RCU-tasks Paul E. McKenney
2014-07-31 16:58     ` josh [this message]
2014-07-31 18:34       ` Paul E. McKenney
2014-07-31  0:39   ` [PATCH v2 tip/core/rcu 04/10] rcu: Export RCU-tasks APIs to GPL modules Paul E. McKenney
2014-07-31 16:56     ` josh
2014-07-31 20:55       ` Paul E. McKenney
2014-07-31  0:39   ` [PATCH v2 tip/core/rcu 05/10] rcutorture: Add torture tests for RCU-tasks Paul E. McKenney
2014-07-31 17:01     ` josh
2014-07-31 20:55       ` Paul E. McKenney
2014-07-31  0:39   ` [PATCH v2 tip/core/rcu 06/10] rcutorture: Add RCU-tasks test cases Paul E. McKenney
2014-07-31  0:39   ` [PATCH v2 tip/core/rcu 07/10] rcu: Add stall-warning checks for RCU-tasks Paul E. McKenney
2014-07-31  0:39   ` [PATCH v2 tip/core/rcu 08/10] rcu: Improve RCU-tasks energy efficiency Paul E. McKenney
2014-07-31  0:39   ` [PATCH v2 tip/core/rcu 09/10] documentation: Add verbiage on RCU-tasks stall warning messages Paul E. McKenney
2014-07-31  0:39   ` [PATCH v2 tip/core/rcu 10/10] rcu: Make RCU-tasks track exiting tasks Paul E. McKenney
2014-07-31  7:30   ` [PATCH v2 tip/core/rcu 01/10] rcu: Add call_rcu_tasks() Lai Jiangshan
2014-07-31 16:09     ` Paul E. McKenney
2014-07-31 16:20       ` Peter Zijlstra
2014-07-31 16:47         ` Paul E. McKenney
2014-07-31 16:57           ` Peter Zijlstra
2014-07-31 16:31       ` Oleg Nesterov
2014-07-31 17:02         ` Paul E. McKenney
2014-07-31 17:27           ` Oleg Nesterov
2014-07-31 17:44             ` Paul E. McKenney
2014-08-01  0:53       ` Lai Jiangshan
2014-08-01  2:09         ` Paul E. McKenney
2014-08-01 15:53   ` Oleg Nesterov
2014-08-01 18:19     ` Paul E. McKenney
2014-08-01 18:36       ` Oleg Nesterov
2014-07-31 16:19 ` [PATCH v2 tip/core/rcu 0/10] RCU-tasks implementation josh
2014-07-31 16:30   ` Peter Zijlstra
2014-07-31 16:43     ` josh
2014-07-31 16:49     ` Paul E. McKenney
2014-07-31 16:58   ` Paul E. McKenney
2014-07-31 17:20     ` josh
2014-07-31 18:38       ` Paul E. McKenney
2014-07-31 20:58         ` josh
2014-07-31 21:11           ` Paul E. McKenney
2014-07-31 19:29 ` Andi Kleen
2014-07-31 21:08   ` 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=20140731165852.GD12697@cloud \
    --to=josh@joshtriplett.org \
    --cc=akpm@linux-foundation.org \
    --cc=bobby.prani@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=dvhart@linux.intel.com \
    --cc=edumazet@google.com \
    --cc=fweisbec@gmail.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --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;
as well as URLs for NNTP newsgroup(s).