From: Vlastimil Babka <vbabka@suse.cz>
To: Qian Cai <cai@lca.pw>, akpm@linux-foundation.org
Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com,
iamjoonsoo.kim@lge.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
"Tobin C. Harding" <tobin@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Michal Hocko <mhocko@kernel.org>
Subject: Re: [PATCH] slab: fix an infinite loop in leaks_show()
Date: Thu, 11 Apr 2019 10:20:14 +0200 [thread overview]
Message-ID: <43517646-a808-bccd-a05e-1b583fc411c7@suse.cz> (raw)
In-Reply-To: <20190411032635.10325-1-cai@lca.pw>
On 4/11/19 5:26 AM, Qian Cai wrote:
> "cat /proc/slab_allocators" could hang forever on SMP machines with
> kmemleak or object debugging enabled due to other CPUs running do_drain()
> will keep making kmemleak_object or debug_objects_cache dirty and unable
> to escape the first loop in leaks_show(),
So what if we don't remove SLAB (yet?) but start removing the debugging
functionality that has been broken for years and nobody noticed. I think
Linus already mentioned that we remove at least the
/proc/slab_allocators file...
> do {
> set_store_user_clean(cachep);
> drain_cpu_caches(cachep);
> ...
>
> } while (!is_store_user_clean(cachep));
>
> For example,
>
> do_drain
> slabs_destroy
> slab_destroy
> kmem_cache_free
> __cache_free
> ___cache_free
> kmemleak_free_recursive
> delete_object_full
> __delete_object
> put_object
> free_object_rcu
> kmem_cache_free
> cache_free_debugcheck --> dirty kmemleak_object
>
> One approach is to check cachep->name and skip both kmemleak_object and
> debug_objects_cache in leaks_show(). The other is to set
> store_user_clean after drain_cpu_caches() which leaves a small window
> between drain_cpu_caches() and set_store_user_clean() where per-CPU
> caches could be dirty again lead to slightly wrong information has been
> stored but could also speed up things significantly which sounds like a
> good compromise. For example,
>
> # cat /proc/slab_allocators
> 0m42.778s # 1st approach
> 0m0.737s # 2nd approach
>
> Fixes: d31676dfde25 ("mm/slab: alternative implementation for DEBUG_SLAB_LEAK")
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
> mm/slab.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/mm/slab.c b/mm/slab.c
> index 9142ee992493..3e1b7ff0360c 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -4328,8 +4328,12 @@ static int leaks_show(struct seq_file *m, void *p)
> * whole processing.
> */
> do {
> - set_store_user_clean(cachep);
> drain_cpu_caches(cachep);
> + /*
> + * drain_cpu_caches() could always make kmemleak_object and
> + * debug_objects_cache dirty, so reset afterwards.
> + */
> + set_store_user_clean(cachep);
>
> x[1] = 0;
>
>
next prev parent reply other threads:[~2019-04-11 8:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-11 3:26 Qian Cai
2019-04-11 8:20 ` Vlastimil Babka [this message]
2019-04-11 11:08 ` Qian Cai
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=43517646-a808-bccd-a05e-1b583fc411c7@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=cai@lca.pw \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=tobin@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox