From: Paul Mackerras <paulus@ozlabs.org>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
Steven Rostedt <rostedt@goodmis.org>,
David Gibson <david@gibson.dropbear.id.au>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH kernel] rcu: Define lockless version of list_for_each_entry_rcu
Date: Mon, 30 Nov 2015 10:39:15 +1100 [thread overview]
Message-ID: <20151129233915.GA8991@fergus.ozlabs.ibm.com> (raw)
In-Reply-To: <20151118191328.GK5184@linux.vnet.ibm.com>
On Wed, Nov 18, 2015 at 11:13:28AM -0800, Paul E. McKenney wrote:
> On Fri, Nov 06, 2015 at 01:17:17PM +1100, Alexey Kardashevskiy wrote:
[snip]
> > Still, is my approach correct? What does the comment for
> > lockless_dereference() actally mean - it won't work together with
> > RCU at all or this is to force people not to use it as
> > "list_for_each_entry_rcu() should really be used in 99.99% of the
> > time"? :)
>
> Well, it depends...
>
> The key difference between lockless_dereference() and rcu_dereference()
> is that lockless_dereference() won't complain if used outside of
> an RCU read-side critical section. When there is no RCU read-side
> critical section, lockless_dereference() cannot rely on RCU's normal
> action of keeping the data item around. Therefore, when you are using
> lockless_dereference(), you have to have some mechanism other than RCU
> to keep the data item around. The usual approach is for the data item
> to never be freed, for example, if data is only ever added to the list
> and never removed. Other approaches include reference counting, hazard
> pointers, hashed arrays of locks, garbage collectors, transactional
> memory, and so on.
So, the situation is that we have an RCU-protected list, which in this
case we are traversing without modifying the list. We are in an
restricted environment (hypervisor real mode) where we can't be
preempted, both because interrupts are hard-disabled and because our
caller has done preempt_disable(). In this restricted environment we
can access the linear mapping (thus kmalloc'd data) but not the
vmalloc or ioremap regions.
Thus we are not formally in a RCU read-side critical section, though
we believe that having preemption disabled gives us equivalent
protection. Probably what we should do is to add a
rcu_read_lock/unlock pair in a function higher up the call chain
so that we are actually in a RCU read-side critical section.
Then the only reason not to use list_for_each_entry_rcu would be that
we don't trust the checking machinery not to ever access vmalloc'd
data. In other words, we want a list_for_each_entry_nocheck
or list_for_each_entry_restricted which omits all the lockdep
checking. That would need a list_entry_rcu_nocheck which would need a
thing like rcu_dereference_raw that does no lockdep checking - which
is where I thought you suggested lockless_dereference.
So, what name do you like for these primitives, and where should they
go?
Thanks,
Paul.
next prev parent reply other threads:[~2015-11-29 23:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 6:57 Alexey Kardashevskiy
2015-11-03 14:39 ` Steven Rostedt
2015-11-06 2:17 ` Alexey Kardashevskiy
2015-11-18 19:13 ` Paul E. McKenney
2015-11-29 23:39 ` Paul Mackerras [this message]
2015-11-30 20:30 ` Paul E. McKenney
2015-12-06 2:19 ` Paul E. McKenney
2015-12-08 5:20 ` Paul Mackerras
2015-12-08 5:46 ` Paul E. McKenney
2015-12-22 7:08 ` Alexey Kardashevskiy
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=20151129233915.GA8991@fergus.ozlabs.ibm.com \
--to=paulus@ozlabs.org \
--cc=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
/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
all inboxes | Powered by JetHome®