Catalin Marinas
fe1136b4cc
samples: kmemleak: print the raw pointers for debugging purposes
...
The kmemleak-test.c module is meant to leak some pointers for debugging
the kmemleak detection, pointer information dumping. It's no use if it
prints the hashed values of such pointers.
Change the printk() format from %p to %px. While at it, also display the
raw __percpu pointer rather than this_cpu_ptr() since kmemleak now tracks
such pointers independently of the standard allocations.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Catalin Marinas <[email protected] >
Signed-off-by: Andrew Morton <[email protected] >
2025-03-16 22:06:08 -07:00
Pavel Tikhomirov
e0b2fdb352
kmemleak-test: add percpu leak
...
Add a per-CPU memory leak, which will be reported like:
unreferenced object 0x3efa840195f8 (size 64):
comm "modprobe", pid 4667, jiffies 4294688677
hex dump (first 32 bytes on cpu 0):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 0):
[<ffffffffa7fa87af>] pcpu_alloc+0x3df/0x840
[<ffffffffc11642d9>] kmemleak_test_init+0x2c9/0x2f0 [kmemleak_test]
[<ffffffffa7c02264>] do_one_initcall+0x44/0x300
[<ffffffffa7de9e10>] do_init_module+0x60/0x240
[<ffffffffa7deb946>] init_module_from_file+0x86/0xc0
[<ffffffffa7deba99>] idempotent_init_module+0x109/0x2a0
[<ffffffffa7debd2a>] __x64_sys_finit_module+0x5a/0xb0
[<ffffffffa88f4f3a>] do_syscall_64+0x7a/0x160
[<ffffffffa8a0012b>] entry_SYSCALL_64_after_hwframe+0x76/0x7e
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Pavel Tikhomirov <[email protected] >
Acked-by: Catalin Marinas <[email protected] >
Cc: Alexander Mikhalitsyn <[email protected] >
Cc: Chen Jun <[email protected] >
Cc: Wei Yongjun <[email protected] >
Signed-off-by: Andrew Morton <[email protected] >
2024-09-01 20:25:50 -07:00
Jeff Johnson
656fe3ee45
kmemleak-test: add missing MODULE_DESCRIPTION() macro
...
make allmodconfig && make W=1 C=1 reports:
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kmemleak/kmemleak-test.o
Add the missing invocation of the MODULE_DESCRIPTION() macro.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Jeff Johnson <[email protected] >
Acked-by: Catalin Marinas <[email protected] >
Signed-off-by: Andrew Morton <[email protected] >
2024-07-03 19:30:04 -07:00
Jim Cromie
dcb8cbb58a
kmemleak-test: drop __init to get better backtrace
...
Drop the __init on kmemleak_test_init(). With it, the storage is
reclaimed, but then the symbol isn't available for "%pS" rendering,
and the backtrace gets a bare pointer where the actual leak happened.
unreferenced object 0xffff88800a2b0800 (size 1024):
comm "modprobe", pid 413, jiffies 4294953430
hex dump (first 32 bytes):
73 02 00 00 75 01 00 68 02 00 00 01 00 00 00 04 s...u..h........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000fabad728>] kmalloc_trace+0x26/0x90
[<00000000ef738764>] 0xffffffffc02350a2
[<00000000004e5795>] do_one_initcall+0x43/0x210
[<00000000d768905e>] do_init_module+0x4a/0x210
[<0000000087135ab5>] __do_sys_finit_module+0x93/0xf0
[<000000004fcb1fa2>] do_syscall_64+0x34/0x80
[<00000000c73c8d9d>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
with __init gone, that trace entry renders like:
[<00000000ef738764>] kmemleak_test_init+<offset>/<size>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Jim Cromie <[email protected] >
Acked-by: Catalin Marinas <[email protected] >
Signed-off-by: Andrew Morton <[email protected] >
2023-06-09 16:25:40 -07:00
Hao Ge
27d9a0fdb5
kmemleak-test: fix kmemleak_test.c build logic
...
kmemleak-test.c was moved to the samples directory in 1abbef4f51
("mm,kmemleak-test.c: move kmemleak-test.c to samples dir").
If CONFIG_DEBUG_KMEMLEAK_TEST=m and CONFIG_SAMPLES is unset,
kmemleak-test.c will be unnecessarily compiled.
So move the entry for CONFIG_DEBUG_KMEMLEAK_TEST from mm/Kconfig and add a
new CONFIG_SAMPLE_KMEMLEAK in samples/ to control whether kmemleak-test.c
is built or not.
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 1abbef4f51 ("mm,kmemleak-test.c: move kmemleak-test.c to samples dir")
Signed-off-by: Hao Ge <[email protected] >
Cc: Catalin Marinas <[email protected] >
Cc: Alex Gaynor <[email protected] >
Cc: Alex Williamson <[email protected] >
Cc: Arnd Bergmann <[email protected] >
Cc: Finn Behrens <[email protected] >
Cc: Greg Kroah-Hartman <[email protected] >
Cc: Jason Gunthorpe <[email protected] >
Cc: Mark Rutland <[email protected] >
Cc: Miguel Ojeda <[email protected] >
Cc: Tony Krowiak <[email protected] >
Cc: Ye Xingchen <[email protected] >
Signed-off-by: Andrew Morton <[email protected] >
2023-04-18 16:29:47 -07:00
Hui Su
1abbef4f51
mm,kmemleak-test.c: move kmemleak-test.c to samples dir
...
kmemleak-test.c is just a kmemleak test module, which also can not be used
as a built-in kernel module. Thus, i think it may should not be in mm
dir, and move the kmemleak-test.c to samples/kmemleak/kmemleak-test.c.
Fix the spelling of built-in by the way.
Signed-off-by: Hui Su <[email protected] >
Signed-off-by: Andrew Morton <[email protected] >
Cc: Catalin Marinas <[email protected] >
Cc: Jonathan Corbet <[email protected] >
Cc: Mauro Carvalho Chehab <[email protected] >
Cc: David S. Miller <[email protected] >
Cc: Rob Herring <[email protected] >
Cc: Masahiro Yamada <[email protected] >
Cc: Sam Ravnborg <[email protected] >
Cc: Josh Poimboeuf <[email protected] >
Cc: Steven Rostedt (VMware) <[email protected] >
Cc: Miguel Ojeda <[email protected] >
Cc: Divya Indi <[email protected] >
Cc: Tomas Winkler <[email protected] >
Cc: David Howells <[email protected] >
Link: https://lkml.kernel.org/r/20200925183729.GA172837@rlk
Signed-off-by: Linus Torvalds <[email protected] >
2020-10-13 18:38:27 -07:00