From: Nick Piggin <nickpiggin@yahoo.com.au>
To: paulmck@us.ibm.com
Cc: Paul McKenney <paul.mckenney@us.ibm.com>,
Dipankar Sarma <dipankar@in.ibm.com>, Ingo Molnar <mingo@elte.hu>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: [patch 5/7] radix-tree: lockless readside
Date: Fri, 12 Aug 2005 13:59:19 +1000 [thread overview]
Message-ID: <1123819159.5098.10.camel@npiggin-nld.site> (raw)
In-Reply-To: <20050812013703.GP1300@us.ibm.com>
On Thu, 2005-08-11 at 18:37 -0700, Paul E. McKenney wrote:
> On Thu, Aug 11, 2005 at 10:25:47PM +1000, Nick Piggin wrote:
> > 5/7
> >
> > --
> > SUSE Labs, Novell Inc.
> >
>
> > Make radix tree lookups safe to be performed without locks.
> > Readers are protected against nodes being deleted by using RCU
> > based freeing. Readers are protected against new node insertion
> > by using memory barriers to ensure the node itself will be
> > properly written before it is visible in the radix tree.
> >
> > Also introduce a lockfree gang_lookup_slot which will be used
> > by a future patch.
>
> Interesting approach! Don't claim to fully understand it, but
> see below (search for empty lines). In the meantime, some questions:
>
Thanks for comments and review - very helpful.
> o What exactly is RCU protecting? My first guess is that
> it protects the pointers and internal nodes of the
> radix tree, but not the objects in the leaves of the
> trees (in other words, the things pointed to by the
> return value from things like radix_tree_lookup_slot()).
>
Ah OK, this wasn't initially apparent to me either, however I
believe it is needed.
Indeed we are protecting the internal nodes of the radix tree,
however the speculative get operation needs to dereference a
*pointer* to the page. The `struct page` itself doesn't go away,
and thus doesn't need any protection. However the *pointer* can
go away - it is contained within a radix tree node.
> But if this really is the case, then the rcu_read_lock() &
> rcu_read_unlock() pairs can be pushed down into
> radix_tree_lookup_slot() and friends.
>
> o The current code structure would lead me to believe that
> page_cache_get_speculative() is protected by RCU, but
> I don't see the corresponding call_rcu() or synchronize_rcu()
> that would cause this protection to be required.
>
I believe this should answer your concern about the RCU protection
placement.
One thing we could do differently is this: instead of receiving
a pointer to the struct page from the radix tree lookup, we could
actually do as you say and push the rcu locking into the radix
tree lookup.
Then we would do a speculative get_page on that struct page,
finally we would lookup the radix tree again to see whether the
same page is still in the pagecache.
I discounted this idea not just for efficiency, but also because
it would require either a 2 phase speculative get (or a speculative
undo), or would require teaching speculative get about the pagecache
radix tree.
> > @@ -208,9 +219,13 @@ static int radix_tree_extend(struct radi
> > tag_set(node, tag, 0);
> > }
> >
> > + newheight = root->height+1;
> > + node->height = newheight;
> > node->count = 1;
> > + /* Make ->height visible before node visible via ->rnode */
>
> > + smp_wmb();
> > root->rnode = node;
>
> The prior two lines should instead be:
>
> rcu_assign_pointer(root->rnode, node);
>
Great, thanks very much.
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
next prev parent reply other threads:[~2005-08-12 3:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-11 12:18 [patch 0/7] lockless pagecache 2 Nick Piggin
2005-08-11 12:21 ` [patch 1/7] mm: remove PageReserved rollup Nick Piggin
2005-08-11 12:22 ` [patch 2/7] mm: PG_free flag Nick Piggin
2005-08-11 12:22 ` [patch 3/7] mm: speculative get_page Nick Piggin
2005-08-11 12:25 ` [patch 4/7] radix-tree: lookup_slot Nick Piggin
2005-08-11 12:25 ` [patch 5/7] radix-tree: lockless readside Nick Piggin
2005-08-11 12:28 ` [patch 6/7] mm: lockless pagecache Nick Piggin
2005-08-11 12:28 ` [patch 7/7] mm: spinlock tree_lock Nick Piggin
2005-08-11 13:58 ` [patch 6/7] mm: lockless pagecache Pekka Enberg
2005-08-11 14:06 ` Nick Piggin
2005-08-12 1:49 ` Paul E. McKenney
2005-08-12 4:04 ` Nick Piggin
2005-08-12 1:37 ` [patch 5/7] radix-tree: lockless readside Paul E. McKenney
2005-08-12 3:59 ` Nick Piggin [this message]
2005-08-12 4:38 ` Nick Piggin
2005-08-12 7:53 ` Nick Piggin
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=1123819159.5098.10.camel@npiggin-nld.site \
--to=nickpiggin@yahoo.com.au \
--cc=dipankar@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paul.mckenney@us.ibm.com \
--cc=paulmck@us.ibm.com \
/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®