From: Vlastimil Babka <vbabka@suse.cz>
To: Johannes Berg <johannes@sipsolutions.net>, linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Johannes Berg <johannes.berg@intel.com>,
Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Pekka Enberg <penberg@kernel.org>
Subject: Re: [PATCH] mm/slub: disable user tracing for kmemleak caches
Date: Wed, 13 Jan 2021 17:59:43 +0100 [thread overview]
Message-ID: <1db7c986-25c4-884e-4fbf-9af348bdff6f@suse.cz> (raw)
In-Reply-To: <20210113170931.929f808099d2.I117b6764e725b3192318bbcf4269b13b709539ae@changeid>
On 1/13/21 5:09 PM, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> If kmemleak is enabled, it uses a kmem cache for its own objects.
> These objects are used to hold information kmemleak uses, including
> a stack trace. If slub_debug is also turned on, each of them has
> *another* stack trace, so the overhead adds up, and on my tests (on
> ARCH=um, admittedly) 2/3rds of the allocations end up being doing
> the stack tracing.
>
> Turn off SLAB_STORE_USER if SLAB_NOLEAKTRACE was given, to avoid
> storing the essentially same data twice.
>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
How about stripping away SLAB_STORE_USER only if it's added from the global
slub_debug variable? In case somebody lists one of the kmemleak caches
explicitly in "slub_debug=..." instead of just booting with "slub_debug", we
should honor that.
> ---
> Perhaps instead it should go the other way around, and kmemleak
> could even use/access the stack trace that's already in there ...
> But I don't really care too much, I can just turn off slub debug
> for the kmemleak caches via the command line anyway :-)
>
> ---
> mm/slub.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 34dcc09e2ec9..625a32a6645b 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1446,7 +1446,16 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
> }
> }
>
> - return flags | slub_debug;
> + flags |= slub_debug;
> +
> + /*
> + * If the slab cache is for debugging (e.g. kmemleak) then
> + * don't store user (stack trace) information.
> + */
> + if (flags & SLAB_NOLEAKTRACE)
> + flags &= ~SLAB_STORE_USER;
> +
> + return flags;
> }
> #else /* !CONFIG_SLUB_DEBUG */
> static inline void setup_object_debug(struct kmem_cache *s,
>
next prev parent reply other threads:[~2021-01-13 16:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-13 16:09 Johannes Berg
2021-01-13 16:59 ` Vlastimil Babka [this message]
2021-01-13 18:11 ` Johannes Berg
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=1db7c986-25c4-884e-4fbf-9af348bdff6f@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.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