Skip to contentSkip to conversation

workqueue: Remove duplicate worqueue attributes allocation

PATCH In review Catalin Marinas 4 participants 4 messages Sep 6, 2023 – Sep 18, 2023 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 workqueue: Remove duplicate worqueue attributes allocation

Commit 84193c07105c ("workqueue: Generalize unbound CPU pods") inadvertently introduced another call to alloc_workqueue_attrs() overriding the pointer returned by a previous alloc_workqueue_attrs() a few lines up in workqueue_init_early(). This leads to a kmemleak report:

unreferenced object 0xffff000040015000 (size 96):
comm "swapper/0", pid 0, jiffies 4294892296 (age 163.956s) hex dump (first 32 bytes):

    00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<000000004cec0d50>] __kmem_cache_alloc_node+0x1c4/0x288
    [<0000000083361c2a>] kmalloc_trace+0x20/0x2c
    [<000000005ca61f11>] workqueue_init_early+0xe4/0x538
    [<000000004e6ea358>] start_kernel+0x23c/0x5ec
    [<00000000aea9761e>] __primary_switched+0xbc/0xc4

Remove the first allocation.

Fixes 84193c07105c ("workqueue: Generalize unbound CPU pods")
Cc Tejun Heo <[email protected]>

---

I've seen this mentioned by Sandeep as well but I couldn't find a patch, so here it is.

https://lore.kernel.org/r/CAB=BE-S=cxewXu7nqJY1DC5w9Bapar_C0cTjpZOQ-Qd5GGwYyw@mail.gmail.com/

 kernel/workqueue.c | 3 ---
 1 file changed, 3 deletions(-)
kernel/workqueue.c +0 -3
index c85825e17df8..43ab8399b72b 100644
@@ -6524,9 +6524,6 @@ void __init workqueue_init_early(void)
 
 	pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC);
 
-	wq_update_pod_attrs_buf = alloc_workqueue_attrs();
-	BUG_ON(!wq_update_pod_attrs_buf);
-
 	/* initialize WQ_AFFN_SYSTEM pods */
 	pt->pod_cpus = kcalloc(1, sizeof(pt->pod_cpus[0]), GFP_KERNEL);
 	pt->pod_node = kcalloc(1, sizeof(pt->pod_node[0]), GFP_KERNEL);
Tested-by on v1 1/1
#2 lore raw
In reply to Catalin Marinas

Hi Catalin,

Quoted 17 lines · Catalin Marinas

Commit 84193c07105c ("workqueue: Generalize unbound CPU pods") inadvertently introduced another call to alloc_workqueue_attrs() overriding the pointer returned by a previous alloc_workqueue_attrs() a few lines up in workqueue_init_early(). This leads to a kmemleak report:

unreferenced object 0xffff000040015000 (size 96):
comm "swapper/0", pid 0, jiffies 4294892296 (age 163.956s) hex dump (first 32 bytes):

    00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<000000004cec0d50>] __kmem_cache_alloc_node+0x1c4/0x288
    [<0000000083361c2a>] kmalloc_trace+0x20/0x2c
    [<000000005ca61f11>] workqueue_init_early+0xe4/0x538
    [<000000004e6ea358>] start_kernel+0x23c/0x5ec
    [<00000000aea9761e>] __primary_switched+0xbc/0xc4
Quoted 1 line

Remove the first allocation.

Thank you for having shared this patch!

We had the same issue when validating MPTCP tree and your patch fixes the problem on our side:

Cheers,
Matt

Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
maintainer
#3 lore raw
In reply to Catalin Marinas
Quoted 17 lines · Catalin Marinas

Commit 84193c07105c ("workqueue: Generalize unbound CPU pods") inadvertently introduced another call to alloc_workqueue_attrs() overriding the pointer returned by a previous alloc_workqueue_attrs() a few lines up in workqueue_init_early(). This leads to a kmemleak report:

unreferenced object 0xffff000040015000 (size 96):
comm "swapper/0", pid 0, jiffies 4294892296 (age 163.956s) hex dump (first 32 bytes):

    00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<000000004cec0d50>] __kmem_cache_alloc_node+0x1c4/0x288
    [<0000000083361c2a>] kmalloc_trace+0x20/0x2c
    [<000000005ca61f11>] workqueue_init_early+0xe4/0x538
    [<000000004e6ea358>] start_kernel+0x23c/0x5ec
    [<00000000aea9761e>] __primary_switched+0xbc/0xc4
Quoted 5 lines

Remove the first allocation.

Fixes 84193c07105c ("workqueue: Generalize unbound CPU pods")
Cc Tejun Heo <[email protected]>

Another version of this patch has been applied to wq/for-6.6-fixes.

Thanks.

Signature · 1 line
tejun