linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] workqueue: replace call_rcu with kfree_rcu
@ 2020-10-14  8:31 qiang.zhang
  2020-10-26 13:41 ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: qiang.zhang @ 2020-10-14  8:31 UTC (permalink / raw)
  To: tj, jiangshanlai; +Cc: linux-kernel

From: Zqiang <qiang.zhang@windriver.com>

The pwq's rcu callback func only to release 'pwq' resources,
can use 'kfree_rcu' instead of 'call_rcu' func.

Signed-off-by: Zqiang <qiang.zhang@windriver.com>
---
 kernel/workqueue.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ac088ce6059b..8d4fe649631a 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3653,11 +3653,6 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
 	return NULL;
 }
 
-static void rcu_free_pwq(struct rcu_head *rcu)
-{
-	kmem_cache_free(pwq_cache,
-			container_of(rcu, struct pool_workqueue, rcu));
-}
 
 /*
  * Scheduled on system_wq by put_pwq() when an unbound pwq hits zero refcnt
@@ -3683,7 +3678,7 @@ static void pwq_unbound_release_workfn(struct work_struct *work)
 	put_unbound_pool(pool);
 	mutex_unlock(&wq_pool_mutex);
 
-	call_rcu(&pwq->rcu, rcu_free_pwq);
+	kfree_rcu(pwq, rcu);
 
 	/*
 	 * If we're the last pwq going away, @wq is already dead and no one
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] workqueue: replace call_rcu with kfree_rcu
  2020-10-14  8:31 [PATCH] workqueue: replace call_rcu with kfree_rcu qiang.zhang
@ 2020-10-26 13:41 ` Tejun Heo
  0 siblings, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2020-10-26 13:41 UTC (permalink / raw)
  To: qiang.zhang; +Cc: jiangshanlai, linux-kernel

On Wed, Oct 14, 2020 at 04:31:45PM +0800, qiang.zhang@windriver.com wrote:
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index ac088ce6059b..8d4fe649631a 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -3653,11 +3653,6 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
>  	return NULL;
>  }
>  
> -static void rcu_free_pwq(struct rcu_head *rcu)
> -{
> -	kmem_cache_free(pwq_cache,
> -			container_of(rcu, struct pool_workqueue, rcu));
> -}
>  
>  /*
>   * Scheduled on system_wq by put_pwq() when an unbound pwq hits zero refcnt
> @@ -3683,7 +3678,7 @@ static void pwq_unbound_release_workfn(struct work_struct *work)
>  	put_unbound_pool(pool);
>  	mutex_unlock(&wq_pool_mutex);
>  
> -	call_rcu(&pwq->rcu, rcu_free_pwq);
> +	kfree_rcu(pwq, rcu);

kfree_rcu() eventually calls kfree() which is different from
kmem_cache_free(). It can only be used for kmalloc'd areas, not
kmem_cache_alloc'd ones.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] workqueue: replace call_rcu with kfree_rcu
@ 2020-10-14  8:20 Zqiang
  0 siblings, 0 replies; 3+ messages in thread
From: Zqiang @ 2020-10-14  8:20 UTC (permalink / raw)
  To: tj, jiangshanlai; +Cc: linux-kernel

The pwq's rcu callback func only to release 'pwq' resources,
can use 'kfree_rcu' instead of 'call_rcu' func.

Signed-off-by: Zqiang <qiang.zhang@windriver.com>
---
 kernel/workqueue.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ac088ce6059b..8d4fe649631a 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3653,11 +3653,6 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
 	return NULL;
 }
 
-static void rcu_free_pwq(struct rcu_head *rcu)
-{
-	kmem_cache_free(pwq_cache,
-			container_of(rcu, struct pool_workqueue, rcu));
-}
 
 /*
  * Scheduled on system_wq by put_pwq() when an unbound pwq hits zero refcnt
@@ -3683,7 +3678,7 @@ static void pwq_unbound_release_workfn(struct work_struct *work)
 	put_unbound_pool(pool);
 	mutex_unlock(&wq_pool_mutex);
 
-	call_rcu(&pwq->rcu, rcu_free_pwq);
+	kfree_rcu(pwq, rcu);
 
 	/*
 	 * If we're the last pwq going away, @wq is already dead and no one
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-26 13:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14  8:31 [PATCH] workqueue: replace call_rcu with kfree_rcu qiang.zhang
2020-10-26 13:41 ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2020-10-14  8:20 Zqiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).