From: Pavel Machek <pavel@ucw.cz>
To: Maninder Singh <maninder1.s@samsung.com>
Cc: jeyu@redhat.com, rusty@rustcorp.com.au,
akpm@linux-foundation.org, chris@chris-wilson.co.uk,
aryabinin@virtuozzo.com, joonas.lahtinen@linux.intel.com,
mhocko@suse.com, keescook@chromium.org, jinb.park7@gmail.com,
anisse@astier.eu, rafael.j.wysocki@intel.com, zijun_hu@htc.com,
mingo@kernel.org, mawilcox@microsoft.com, thgarnie@google.com,
joelaf@google.com, kirill.shutemov@linux.intel.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
pankaj.m@samsung.com, ajeet.y@samsung.com,
hakbong5.lee@samsung.com, a.sahrawat@samsung.com,
lalit.mohan@samsung.com, cpgs@samsung.com,
Vaneet Narang <v.narang@samsung.com>
Subject: Re: [PATCH 1/1] module: check if memory leak by module.
Date: Mon, 27 Mar 2017 08:43:25 +0200 [thread overview]
Message-ID: <20170327064325.GA27625@amd> (raw)
In-Reply-To: <1490355028-13292-1-git-send-email-maninder1.s@samsung.com>
[-- Attachment #1: Type: text/plain, Size: 1803 bytes --]
Hi!
> This patch adds new config VMALLOC_MEMORY_LEAK to check if any
> module which is going to be unloaded is doing vmalloc memory leak.
>
> Logs:-
> [ 129.336368] Module vmalloc is getting unloaded before doing vfree
> [ 129.336371] Memory still allocated: addr:0xffffc90001461000 - 0xffffc900014c7000, pages 101
> [ 129.336376] Allocating function kernel_init+0x1c/0x20 [vmalloc]
>
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
> Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Let me see...
> diff --git a/kernel/module.c b/kernel/module.c
> index 529efae..b492f34 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -2082,9 +2082,37 @@ void __weak module_arch_freeing_init(struct module *mod)
> {
> }
>
> +#ifdef CONFIG_VMALLOC_MEMORY_LEAK
I'd not make this optional -- the performance cost is not all that
big, right?
> +static void check_memory_leak(struct module *mod)
> +{
> + struct vmap_area *va;
> +
> + rcu_read_lock();
> + list_for_each_entry_rcu(va, &vmap_area_list, list) {
> + if (!(va->flags & VM_VM_AREA))
> + continue;
> + if ((mod->core_layout.base < va->vm->caller) &&
> + (mod->core_layout.base + mod->core_layout.size) > va->vm->caller) {
Two spaces after "+".
> + pr_alert("Module %s is getting unloaded before doing vfree\n", mod->name);
> + pr_alert("Memory still allocated: addr:0x%lx - 0x%lx, pages %u\n",
> + va->va_start, va->va_end, va->vm->nr_pages);
> + pr_alert("Allocating function %pS\n", va->vm->caller);
> + }
Plain pr_err() would be preffered. Its just a memory leak.
Otherwise looks good to me..
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
prev parent reply other threads:[~2017-03-27 6:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170324113058epcas5p48d9b7cf45d62d2cf7c2146ebc8719542@epcas5p4.samsung.com>
2017-03-24 11:30 ` [PATCH 1/1] module: check if memory leak by module Maninder Singh
2017-03-27 6:43 ` Pavel Machek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170327064325.GA27625@amd \
--to=pavel@ucw.cz \
--cc=a.sahrawat@samsung.com \
--cc=ajeet.y@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=anisse@astier.eu \
--cc=aryabinin@virtuozzo.com \
--cc=chris@chris-wilson.co.uk \
--cc=cpgs@samsung.com \
--cc=hakbong5.lee@samsung.com \
--cc=jeyu@redhat.com \
--cc=jinb.park7@gmail.com \
--cc=joelaf@google.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=keescook@chromium.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=lalit.mohan@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maninder1.s@samsung.com \
--cc=mawilcox@microsoft.com \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=pankaj.m@samsung.com \
--cc=rafael.j.wysocki@intel.com \
--cc=rusty@rustcorp.com.au \
--cc=thgarnie@google.com \
--cc=v.narang@samsung.com \
--cc=zijun_hu@htc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).