[ovs-dev] [PATCH net-next 3/3] nftables: Convert nft_hash to use generic rhashtable

Nikolay Aleksandrov nikolay at redhat.com
Fri Aug 1 12:21:31 UTC 2014


On 08/01/2014 01:58 PM, Thomas Graf wrote:
> The sizing of the hash table and the practice of requiring a lookup
> to retrieve the pprev to be stored in the element cookie before the
> deletion of an entry is left intact.
> 
> Signed-off-by: Thomas Graf <tgraf at suug.ch>
> Acked-by: Patrick McHardy <kaber at trash.net>
> ---
<<snip>>
> @@ -257,36 +82,28 @@ static void nft_hash_elem_destroy(const struct nft_set *set,
>  static void nft_hash_remove(const struct nft_set *set,
>  			    const struct nft_set_elem *elem)
>  {
> -	struct nft_hash *priv = nft_set_priv(set);
> -	struct nft_hash_table *tbl = nft_dereference(priv->tbl);
> -	struct nft_hash_elem *he, __rcu **pprev;
> +	struct rhashtable *priv = nft_set_priv(set);
> +	struct rhash_head *he, __rcu **pprev;
>  
>  	pprev = elem->cookie;
> -	he = nft_dereference((*pprev));
> -
> -	RCU_INIT_POINTER(*pprev, he->next);
> -	synchronize_rcu();
> -	kfree(he);
> +	he = rht_dereference((*pprev), priv);
>  
> -	/* Shrink table beneath 30% load */
> -	if (set->nelems - 1 < tbl->size * 3 / 10 &&
> -	    tbl->size > NFT_HASH_MIN_SIZE)
> -		nft_hash_tbl_shrink(set, priv);
> +	rhashtable_remove_pprev(priv, he, pprev, GFP_KERNEL);
>  }
<<snip>>
Hi again,
Sorry for the late response but I just got around to check the 3rd patch now,
so my question about this fragment is: before nft_hash_remove() would free the
element after removal, but after this change I don't see where and when the
removed element would get freed ?

Nik




More information about the dev mailing list