All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] sysctl: Suppress kmemleak messages
Date: Tue, 22 May 2012 10:47:57 +0100	[thread overview]
Message-ID: <20120522094757.GA28761@arm.com> (raw)
In-Reply-To: <1337648657.13348.26.camel@gandalf.stny.rr.com>

On Tue, May 22, 2012 at 02:04:17AM +0100, Steven Rostedt wrote:
> Not sure who the owner is of kernel/sysctl.c, so I'm just sending this
> patch to you :-)
> 
> The register_sysctl_table() is a strange function, as it makes internal
> allocations (a header) to register a sysctl_table. This header is a
> handle to the table that is created, and can be used to unregister the
> table. But if the table is permanent and never unregistered, the header
> acts the same as a static variable.
> 
> Unfortunately, this allocation of memory that is never expected to be
> freed, fools kmemleak in thinking that we have leaked memory. For those
> sysctl tables that are never unregistered, and have no pointer
> referencing them, kmemleak will think that these are memory leaks:
> 
> unreferenced object 0xffff880079fb9d40 (size 192):
>   comm "swapper/0", pid 0, jiffies 4294667316 (age 12614.152s)
>   hex dump (first 32 bytes):
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>   backtrace:
>     [<ffffffff8146b590>] kmemleak_alloc+0x73/0x98
>     [<ffffffff8110a935>] kmemleak_alloc_recursive.constprop.42+0x16/0x18
>     [<ffffffff8110b852>] __kmalloc+0x107/0x153
>     [<ffffffff8116fa72>] kzalloc.constprop.8+0xe/0x10
>     [<ffffffff811703c9>] __register_sysctl_paths+0xe1/0x160
>     [<ffffffff81170463>] register_sysctl_paths+0x1b/0x1d
>     [<ffffffff8117047d>] register_sysctl_table+0x18/0x1a
>     [<ffffffff81afb0a1>] sysctl_init+0x10/0x14
>     [<ffffffff81b05a6f>] proc_sys_init+0x2f/0x31
>     [<ffffffff81b0584c>] proc_root_init+0xa5/0xa7
>     [<ffffffff81ae5b7e>] start_kernel+0x3d0/0x40a
>     [<ffffffff81ae52a7>] x86_64_start_reservations+0xae/0xb2
>     [<ffffffff81ae53ad>] x86_64_start_kernel+0x102/0x111
>     [<ffffffffffffffff>] 0xffffffffffffffff
> 
> 
> The sysctl_base_table used by sysctl itself is one such instance that
> registers the table to never be unregistered.
> 
> Use kmemleak_not_leak() to suppress the kmemleak false positive.
> 
> [ applied against 3.4 ]
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

FWIW,

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

(for the use of the kmemleak API :))

-- 
Catalin

      reply	other threads:[~2012-05-22  9:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-22  1:04 [PATCH] sysctl: Suppress kmemleak messages Steven Rostedt
2012-05-22  9:47 ` Catalin Marinas [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=20120522094757.GA28761@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.