Skip to content

Commit 7b42f40

Browse files
Zqianghtejun
authored andcommitted
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 <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent bd9e732 commit 7b42f40

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kernel/workqueue.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4610,8 +4610,12 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
46104610

46114611
enomem:
46124612
if (wq->cpu_pwq) {
4613-
for_each_possible_cpu(cpu)
4614-
kfree(*per_cpu_ptr(wq->cpu_pwq, cpu));
4613+
for_each_possible_cpu(cpu) {
4614+
struct pool_workqueue *pwq = *per_cpu_ptr(wq->cpu_pwq, cpu);
4615+
4616+
if (pwq)
4617+
kmem_cache_free(pwq_cache, pwq);
4618+
}
46154619
free_percpu(wq->cpu_pwq);
46164620
wq->cpu_pwq = NULL;
46174621
}

0 commit comments

Comments
 (0)