linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kmemleak: Always register debugfs file
@ 2018-08-24 13:12 Vincent Whitchurch
  2018-08-24 15:23 ` Catalin Marinas
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Whitchurch @ 2018-08-24 13:12 UTC (permalink / raw)
  To: catalin.marinas, akpm; +Cc: linux-kernel, linux-mm, Vincent Whitchurch

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.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 mm/kmemleak.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 9a085d525bbc..17dd883198ae 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -2097,6 +2097,11 @@ static int __init kmemleak_late_init(void)
 
 	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(void)
 		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);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kmemleak: Always register debugfs file
  2018-08-24 13:12 [PATCH] kmemleak: Always register debugfs file Vincent Whitchurch
@ 2018-08-24 15:23 ` Catalin Marinas
  0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2018-08-24 15:23 UTC (permalink / raw)
  To: Vincent Whitchurch; +Cc: akpm, linux-kernel, linux-mm, Vincent Whitchurch

On Fri, Aug 24, 2018 at 03:12:20PM +0200, Vincent Whitchurch wrote:
> 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.
> 
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>

I think that's also consistent with a late disabling of kmemleak when
the debugfs entry sticks around.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-24 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-24 13:12 [PATCH] kmemleak: Always register debugfs file Vincent Whitchurch
2018-08-24 15:23 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).