From: Waiman Long <waiman.long@hp.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
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>
Subject: Re: [PATCH] dcache: Translating dentry into pathname without taking rename_lock
Date: Wed, 04 Sep 2013 22:17:04 -0400 [thread overview]
Message-ID: <5227E9A0.9020802@hp.com> (raw)
In-Reply-To: <CA+55aFzbzz4_YNaM+9jAP2Znkjzar42iTM2wFfRX6ySDwBAUeQ@mail.gmail.com>
On 09/04/2013 05:31 PM, Linus Torvalds wrote:
> On Wed, Sep 4, 2013 at 12:05 PM, Waiman Long<Waiman.Long@hp.com> wrote:
>> + rcu_read_unlock();
>> + if (read_seqretry(&rename_lock, seq))
>> + goto restart;
> Btw, you have this pattern twice, and while it's not necessarily
> incorrect, it's a bit worrisome for performance.
The rcu_read_unlock sequence in the middle of prepend_path() is not
likely to executed. So it shouldn't affect performance exception for the
conditional check.
> The rcu_read_unlock() is very possibly going to trigger an immediate
> scheduling event, so checking the sequence lock after dropping the
> read-lock sounds like it would make it much easier to hit the race
> with some rename.
I can put read_seqbegin/read_seqretry within the
rcu_read_lock/rcu_read_unlock block. However, read_seqbegin() can spin
for a while if a rename is in progress. So it depends on which is more
important, a shorter RCU critical section at the expense of more retries
or vice versa.
> I'm also a tiny bit worried about livelocking on the sequence lock in
> the presence of lots of renames, so I'm wondering if the locking
> should try to approximate what we do for the RCU lookup path: start
> off optimistically using just the RCU lock and a sequence point, but
> if that fails, fall back to taking the real lock. Maybe using a
> counter ("try twice, then get the rename lock for writing")
>
> Hmm?
Yes, I can implement a counter that switch to taking the rename_lock if
the count reaches 0. It shouldn't be too hard. That should avoid the
possibility of a livelock.
Longman
next prev parent reply other threads:[~2013-09-05 2:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-04 19:05 [PATCH] dcache: Translating dentry into pathname without taking rename_lock Waiman Long
2013-09-04 19:11 ` Al Viro
2013-09-04 19:33 ` Waiman Long
2013-09-04 19:43 ` Al Viro
2013-09-05 1:55 ` Waiman Long
2013-09-05 2:42 ` Al Viro
[not found] ` <CA+55aFwW+hWwQd8+NgukSidHbf2bnd6QO0yKK9NAgX+9rt0cOQ@mail.gmail.com>
[not found] ` <5227E321.4090008@hp.com>
2013-09-05 2:48 ` Linus Torvalds
2013-09-05 4:20 ` Al Viro
2013-09-04 19:26 ` Waiman Long
2013-09-04 20:40 ` John Stoffel
2013-09-05 2:04 ` Waiman Long
2013-09-05 13:29 ` John Stoffel
2013-09-05 17:28 ` Waiman Long
2013-09-04 21:31 ` Linus Torvalds
2013-09-05 2:17 ` Waiman Long [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-09-05 4:30 George Spelvin
2013-09-05 17:06 ` Waiman Long
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=5227E9A0.9020802@hp.com \
--to=waiman.long@hp.com \
--cc=aswin@hp.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=scott.norton@hp.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).