mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Dave Chinner <david@fromorbit.com>
Cc: viro@ZenIV.linux.org.uk, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com
Subject: Re: [PATCH 4/4] fs: rcu protect inode hash lookups
Date: Mon, 08 Nov 2010 09:53:41 +0100	[thread overview]
Message-ID: <1289206421.2820.32.camel@edumazet-laptop> (raw)
In-Reply-To: <1289201305-14866-5-git-send-email-david@fromorbit.com>

Le lundi 08 novembre 2010 à 18:28 +1100, Dave Chinner a écrit :
> From: Dave Chinner <dchinner@redhat.com>
> 
> Now that inodes are using RCU freeing, we can walk the hash lists
> using RCU protection during lookups. Convert all the hash list
> operations to use RCU-based operators and drop the inode_hash_lock
> around pure lookup operations.
> 
> Because we are using SLAB_DESTROY_BY_RCU, we need to be careful
> about the lockless lookups and the way we initialise the struct
> inode during allocation. The inode->i_lock is the critical item we
> need to avoid touching when allocating an inode, so move the
> initialisation of this lock to the slab constructor so that we can
> reliably use the lock even after the inode has been freed or is in
> the process of being allocated or initialised.
> 
> We also need to change the order of checks during hash lookups to
> validate we have an active inode before we skip it. That means we
> need to revalidate the inode number and superblock after we have
> checked it for being freed or unhashed under the inode->i_lock.
> 
> Finally, during traversals an inode can be freed and reallocated and
> linked into a new hash chain, so an RCU safe traversal can jump to a
> different chain without indication. On a cache miss we need to
> validate that we ended the search on the same hash chain we started
> on. Do this by converting the hash lists to the hlist_null list type
> and checking the list null on walk termination.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---

Very nice stuff Dave !

I have one question

> diff --git a/include/linux/list_nulls.h b/include/linux/list_nulls.h
> index 5d10ae36..29762d1 100644
> --- a/include/linux/list_nulls.h
> +++ b/include/linux/list_nulls.h
> @@ -83,6 +83,13 @@ static inline void hlist_nulls_del(struct hlist_nulls_node *n)
>  	n->pprev = LIST_POISON2;
>  }
>  
> +/* after that we'll appear to be on some hlist and hlist_nulls_del will work */
> +static inline void hlist_nulls_add_fake(struct hlist_nulls_node *n)
> +{
> +	n->next = (struct hlist_nulls_node *)1UL;
> +	n->pprev = &n->next;
> +}
> +


I am not sure why you need to change n->next here ?

This might restart lookups (making them doing a 'goto repeat', and
possibly abort a lookup on slot 0 of hash chain, since this is a 'nulls'
value for slot 0.

So at least I suggest adding a comment, and possibly use a different
slot number (outside of slot ranges). If so, change documentation to
restrict to 2^(BITS_PER_LONG-2) number of possible slots in hash table.

n->next = (struct hlist_nulls_node *)(1UL | (1UL << (BITS_PER_LONG-1));




  reply	other threads:[~2010-11-08  8:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-08  7:28 fs: inode rcu freeing and hash walking V2 Dave Chinner
2010-11-08  7:28 ` [PATCH 1/4] fs: pull inode->i_lock up out of writeback_single_inode Dave Chinner
2010-11-08  7:28 ` [PATCH 2/4] fs: Convert inode slab creation to use consistent parameters Dave Chinner
2011-04-25 17:46   ` Christoph Hellwig
2010-11-08  7:28 ` [PATCH 3/4] fs: Use RCU freeing of inodes via SLAB_DESTROY_BY_RCU Dave Chinner
2010-11-08  7:28 ` [PATCH 4/4] fs: rcu protect inode hash lookups Dave Chinner
2010-11-08  8:53   ` Eric Dumazet [this message]
2010-11-08 11:10   ` Christoph Hellwig

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=1289206421.2820.32.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --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

all inboxes | Powered by JetHome®