public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: dipankar@in.ibm.com, Alan Stern <stern@rowland.harvard.edu>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	josht@us.ibm.com
Subject: Re: [PATCH 0/4] RCU: various merge candidates
Date: Tue, 29 Aug 2006 17:40:55 -0700	[thread overview]
Message-ID: <20060830004055.GA2845@us.ibm.com> (raw)
In-Reply-To: <20060828124058.cca5f5ab.akpm@osdl.org>

On Mon, Aug 28, 2006 at 12:40:58PM -0700, Andrew Morton wrote:
> On Tue, 29 Aug 2006 00:46:42 +0530
> Dipankar Sarma <dipankar@in.ibm.com> wrote:
> 
> > srcu (sleepable rcu) patches independent of the core RCU implementation
> > changes in the patchset. You can queue these up either before
> > or after srcu.
> > 
> > ...
> >
> > rcutorture fix patches independent of rcu implementation changes
> > in this patchset.
> 
> So this patchset is largely orthogonal to the presently-queued stuff?
>  
> > > 
> > > Now what?
> > 
> > Heh. I can always re-submit against -mm after I wait for a day or two
> > for comments :)
> 
> That would be good, thanks.  We were seriously considering merging all the
> SRCU stuff for 2.6.18, because
> cpufreq-make-the-transition_notifier-chain-use-srcu.patch fixes a cpufreq
> down()-in-irq-disabled warning at suspend time.
> 
> But that's a lot of new stuff just to fix a warning about something which
> won't actually cause any misbehaviour.  We could just as well do
> 
> 	if (irqs_disabled())
> 		down_read_trylock(...);	/* suspend */
> 	else
> 		down_read(...);
> 
> in cpufreq to temporarily shut the thing up.

I re-reviewed SRCU and found no issues.  So I am OK with it going upstream
if it is useful.

I do have a comment patch below to flag an "attractive nuisance".
Several people have asked about moving the final synchronize_sched()
out of the critical section, but this turns out to be not just scary,
but actually unsafe.  ;-)

Again, this patch just adds verbiage to an existing comment.

Signed-off-by: Paul E. McKenney <paulmck@us.ibm.com>
---

diff -urpNa -X dontdiff linux-2.6.18-rc2-mm1/kernel/srcu.c linux-2.6.18-rc2-mm1-srcu-comment/kernel/srcu.c
--- linux-2.6.18-rc2-mm1/kernel/srcu.c	2006-08-05 16:30:19.000000000 -0700
+++ linux-2.6.18-rc2-mm1-srcu-comment/kernel/srcu.c	2006-08-29 17:29:30.000000000 -0700
@@ -212,6 +212,25 @@ void synchronize_srcu(struct srcu_struct
 	 * More importantly, it also forces the corresponding SRCU read-side
 	 * critical sections to have also completed, and the corresponding
 	 * references to SRCU-protected data items to be dropped.
+	 *
+	 * Note:
+	 *
+	 *	Despite what you might think at first glance, the
+	 *	preceding synchronize_sched() -must- be within the
+	 *	critical section ended by the following mutex_unlock().
+	 *	Otherwise, a task taking the early exit can race
+	 *	with a srcu_read_unlock(), which might have executed
+	 *	just before the preceding srcu_readers_active() check,
+	 *	and whose CPU might have reordered the srcu_read_unlock()
+	 *	with the preceding critical section.  In this case, there
+	 *	is nothing preventing the synchronize_sched() task that is
+	 *	taking the early exit from freeing a data structure that
+	 *	is still being referenced (out of order) by the task
+	 *	doing the srcu_read_unlock().
+	 *
+	 *	Alternatively, the comparison with "2" on the early exit
+	 *	could be changed to "3", but this increases synchronize_srcu()
+	 *	latency for bulk loads.  So the current code is preferred.
 	 */
 
 	mutex_unlock(&sp->mutex);

      parent reply	other threads:[~2006-08-30  0:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-28 16:08 [PATCH 0/4] RCU: various merge candidates Dipankar Sarma
2006-08-28 16:10 ` [PATCH 1/4] RCU: split classic rcu Dipankar Sarma
2006-08-31  1:12   ` Paul E. McKenney
2006-08-28 16:11 ` [PATCH 2/4] RCU: use a separate softirq Dipankar Sarma
2006-08-31  1:13   ` Paul E. McKenney
2006-08-28 16:12 ` [PATCH 3/4] RCU: preemptible RCU implementation Dipankar Sarma
2006-08-28 20:46   ` Christoph Hellwig
2006-08-29  1:33     ` Dipankar Sarma
2006-08-28 16:13 ` [PATCH 4/4] RCU: clean up RCU trace Dipankar Sarma
2006-08-28 16:15 ` [PATCH 0/4] RCU: various merge candidates Arjan van de Ven
2006-08-28 16:29   ` Dipankar Sarma
2006-08-28 16:33     ` Arjan van de Ven
2006-08-28 16:43       ` Dipankar Sarma
2006-08-28 19:06 ` Andrew Morton
2006-08-28 19:16   ` Dipankar Sarma
2006-08-28 19:40     ` Andrew Morton
2006-08-29  0:23       ` Dipankar Sarma
2006-08-29  0:28         ` Andrew Morton
2006-08-30  0:40       ` Paul E. McKenney [this message]

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=20060830004055.GA2845@us.ibm.com \
    --to=paulmck@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=dipankar@in.ibm.com \
    --cc=josht@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=stern@rowland.harvard.edu \
    /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