All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: "Theodore Y. Ts'o" <tytso@mit.edu>,
	"Joel Fernandes (Google)" <joel@joelfernandes.org>,
	linux-kernel@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
	Josh Triplett <josh@joshtriplett.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	linux-doc@vger.kernel.org,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	pantin@google.com
Subject: Re: [PATCH RFC 0/5] rcu doc updates for whatisRCU and checklist
Date: Sat, 6 Oct 2018 09:49:33 -0700	[thread overview]
Message-ID: <20181006164933.GP2674@linux.ibm.com> (raw)
In-Reply-To: <20181006053446.GA2529@thunk.org>

On Sat, Oct 06, 2018 at 01:34:46AM -0400, Theodore Y. Ts'o wrote:
> On Fri, Oct 05, 2018 at 08:45:40PM -0700, Paul E. McKenney wrote:
> > 
> > Shouldn't the synchronize_rcu() precede the loop doing the kfree()
> > calls?  Or am I missing something subtle?
> 
> No, that was a cut and paste error on my part.  I was removing the
> rcu_read_unlock() before the kfree loop, and accidentally removed the
> synchronize_rcu().  Then when I put it back, I put it back in the
> right place.

Been there, done that!  ;-)

> The longer version:
> 
> I originally used rcu_read_lock() and rcu_read_unlock() around setting
> up to_free[] --- since whatisRCU.txt didn't talk about
> rcu_derefence_proctected(), just rcu_dereference() in Section 2: "What
> is RCU's Core API?"   
> 
> Then when I looked at the example in Section 3, I was surprised when I
> didn't see the rcu_read_[un]lock() on the updater side, and spent some
> time trying to figure out how to use rcu_dereference_protected().
> 
> Then when I did the transumation from
> rcu_read_lock/rcu_dereference_protected/rcu_read_unlock to
> rcu_dereference_protected, I bobbled the location of
> synchronize_rcu().
> 
> 						- Ted
> 
> P.S.  Pedagogically, it might make sense to show an example that only
> uses the RCU core API --- I assume using rcu_read_[un]lock() and
> rcu_dereference() does work; it's just non-optimal, right?  --- and
> then introduce the use of rcu_dereference_protected() afterwards.

Yes, you can use rcu_dereference() on the update side and dispense
with rcu_dereference_protected(), but that will require you to add an
otherwise useless rcu_read_lock()/rcu_read_unlock() pair when accessing
the pointer on the update side.

Furthermore, if you are OK leaking memory rather than freeing it (which
is admittedly quite rare, but does sometimes happen), then yes, you
don't need call_rcu(), synchronize_rcu(), and friends.

So it is as you say, functional but non-optimal.

							Thanx, Paul


  reply	other threads:[~2018-10-06 16:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05 23:18 [PATCH RFC 0/5] rcu doc updates for whatisRCU and checklist Joel Fernandes (Google)
2018-10-05 23:18 ` [PATCH RFC 1/5] doc: rcu: Update core and full API in whatisRCU Joel Fernandes (Google)
2018-10-05 23:18 ` [PATCH RFC 2/5] doc: rcu: Add more rationale for using rcu_read_lock_sched in checklist Joel Fernandes (Google)
2018-10-05 23:18 ` [PATCH RFC 3/5] doc: rcu: Remove obsolete suggestion from checklist Joel Fernandes (Google)
2018-10-05 23:18 ` [PATCH RFC 4/5] doc: rcu: Remove obsolete checklist item about synchronize_rcu usage Joel Fernandes (Google)
2018-10-05 23:18 ` [PATCH RFC 5/5] doc: rcu: Encourage use of rcu_barrier in checklist Joel Fernandes (Google)
2018-10-05 23:46 ` [PATCH RFC 0/5] rcu doc updates for whatisRCU and checklist Theodore Y. Ts'o
2018-10-06  1:59   ` Joel Fernandes
2018-10-06  3:45   ` Paul E. McKenney
2018-10-06  4:40     ` Joel Fernandes
2018-10-06 22:47       ` Theodore Y. Ts'o
2018-10-06  4:50     ` Joel Fernandes
2018-10-06  5:34     ` Theodore Y. Ts'o
2018-10-06 16:49       ` Paul E. McKenney [this message]
2018-10-06  0:13 ` Paul E. McKenney
2018-10-06  2:10   ` Joel Fernandes

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=20181006164933.GP2674@linux.ibm.com \
    --to=paulmck@linux.ibm.com \
    --cc=corbet@lwn.net \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=pantin@google.com \
    --cc=rostedt@goodmis.org \
    --cc=tytso@mit.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.