linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dipankar Sarma <dipankar@in.ibm.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Andrew Morton <akpm@digeo.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	viro@math.psu.edu, Maneesh Soni <maneesh@in.ibm.com>
Subject: Re: 2.5.56-mm1
Date: Mon, 13 Jan 2003 11:55:03 +0530	[thread overview]
Message-ID: <20030113062503.GA14996@in.ibm.com> (raw)
In-Reply-To: <20030111225756.GA13330@gtf.org>

On Sat, Jan 11, 2003 at 11:00:38PM +0000, Jeff Garzik wrote:
> On Sat, Jan 11, 2003 at 02:43:08PM -0800, Andrew Morton wrote:
> > - dcache-RCU.
> > 
> >   This was recently updated to fix a rename race.  It's quite stable.  I'm
> >   not sure where we stand wrt merging it now.  Al seems to have disappeared.
> 
> I talked to him in person last week, and this was one of the topics of
> discussion.  He seemed to think it was fundamentally unfixable.  He
> proceed to explain why, and then explained the scheme he worked out to
> improve things.  Unfortunately my memory cannot do justice to the
> details.

The rename race is fixed now. Yes, it was unfixable using *existing* RCU
techniques, but one has to invent new tricks when the old bag of
tricks is empty :)

Fundamentally what happens is that rename may be *two* updates - delete
from one hash chain and insert into another hash chain. In order for
lockfree traversal to work correctly, you must have a grace period after
each update. If we do a grace period between these two updates in a rename,
it slows down renames to unacceptable levels. So we had a problem there.

The solution lies in the dcache itself - it has a fast path (cached_lookup)
and a slow path (real_lookup). So all we had to do was to detect that a
rename had happened to the dentry while we looked it up lockfree. This
is done by a generation counter (d_move_count) in the dentry and is
protected by the per-dentry spinlock which we take during rename and
a successful cache lookup. 

Two things can happen due to the rename race - lookup incorrectly succeeds
or lookup incorrectly fails. The success case is easily handled by 
the lockfree lookup code that looks like this -

for the dentries in the hash chain {
	... More stuff....
	move_count = dentry->d_move_count;
	if (dentry name matches) {
		/* lookup succeeds */
		spin_lock(&dentry->d_lock);
		if (move_count != dentry->d_move_count) {
			/* 
			 * A rename happened while looking up lockfree and 
			 * we now cannot gurantee
			 * that the lookup is correct
			 */
			spin_unlock(&dentry->d_lock);
			return slow_lookup();
		}
		....
		....
	}
	... More stuff....
}

If the lookup fails due to rename race, then there will anyway be a
slow real_lookup which is serialized with rename.

Maneesh did a lot of testing using many ramfs and many millions of renames
with millions of lookups going on at the same time and slow path was hit only
100 times or so. For practical workloads, this should have absolutely no
performance impact.

Thanks
Dipankar
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

  reply	other threads:[~2003-01-13  6:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-11 22:43 2.5.56-mm1 Andrew Morton
2003-01-11 22:57 ` 2.5.56-mm1 Jeff Garzik
2003-01-13  6:25   ` Dipankar Sarma [this message]
2003-01-13 10:41 ` 2.5.56-mm1 William Lee Irwin III

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=20030113062503.GA14996@in.ibm.com \
    --to=dipankar@in.ibm.com \
    --cc=akpm@digeo.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maneesh@in.ibm.com \
    --cc=viro@math.psu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox