From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 497CBC433E0 for ; Wed, 13 Jan 2021 17:00:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E47CD23437 for ; Wed, 13 Jan 2021 17:00:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727296AbhAMRA3 (ORCPT ); Wed, 13 Jan 2021 12:00:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:50428 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbhAMRA3 (ORCPT ); Wed, 13 Jan 2021 12:00:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6D039AB92; Wed, 13 Jan 2021 16:59:47 +0000 (UTC) To: Johannes Berg , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Andrew Morton , Catalin Marinas , Johannes Berg , Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg References: <20210113170931.929f808099d2.I117b6764e725b3192318bbcf4269b13b709539ae@changeid> From: Vlastimil Babka Subject: Re: [PATCH] mm/slub: disable user tracing for kmemleak caches Message-ID: <1db7c986-25c4-884e-4fbf-9af348bdff6f@suse.cz> Date: Wed, 13 Jan 2021 17:59:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210113170931.929f808099d2.I117b6764e725b3192318bbcf4269b13b709539ae@changeid> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/13/21 5:09 PM, Johannes Berg wrote: > From: Johannes Berg > > 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 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, >