Skip to content

Commit

Permalink
kmemleak-test: fix kmemleak_test.c build logic
Browse files Browse the repository at this point in the history
kmemleak-test.c was moved to the samples directory in 1abbef4
("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: 1abbef4 ("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]>
  • Loading branch information
GeHao01994 authored and akpm00 committed Apr 18, 2023
1 parent 869cb29 commit 27d9a0f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
8 changes: 0 additions & 8 deletions mm/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,6 @@ config DEBUG_KMEMLEAK_MEM_POOL_SIZE
fully initialised, this memory pool acts as an emergency one
if slab allocations fail.

config DEBUG_KMEMLEAK_TEST
tristate "Simple test for the kernel memory leak detector"
depends on DEBUG_KMEMLEAK && m
help
This option enables a module that explicitly leaks memory.

If unsure, say N.

config DEBUG_KMEMLEAK_DEFAULT_OFF
bool "Default kmemleak to off"
depends on DEBUG_KMEMLEAK
Expand Down
7 changes: 7 additions & 0 deletions samples/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ config SAMPLE_CORESIGHT_SYSCFG
This demonstrates how a user may create their own CoreSight
configurations and easily load them into the system at runtime.

config SAMPLE_KMEMLEAK
tristate "Simple test for the kernel memory leak detector"
depends on DEBUG_KMEMLEAK && m
help
Build a sample program which have explicitly leaks memory to test
kmemleak

source "samples/rust/Kconfig"

endif # SAMPLES
Expand Down
2 changes: 1 addition & 1 deletion samples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ subdir-$(CONFIG_SAMPLE_VFS) += vfs
obj-$(CONFIG_SAMPLE_INTEL_MEI) += mei/
subdir-$(CONFIG_SAMPLE_WATCHDOG) += watchdog
subdir-$(CONFIG_SAMPLE_WATCH_QUEUE) += watch_queue
obj-$(CONFIG_DEBUG_KMEMLEAK_TEST) += kmemleak/
obj-$(CONFIG_SAMPLE_KMEMLEAK) += kmemleak/
obj-$(CONFIG_SAMPLE_CORESIGHT_SYSCFG) += coresight/
obj-$(CONFIG_SAMPLE_FPROBE) += fprobe/
obj-$(CONFIG_SAMPLES_RUST) += rust/
2 changes: 1 addition & 1 deletion samples/kmemleak/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only

obj-$(CONFIG_DEBUG_KMEMLEAK_TEST) += kmemleak-test.o
obj-$(CONFIG_SAMPLE_KMEMLEAK) += kmemleak-test.o

0 comments on commit 27d9a0f

Please sign in to comment.