[-next] mm/kmemleak: record the current memory pool size
diff mbox series

Message ID 1565809631-28933-1-git-send-email-cai@lca.pw
State New
Headers show
Series
  • [-next] mm/kmemleak: record the current memory pool size
Related show

Commit Message

Qian Cai Aug. 14, 2019, 7:07 p.m. UTC
The only way to obtain the current memory pool size for a running kernel
is to check back the kernel config file which is inconvenient. Record it
in the kernel messages.

Signed-off-by: Qian Cai <cai@lca.pw>
---
 mm/kmemleak.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Catalin Marinas Aug. 15, 2019, 10:02 a.m. UTC | #1
On Wed, Aug 14, 2019 at 03:07:11PM -0400, Qian Cai wrote:
> The only way to obtain the current memory pool size for a running kernel
> is to check back the kernel config file which is inconvenient. Record it
> in the kernel messages.
> 
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  mm/kmemleak.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index b8bbe9ac5472..1f74f8bcb4eb 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -1967,7 +1967,8 @@ static int __init kmemleak_late_init(void)
>  		mutex_unlock(&scan_mutex);
>  	}
>  
> -	pr_info("Kernel memory leak detector initialized\n");
> +	pr_info("Kernel memory leak detector initialized (mem pool size: %d)\n",
> +		mem_pool_free_count);

I wouldn't actually call it the "memory pool size" as I see the size as
a constant set at config time. What about "memory pool available"?

(even this one is not entirely accurate since we have a
mem_pool_free_list but I expect such list not to have too many elements
at the late_initcall time)

If you change the printed string:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Andrew Morton Sept. 20, 2019, 11:22 p.m. UTC | #2
On Thu, 15 Aug 2019 11:02:16 +0100 Catalin Marinas <catalin.marinas@arm.com> wrote:

> On Wed, Aug 14, 2019 at 03:07:11PM -0400, Qian Cai wrote:
> > The only way to obtain the current memory pool size for a running kernel
> > is to check back the kernel config file which is inconvenient. Record it
> > in the kernel messages.
> > 
> > Signed-off-by: Qian Cai <cai@lca.pw>
> > ---
> >  mm/kmemleak.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> > index b8bbe9ac5472..1f74f8bcb4eb 100644
> > --- a/mm/kmemleak.c
> > +++ b/mm/kmemleak.c
> > @@ -1967,7 +1967,8 @@ static int __init kmemleak_late_init(void)
> >  		mutex_unlock(&scan_mutex);
> >  	}
> >  
> > -	pr_info("Kernel memory leak detector initialized\n");
> > +	pr_info("Kernel memory leak detector initialized (mem pool size: %d)\n",
> > +		mem_pool_free_count);
> 
> I wouldn't actually call it the "memory pool size" as I see the size as
> a constant set at config time. What about "memory pool available"?
> 
> (even this one is not entirely accurate since we have a
> mem_pool_free_list but I expect such list not to have too many elements
> at the late_initcall time)
> 
> If you change the printed string:
> 
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>

--- a/mm/kmemleak.c~mm-kmemleak-record-the-current-memory-pool-size-fix
+++ a/mm/kmemleak.c
@@ -1967,7 +1967,7 @@ static int __init kmemleak_late_init(voi
 		mutex_unlock(&scan_mutex);
 	}
 
-	pr_info("Kernel memory leak detector initialized (mem pool size: %d)\n",
+	pr_info("Kernel memory leak detector initialized (mem pool available: %d)\n",
 		mem_pool_free_count);
 
 	return 0;

Patch
diff mbox series

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index b8bbe9ac5472..1f74f8bcb4eb 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1967,7 +1967,8 @@  static int __init kmemleak_late_init(void)
 		mutex_unlock(&scan_mutex);
 	}
 
-	pr_info("Kernel memory leak detector initialized\n");
+	pr_info("Kernel memory leak detector initialized (mem pool size: %d)\n",
+		mem_pool_free_count);
 
 	return 0;
 }