linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Joel Fernandes <joelaf@google.com>
Cc: "Vaneet Narang" <v.narang@samsung.com>,
	"Miroslav Benes" <mbenes@suse.cz>,
	"Maninder Singh" <maninder1.s@samsung.com>,
	"jeyu@redhat.com" <jeyu@redhat.com>,
	"rusty@rustcorp.com.au" <rusty@rustcorp.com.au>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"chris@chris-wilson.co.uk" <chris@chris-wilson.co.uk>,
	"aryabinin@virtuozzo.com" <aryabinin@virtuozzo.com>,
	"joonas.lahtinen@linux.intel.com"
	<joonas.lahtinen@linux.intel.com>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"pavel@ucw.cz" <pavel@ucw.cz>,
	"jinb.park7@gmail.com" <jinb.park7@gmail.com>,
	"anisse@astier.eu" <anisse@astier.eu>,
	"rafael.j.wysocki@intel.com" <rafael.j.wysocki@intel.com>,
	"zijun_hu@htc.com" <zijun_hu@htc.com>,
	"mingo@kernel.org" <mingo@kernel.org>,
	"mawilcox@microsoft.com" <mawilcox@microsoft.com>,
	"thgarnie@google.com" <thgarnie@google.com>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"PANKAJ MISHRA" <pankaj.m@samsung.com>,
	"Ajeet Kumar Yadav" <ajeet.y@samsung.com>,
	이학봉 <hakbong5.lee@samsung.com>,
	"AMIT SAHRAWAT" <a.sahrawat@samsung.com>,
	랄릿 <lalit.mohan@samsung.com>, CPGS <cpgs@samsung.com>
Subject: Re: [PATCH v2] module: check if memory leak by module.
Date: Mon, 3 Apr 2017 09:24:02 +0200	[thread overview]
Message-ID: <20170403072402.GA24661@dhcp22.suse.cz> (raw)
In-Reply-To: <CAJWu+ooKE0yC5t-nk4SyPphn3vjRVeZxMzdEwCrQSjhP=mryKQ@mail.gmail.com>

On Fri 31-03-17 10:05:29, Joel Fernandes wrote:
> On Fri, Mar 31, 2017 at 1:00 AM, Michal Hocko <mhocko@kernel.org> wrote:
> > On Thu 30-03-17 23:49:52, Joel Fernandes wrote:
> >> Hi Michal,
> >>
> >> On Wed, Mar 29, 2017 at 3:43 AM, Michal Hocko <mhocko@kernel.org> wrote:
> >> > On Wed 29-03-17 09:23:32, Vaneet Narang wrote:
> >> >> Hi,
> >> >>
> >> >> >> Hmm, how can you track _all_ vmalloc allocations done on behalf of the
> >> >> >> module? It is quite some time since I've checked kernel/module.c but
> >> >> >> from my vague understading your check is basically only about statically
> >> >> >> vmalloced areas by module loader. Is that correct? If yes then is this
> >> >> >> actually useful? Were there any bugs in the loader code recently? What
> >> >> >> led you to prepare this patch? All this should be part of the changelog!
> >> >>
> >> >> First of all there is no issue in kernel/module.c. This patch add functionality
> >> >> to detect scenario where some kernel module does some memory allocation but gets
> >> >> unloaded without doing vfree. For example
> >> >> static int kernel_init(void)
> >> >> {
> >> >>         char * ptr = vmalloc(400 * 1024);
> >> >>         return 0;
> >> >> }
> >> >
> >> > How can you track that allocation back to the module? Does this patch
> >> > actually works at all? Also why would be vmalloc more important than
> >> > kmalloc allocations?
> >>
> >> Doesn't the patch use caller's (in this case, the module is the
> >> caller) text address for tracking this? vma->vm->caller should track
> >> the caller doing the allocation?
> >
> > Not really. First of all it will be vmalloc() to be tracked in the above
> > the example because vmalloc is not inlined. And secondly even if the
> 
> vmalloc is not inlined, but __built_in_address(0) will return the
> *return address* of vmalloc:
> 
> >From https://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Return-Address.html :
> "The level argument is number of frames to scan up the call stack. A
> value of 0 yields the return address of the current function"

yes, sorry, I meant to say s@vmalloc is not @__vmalloc_node_flags is not@
I can see some arguments to make __vmalloc_node_flags inline to make
/proc/vmallocinfo output more useful but...

> > caller of the vmalloc was tracked then it would be hopelessly
> > insufficient because you would get coverage of the _direct_ module usage
> > of vmalloc rather than anything that the module triggered and that is
> > outside of the module. Which means any library function etc...
> 
> Yes true, but I think the check is for direct allocations, done by the
> module, not indirect ones... it may not be a catch-all issues type of
> deal but is still IMO a good check since we already have
> va->vm->caller available.

I disagree. We have a full featured kmemleak to catch all potential
leaks. This code is IMHO not worth it.

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-04-03  7:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170329060315epcas5p1c6f7ce3aca1b2770c5e1d9aaeb1a27e1@epcas5p1.samsung.com>
2017-03-29  6:02 ` Maninder Singh
2017-03-29  7:45   ` Michal Hocko
2017-03-29  8:02     ` Miroslav Benes
     [not found]     ` <CGME20170329060315epcas5p1c6f7ce3aca1b2770c5e1d9aaeb1a27e1@epcms5p1>
2017-03-29  9:23       ` Vaneet Narang
2017-03-29 10:43         ` Michal Hocko
2017-03-31  6:49           ` Joel Fernandes
2017-03-31  8:00             ` Michal Hocko
2017-03-31 17:05               ` Joel Fernandes
2017-04-03  7:24                 ` Michal Hocko [this message]
2017-03-31 22:18         ` Jessica Yu
2017-03-29 11:05   ` Andrey Ryabinin
2017-03-30 13:37     ` Pavel Machek
2017-03-30 14:31       ` Andrey Ryabinin

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=20170403072402.GA24661@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --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=mbenes@suse.cz \
    --cc=mingo@kernel.org \
    --cc=pankaj.m@samsung.com \
    --cc=pavel@ucw.cz \
    --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