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

From: Nikolay Aleksandrov
Date: Fri Aug 01 2014 - 08:28:07 EST


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@xxxxxxx>
> Acked-by: Patrick McHardy <kaber@xxxxxxxxx>
> ---
<<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

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