* [PATCHv3] mm: use stack_depot_early_init for kmemleak
@ 2023-01-18 2:07 zhaoyang.huang
2023-01-18 14:34 ` Catalin Marinas
0 siblings, 1 reply; 2+ messages in thread
From: zhaoyang.huang @ 2023-01-18 2:07 UTC (permalink / raw)
To: Andrew Morton, Catalin Marinas, Vlastimil Babka,
Nathan Chancellor, Peter Zijlstra, Zhaoyang Huang, linux-mm,
linux-kernel, ke.wang, Mirsad Todorovac
From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
Mirsad report bellow error which caused by stack_depot_init failed 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.
reported-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>
suggested-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
v2: use stack_depot_want_early_init instead of CONFIG_STACKDEPOT_ALWAYS_INIT
v3: have the Kconfig changes commited in another patch
---
Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
mm/kmemleak.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 762b91f..ddc1ddf 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -2070,8 +2070,10 @@ static int __init kmemleak_boot_config(char *str)
return -EINVAL;
if (strcmp(str, "off") == 0)
kmemleak_disable();
- else if (strcmp(str, "on") == 0)
+ else if (strcmp(str, "on") == 0) {
kmemleak_skip_disable = 1;
+ stack_depot_want_early_init();
+ }
else
return -EINVAL;
return 0;
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCHv3] mm: use stack_depot_early_init for kmemleak
2023-01-18 2:07 [PATCHv3] mm: use stack_depot_early_init for kmemleak zhaoyang.huang
@ 2023-01-18 14:34 ` Catalin Marinas
0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2023-01-18 14:34 UTC (permalink / raw)
To: zhaoyang.huang
Cc: Andrew Morton, Vlastimil Babka, Nathan Chancellor,
Peter Zijlstra, Zhaoyang Huang, linux-mm, linux-kernel, ke.wang,
Mirsad Todorovac
On Wed, Jan 18, 2023 at 10:07:35AM +0800, zhaoyang.huang wrote:
> Mirsad report bellow error which caused by stack_depot_init failed in kvcalloc.
> Solve this by having stackdepot use stack_depot_early_init.
[...]
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index 762b91f..ddc1ddf 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -2070,8 +2070,10 @@ static int __init kmemleak_boot_config(char *str)
> return -EINVAL;
> if (strcmp(str, "off") == 0)
> kmemleak_disable();
> - else if (strcmp(str, "on") == 0)
> + else if (strcmp(str, "on") == 0) {
> kmemleak_skip_disable = 1;
> + stack_depot_want_early_init();
> + }
Does this fix still work if kmemleak is default on and no option passed
on the kernel command line? I thought we also need something like:
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 881c3f84e88a..80c69d026890 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -754,6 +754,7 @@ config DEBUG_KMEMLEAK
select KALLSYMS
select CRC32
select STACKDEPOT
+ select STACKDEPOT_ALWAYS_INIT if !DEBUG_KMEMLEAK_DEFAULT_OFF
help
Say Y here if you want to enable the memory leak
detector. The memory allocation/freeing is traced in a way
--
Catalin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-18 14:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18 2:07 [PATCHv3] mm: use stack_depot_early_init for kmemleak zhaoyang.huang
2023-01-18 14:34 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox