lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 08 Nov 2010 09:53:41 +0100
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Dave Chinner <david@...morbit.com>
Cc:	viro@...IV.linux.org.uk, linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org, paulmck@...ux.vnet.ibm.com
Subject: Re: [PATCH 4/4] fs: rcu protect inode hash lookups

Le lundi 08 novembre 2010 à 18:28 +1100, Dave Chinner a écrit :
> From: Dave Chinner <dchinner@...hat.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@...hat.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));



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists