From 725df8b76b42379b2d5247a938979602024d977d Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Sat, 5 Dec 2020 19:46:01 -0800 Subject: [PATCH] mm: kmemleak: Don't require global debug options or debugfs This allows kmemleak to function even when debugfs is globally disabled, allowing kmemleak to give accurate results for CONFIG_DEBUG_FS=n. Signed-off-by: Sultan Alsawaf Signed-off-by: Carlos Jimenez (JavaShin-X) --- fs/Makefile | 6 +++++- fs/debugfs/Makefile | 5 ++++- lib/Kconfig.debug | 3 +-- mm/Makefile | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/Makefile b/fs/Makefile index 7e50a549cc43..84005a0db17b 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -123,7 +123,11 @@ obj-$(CONFIG_NILFS2_FS) += nilfs2/ obj-$(CONFIG_BEFS_FS) += befs/ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_CACHEFILES) += cachefiles/ -obj-$(CONFIG_DEBUG_FS) += debugfs/ +ifeq ($(CONFIG_DEBUG_FS),y) +obj-y += debugfs/ +else +obj-$(CONFIG_DEBUG_KMEMLEAK) += debugfs/ +endif obj-$(CONFIG_TRACING) += tracefs/ obj-$(CONFIG_OCFS2_FS) += ocfs2/ obj-$(CONFIG_BTRFS_FS) += btrfs/ diff --git a/fs/debugfs/Makefile b/fs/debugfs/Makefile index 840c45696668..a1f5982cd771 100644 --- a/fs/debugfs/Makefile +++ b/fs/debugfs/Makefile @@ -1,4 +1,7 @@ debugfs-objs := inode.o file.o -obj-$(CONFIG_DEBUG_FS) += debugfs.o +ifeq ($(CONFIG_DEBUG_KMEMLEAK),y) +ccflags-y := -DCONFIG_DEBUG_FS +endif +obj-y += debugfs.o diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index bfe230f5b159..a1425a50d195 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -589,8 +589,7 @@ config HAVE_DEBUG_KMEMLEAK config DEBUG_KMEMLEAK bool "Kernel memory leak detector" - depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK - select DEBUG_FS + depends on HAVE_DEBUG_KMEMLEAK select STACKTRACE if STACKTRACE_SUPPORT select KALLSYMS select CRC32 diff --git a/mm/Makefile b/mm/Makefile index 61e1aac6a150..2729a997dc0f 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -105,3 +105,5 @@ obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o obj-$(CONFIG_PERCPU_STATS) += percpu-stats.o obj-$(CONFIG_HMM) += hmm.o obj-$(CONFIG_PROCESS_RECLAIM) += process_reclaim.o + +CFLAGS_kmemleak.o += -DCONFIG_DEBUG_FS