The patch titled Subject: kmemleak: always register debugfs file has been added to the -mm tree. Its filename is kmemleak-always-register-debugfs-file.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/kmemleak-always-register-debugfs-file.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/kmemleak-always-register-debugfs-file.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Vincent Whitchurch <vincent.whitchurch@xxxxxxxx> Subject: kmemleak: always register debugfs file If kmemleak built in to the kernel, but is disabled by default, the debugfs file is never registered. Because of this, it is not possible to find out if the kernel is built with kmemleak support by checking for the presence of this file. To allow this, always register the file. After this patch, if the file doesn't exist, kmemleak is not available in the kernel. If writing "scan" or any other value than "clear" to this file results in EBUSY, then kmemleak is available but is disabled by default and can be activated via the kernel command line. Catalin: "that's also consistent with a late disabling of kmemleak when the debugfs entry sticks around." Link: http://lkml.kernel.org/r/20180824131220.19176-1-vincent.whitchurch@xxxxxxxx Signed-off-by: Vincent Whitchurch <vincent.whitchurch@xxxxxxxx> Acked-by: Catalin Marinas <catalin.marinas@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/kmemleak.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/mm/kmemleak.c~kmemleak-always-register-debugfs-file +++ a/mm/kmemleak.c @@ -2097,6 +2097,11 @@ static int __init kmemleak_late_init(voi kmemleak_initialized = 1; + dentry = debugfs_create_file("kmemleak", 0644, NULL, NULL, + &kmemleak_fops); + if (!dentry) + pr_warn("Failed to create the debugfs kmemleak file\n"); + if (kmemleak_error) { /* * Some error occurred and kmemleak was disabled. There is a @@ -2108,10 +2113,6 @@ static int __init kmemleak_late_init(voi return -ENOMEM; } - dentry = debugfs_create_file("kmemleak", 0644, NULL, NULL, - &kmemleak_fops); - if (!dentry) - pr_warn("Failed to create the debugfs kmemleak file\n"); mutex_lock(&scan_mutex); start_scan_thread(); mutex_unlock(&scan_mutex); _ Patches currently in -mm which might be from vincent.whitchurch@xxxxxxxx are kmemleak-always-register-debugfs-file.patch