Skip to content

Commit 993f57e

Browse files
Zhaoyang Huangakpm00
authored andcommitted
mm: use stack_depot_early_init for kmemleak
Mirsad report the below error which is caused by stack_depot_init() failure in kvcalloc. Solve this by having stackdepot use stack_depot_early_init(). On 1/4/23 17:08, Mirsad Goran Todorovac wrote: I hate to bring bad news again, but there seems to be a problem with the output of /sys/kernel/debug/kmemleak: [root@pc-mtodorov ~]# cat /sys/kernel/debug/kmemleak unreferenced object 0xffff951c118568b0 (size 16): comm "kworker/u12:2", pid 56, jiffies 4294893952 (age 4356.548s) hex dump (first 16 bytes): 6d 65 6d 73 74 69 63 6b 30 00 00 00 00 00 00 00 memstick0....... backtrace: [root@pc-mtodorov ~]# Apparently, backtrace of called functions on the stack is no longer printed with the list of memory leaks. This appeared on Lenovo desktop 10TX000VCR, with AlmaLinux 8.7 and BIOS version M22KT49A (11/10/2022) and 6.2-rc1 and 6.2-rc2 builds. This worked on 6.1 with the same CONFIG_KMEMLEAK=y and MGLRU enabled on a vanilla mainstream kernel from Mr. Torvalds' tree. I don't know if this is deliberate feature for some reason or a bug. Please find attached the config, lshw and kmemleak output. [[email protected]: remove stack_depot_init() call] Link: https://lore.kernel.org/all/[email protected]/ Link: https://lkml.kernel.org/r/[email protected] Fixes: 56a6161 ("mm: use stack_depot for recording kmemleak's backtrace") Reported-by: Mirsad Todorovac <[email protected]> Suggested-by: Vlastimil Babka <[email protected]> Signed-off-by: Zhaoyang Huang <[email protected]> Acked-by: Mike Rapoport (IBM) <[email protected]> Acked-by: Catalin Marinas <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Tested-by: Borislav Petkov (AMD) <[email protected]> Cc: ke.wang <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f65c4bb commit 993f57e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/Kconfig.debug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ config DEBUG_KMEMLEAK
754754
select KALLSYMS
755755
select CRC32
756756
select STACKDEPOT
757+
select STACKDEPOT_ALWAYS_INIT if !DEBUG_KMEMLEAK_DEFAULT_OFF
757758
help
758759
Say Y here if you want to enable the memory leak
759760
detector. The memory allocation/freeing is traced in a way

mm/kmemleak.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,8 +2070,10 @@ static int __init kmemleak_boot_config(char *str)
20702070
return -EINVAL;
20712071
if (strcmp(str, "off") == 0)
20722072
kmemleak_disable();
2073-
else if (strcmp(str, "on") == 0)
2073+
else if (strcmp(str, "on") == 0) {
20742074
kmemleak_skip_disable = 1;
2075+
stack_depot_want_early_init();
2076+
}
20752077
else
20762078
return -EINVAL;
20772079
return 0;
@@ -2093,7 +2095,6 @@ void __init kmemleak_init(void)
20932095
if (kmemleak_error)
20942096
return;
20952097

2096-
stack_depot_init();
20972098
jiffies_min_age = msecs_to_jiffies(MSECS_MIN_AGE);
20982099
jiffies_scan_wait = msecs_to_jiffies(SECS_SCAN_WAIT * 1000);
20992100

0 commit comments

Comments
 (0)