aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZqiang <qiang.zhang1211@gmail.com>2023-10-11 16:27:59 +0800
committerTejun Heo <tj@kernel.org>2023-10-12 07:34:07 -1000
commit7b42f401fc6571b6604441789d892d440829e33c (patch)
tree7a658c200e6face61e064eadf5c87a887427348b
parentbd9e7326b8d512ee724006d4ec06dfbf3096ae9e (diff)
downloadubifs-7b42f401fc6571b6604441789d892d440829e33c.tar.gz
workqueue: Use the kmem_cache_free() instead of kfree() to release pwq
Currently, the kfree() be used for pwq objects allocated with kmem_cache_alloc() in alloc_and_link_pwqs(), this isn't wrong. but usually, use "trace_kmem_cache_alloc/trace_kmem_cache_free" to track memory allocation and free. this commit therefore use kmem_cache_free() instead of kfree() in alloc_and_link_pwqs() and also consistent with release of the pwq in rcu_free_pwq(). Signed-off-by: Zqiang <qiang.zhang1211@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--kernel/workqueue.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ebe24a5e143510..6f74cab2bd5af3 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4610,8 +4610,12 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
enomem:
if (wq->cpu_pwq) {
- for_each_possible_cpu(cpu)
- kfree(*per_cpu_ptr(wq->cpu_pwq, cpu));
+ for_each_possible_cpu(cpu) {
+ struct pool_workqueue *pwq = *per_cpu_ptr(wq->cpu_pwq, cpu);
+
+ if (pwq)
+ kmem_cache_free(pwq_cache, pwq);
+ }
free_percpu(wq->cpu_pwq);
wq->cpu_pwq = NULL;
}