Skip to content

Commit

Permalink
workqueue: Use the kmem_cache_free() instead of kfree() to release pwq
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zqiang authored and Tejun Heo committed Oct 12, 2023
1 parent bd9e732 commit 7b42f40
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7b42f40

Please sign in to comment.