From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Waiman Long <Waiman.Long@hp.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"Chandramouleeswaran, Aswin" <aswin@hp.com>,
"Norton, Scott J" <scott.norton@hp.com>,
George Spelvin <linux@horizon.com>,
John Stoffel <john@stoffel.org>
Subject: Re: [PATCH v4 1/1] dcache: Translating dentry into pathname without taking rename_lock
Date: Mon, 9 Sep 2013 19:06:04 +0100 [thread overview]
Message-ID: <20130909180604.GO13318@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CA+55aFx_pUwHg35Ueb4Ewy8ZrBA_UtFbQqdRzL64_Q7iQ=V-rA@mail.gmail.com>
On Mon, Sep 09, 2013 at 10:45:38AM -0700, Linus Torvalds wrote:
> On Mon, Sep 9, 2013 at 10:29 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > I'm not sure I like mixing rcu_read_lock() into that - d_path() and friends
> > can do that themselves just fine (it needs to be taken when seq is even),
> > and e.g. d_walk() doesn't need it at all. Other than that, I'm OK with
> > this variant.
>
> Hmm.. I think you need the RCU read lock even when you get the write_seqlock().
>
> Yes, getting the seqlock for write implies that you get a spinlock and
> in many normal circumstances that basically is equvalent to being
> rcu-locked, but afaik in some configurations that is *not* sufficient
> protection against an RCU grace period on another CPU. You need to do
> a real rcu_read_lock that increments that whole rcu_read_lock_nesting
> level, which a spinlock won't do.
>
> And while the rename sequence lock protects against _renames_, it does
> not protect against just plain dentries getting free'd under memory
> pressure.
It protects the chain of ->d_parent, so they'd better not get freeds at
all...
> So I think the RCU-readlockness really needs to be independent of the
> sequence lock.
Actually, now that I've tried to convert d_walk() to those guys, I think
I like my proposal for the set of primitives better:
static inline bool seqretry_and_lock(seqlock_t *lock, unsigned *seq):
{
if ((*seq & 1) || !read_seqretry(lock, *seq))
return true;
*seq |= 1;
write_seqlock(lock);
return false;
}
static inline void seqretry_done(seqlock_t *lock, unsigned seq)
{
if (seq & 1)
write_sequnlock(lock);
}
with the prepend_path() and friends becoming
rcu_read_lock();
seq = read_seqbegin(&rename_lock);
again:
....
if (!seqretry_and_lock(&rename_lock, seq))
goto again; /* now as writer */
seqretry_done(&rename_lock, seq);
rcu_read_unlock();
The thing is, d_walk() does essentially
seq = read_seqbegin(&rename_lock);
again:
....
spin_lock(&d->d_lock);
if (!seqretry_and_lock(&rename_lock, seq)) {
spin_unlock(&d->d_lock);
goto again; /* now as writer */
}
/* now we are holding ->d_lock on it and we know
* that d has not gone stale until that point.
*/
do stuff with d
spin_unlock(&d->d_lock);
seqretry_done(&rename_lock, seq);
OTOH, it's not impossible to handle with Waiman's primitives, just more
massage to do that...
next prev parent reply other threads:[~2013-09-09 18:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-09 16:18 [PATCH v4 0/1] dcache: Translating dentry into pathname without taking rename_lock Waiman Long
2013-09-09 16:18 ` [PATCH v4 1/1] " Waiman Long
2013-09-09 17:29 ` Al Viro
2013-09-09 17:45 ` Linus Torvalds
2013-09-09 17:56 ` Waiman Long
2013-09-09 18:06 ` Al Viro [this message]
2013-09-09 18:15 ` Linus Torvalds
2013-09-09 18:21 ` Al Viro
2013-09-09 18:36 ` Al Viro
2013-09-09 18:46 ` Al Viro
2013-09-09 18:46 ` Waiman Long
2013-09-09 19:10 ` Al Viro
2013-09-09 19:28 ` Al Viro
2013-09-09 22:57 ` Waiman Long
2013-09-10 0:40 ` George Spelvin
2013-09-10 0:57 ` Al Viro
2013-09-10 1:15 ` Ramkumar Ramachandra
2013-09-10 1:34 ` Linus Torvalds
2013-09-10 2:25 ` Al Viro
2013-09-10 2:33 ` Linus Torvalds
2013-09-10 3:12 ` Ramkumar Ramachandra
2013-09-10 8:24 ` George Spelvin
2013-09-10 3:57 ` Waiman Long
2013-09-09 17:55 ` Waiman Long
2013-09-09 18:07 ` Al Viro
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=20130909180604.GO13318@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=Waiman.Long@hp.com \
--cc=aswin@hp.com \
--cc=john@stoffel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@horizon.com \
--cc=scott.norton@hp.com \
--cc=torvalds@linux-foundation.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 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.