Subject: Re: [PATCH net-next v3] rhashtable: Fix race in rhashtable_destroy() and use regular work_struct

From: Sergei Shtylyov <[email-masked]>
Date: Wed, 14 Jan 2015 16:25:50 +0300

Hello.

On 1/14/2015 12:37 PM, Ying Xue wrote:

> When we put our declared work task in the global workqueue with
> schedule_delayed_work(), its delay parameter is always zero.
> Therefore, we should define a regular work in rhashtable structure
> instead of a delayed work.

> By the way, we add a condition to check whether resizing functions
> are NULL before cancel the work, avoiding to cancel an uninitialized

    s/before cancel/before cancelling/.

> work.

[...]

> Fixes: 97defe1 ("rhashtable: Per bucket locks & deferred expansion/shrinking")
> Signed-off-by: Ying Xue <[email-masked]>
> Cc: Thomas Graf <[email-masked]>
> Acked-by: Thomas Graf <[email-masked]>

[...]

> diff --git a/lib/rhashtable.c b/lib/rhashtable.c
> index ed6ae1a..1f56189 100644
> --- a/lib/rhashtable.c
> +++ b/lib/rhashtable.c
[...]
> @@ -911,12 +911,11 @@ EXPORT_SYMBOL_GPL(rhashtable_init);
>   void rhashtable_destroy(struct rhashtable *ht)
>   {
>   	ht->being_destroyed = true;

    Empty line needed here.

> +	if (ht->p.grow_decision || ht->p.shrink_decision)
> +		cancel_work_sync(&ht->run_work);
>
>   	mutex_lock(&ht->mutex);
> -
> -	cancel_delayed_work(&ht->run_work);
>   	bucket_table_free(rht_dereference(ht->tbl, ht));
> -
>   	mutex_unlock(&ht->mutex);
>   }
>   EXPORT_SYMBOL_GPL(rhashtable_destroy);

WBR, Sergei