From: Dave Hansen <dave.hansen@intel.com>
To: "Dilger, Andreas" <andreas.dilger@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dan Carpenter <dan.carpenter@oracle.com>
Cc: "devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
Peng Tao <tao.peng@emc.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
"Drokin, Oleg" <oleg.drokin@intel.com>
Subject: Re: [PATCH] staging: lustre: fix GFP_ATOMIC macro usage
Date: Tue, 21 Jan 2014 13:15:32 -0800 [thread overview]
Message-ID: <52DEE374.7040908@intel.com> (raw)
In-Reply-To: <CF037522.8B804%andreas.dilger@intel.com>
On 01/21/2014 12:02 PM, Dilger, Andreas wrote:
> The Lustre allocation macros track the memory usage across the whole
> filesystem,
> not just of a single structure that a mempool/slab/whatever would do.
> This is
> useful to know for debugging purposes (e.g. user complains about not having
> enough RAM for their highly-tuned application, or to check for leaks at
> unmount).
Urg, it does this with a global variable. If we did this kind of thing
generically, we'd get eaten alive by all of the cacheline bouncing from
that atomic. It's also a 32-bit atomic. Guess it's never had more than
4GB of memory tracked in there. :)
This also doesn't track overhead from things that *are* in slabs like
the inodes, or the 14 kmem_caches that lustre has, so it's far from a
complete picture of how lustre is using memory.
> It can also log the alloc/free calls and post-process them to find leaks
> easily, or find pieces code that is allocating too much memory that are not
> using dedicated slabs. This also works if you encounter a system with a
> lot of allocated memory, enable "free" logging, and then unmount the
> filesystem.
> The logs will show which structures are being freed (assuming they are not
> leaked completely) and point you to whatever is not being shrunk properly.
This isn't perfect, but it does cover most of the ext4 call sites in my
kernel. It would work better for a module, I'd imagine:
cd /sys/kernel/debug/tracing/events/kmem
echo -n 'call_site < 0xffffffff81e0af00 && call_site >=
0xffffffff81229cf0' > kmalloc/filter
echo 1 > kmalloc/enable
cat /sys/kernel/debug/tracing/trace_pipe
It will essentially log all the kmalloc() calls from the ext4 code. I
got the call site locations from grepping System.map. It would be
_really_ nice if we were able to do something like:
echo 'call_site =~ *ext4*'
but there's no way to do that which I know of. You could probably rig
something up with the function graph tracer by triggering only on entry
to the lustre code.
> I don't know if there is any way to track this with regular kmalloc(), and
> creating separate slabs for so ever data structure would be ugly. The
> generic
> /proc/meminfo data doesn't really tell you what is using all the memory,
> and
> the size-NNNN slabs give some information, but are used all over the
> kernel.
>
> I'm pretty much resigned to losing all of this functionality, but it
> definitely
> has been very useful for finding problems.
Yeah, it is hard to find out who is responsible for leaking pages or
kmalloc()s, especially after the fact. But, we seem to limp along just
fine. If lustre is that bad of a memory leaker that it *NEEDS* this
feature, we have bigger problems on our hands. :)
next prev parent reply other threads:[~2014-01-21 21:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-17 8:46 [PATCH] staging: lustre: fix GFP_ATOMIC macro usage Marek Szyprowski
2014-01-17 14:33 ` Greg Kroah-Hartman
2014-01-17 14:51 ` Dan Carpenter
2014-01-17 15:17 ` Greg Kroah-Hartman
2014-01-21 20:02 ` Dilger, Andreas
2014-01-21 20:16 ` Dan Carpenter
2014-01-22 1:31 ` Drokin, Oleg
2014-01-21 21:15 ` Dave Hansen [this message]
2014-01-22 1:52 ` Drokin, Oleg
2014-01-20 8:18 ` Marek Szyprowski
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=52DEE374.7040908@intel.com \
--to=dave.hansen@intel.com \
--cc=andreas.dilger@intel.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=oleg.drokin@intel.com \
--cc=tao.peng@emc.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