Skip to contentSkip to conversation

mm/kmemleak: Fix percpu memory leak detection failure

PATCH Applied Guo Weikang 3 participants 5 messages Dec 27, 2024 – Dec 31, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/kmemleak: Fix percpu memory leak detection failure

kmemleak_alloc_percpu gives an incorrect min_count parameter, causing percpu memory to be considered a gray object.

Fixes 8c8685928910 ("mm/kmemleak: use IS_ERR_PCPU() for pointer in the percpu address space")
---
 mm/kmemleak.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kmemleak.c +1 -1
index 238ab733fbea..982bb5ef3233 100644
@@ -1093,7 +1093,7 @@ void __ref kmemleak_alloc_percpu(const void __percpu *ptr, size_t size,
 	pr_debug("%s(0x%px, %zu)\n", __func__, ptr, size);
 
 	if (kmemleak_enabled && ptr && !IS_ERR_PCPU(ptr))
-		create_object_percpu((__force unsigned long)ptr, size, 0, gfp);
+		create_object_percpu((__force unsigned long)ptr, size, 1, gfp);
 }
 EXPORT_SYMBOL_GPL(kmemleak_alloc_percpu);
 
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Guo Weikang

kmemleak_alloc_percpu gives an incorrect min_count parameter, causing percpu memory to be considered a gray object.

Fixes 8c8685928910 ("mm/kmemleak: use IS_ERR_PCPU() for pointer in the percpu address space")

I don't know how 1 turned to 0, the change was definitely unintended.

Thanks,
Uros.

Quoted 20 lines
---
 mm/kmemleak.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kmemleak.c +1 -2
index 238ab733fbea..982bb5ef3233 100644
@@ -1093,7 +1093,7 @@ void __ref kmemleak_alloc_percpu(const void __percpu *ptr, size_t size,
        pr_debug("%s(0x%px, %zu)\n", __func__, ptr, size);
 
        if (kmemleak_enabled && ptr && !IS_ERR_PCPU(ptr))
-               create_object_percpu((__force unsigned long)ptr, size, 0, gfp);
+               create_object_percpu((__force unsigned long)ptr, size, 1, gfp);
 }
 EXPORT_SYMBOL_GPL(kmemleak_alloc_percpu);
 
--

2.25.1

#2 lore raw
Quoted 4 lines · Uros Bizjak
Quoted 1 line · Guo Weikang
Quoted 8 lines
Quoted 6 lines

kmemleak_alloc_percpu gives an incorrect min_count parameter, causing percpu memory to be considered a gray object.

Fixes 8c8685928910 ("mm/kmemleak: use IS_ERR_PCPU() for pointer in the percpu address space")

I don't know how 1 turned to 0, the change was definitely unintended.

Looking at the original patch at [1], it looks like a mismerge to me.

[1] https://lore.kernel.org/all/[email protected]/T/#u

Uros.

maintainer
#3 lore raw
Quoted 8 lines · Uros Bizjak
Quoted 7 lines · Uros Bizjak
Quoted 5 lines · Guo Weikang

kmemleak_alloc_percpu gives an incorrect min_count parameter, causing percpu memory to be considered a gray object.

Fixes 8c8685928910 ("mm/kmemleak: use IS_ERR_PCPU() for pointer in the percpu address space")
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I don't know how 1 turned to 0, the change was definitely unintended.

Looking at the original patch at [1], it looks like a mismerge to me.

[1] https://lore.kernel.org/all/[email protected]/T/#u

About the same time we had commit 6c99d4eb7c5e ("kmemleak: enable tracking for percpu pointers") increasing min_count to 1 but in the merge this got lost.

Signature · 1 line
Catalin