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.5 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 675C7C433E0 for ; Thu, 14 Jan 2021 11:07:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC753239CF for ; Thu, 14 Jan 2021 11:07:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC753239CF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF4388D00D6; Thu, 14 Jan 2021 06:07:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA3D68D008E; Thu, 14 Jan 2021 06:07:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE1078D00D6; Thu, 14 Jan 2021 06:07:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id B6F878D008E for ; Thu, 14 Jan 2021 06:07:56 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 88EE1362A for ; Thu, 14 Jan 2021 11:07:56 +0000 (UTC) X-FDA: 77704105752.26.rifle99_3f16e3427526 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 6ABFA18025DD1 for ; Thu, 14 Jan 2021 11:07:56 +0000 (UTC) X-HE-Tag: rifle99_3f16e3427526 X-Filterd-Recvd-Size: 3375 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 Jan 2021 11:07:55 +0000 (UTC) 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 91D5DB769; Thu, 14 Jan 2021 11:07:54 +0000 (UTC) Subject: Re: [PATCH v2] mm/slub: disable user tracing for kmemleak caches by default To: Johannes Berg , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Andrew Morton , Catalin Marinas , Johannes Berg References: <20210113215114.d94efa13ba30.I117b6764e725b3192318bbcf4269b13b709539ae@changeid> From: Vlastimil Babka Message-ID: <31b91946-af43-8795-0d4a-cb93899ccbce@suse.cz> Date: Thu, 14 Jan 2021 12:07:54 +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: <20210113215114.d94efa13ba30.I117b6764e725b3192318bbcf4269b13b709539ae@changeid> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 1/13/21 9:51 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 Acked-by: Vlastimil Babka > --- > 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 :-) > > v2: > - strip SLAB_STORE_USER only coming from slub_debug so that the > command line args always take effect > > --- > mm/slub.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 34dcc09e2ec9..a66c9948c529 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -1412,6 +1412,15 @@ slab_flags_t kmem_cache_flags(unsigned int object_size, > size_t len; > char *next_block; > slab_flags_t block_flags; > + slab_flags_t slub_debug_local = slub_debug; > + > + /* > + * If the slab cache is for debugging (e.g. kmemleak) then > + * don't store user (stack trace) information by default, > + * but let the user enable it via the command line below. > + */ > + if (flags & SLAB_NOLEAKTRACE) > + slub_debug_local &= ~SLAB_STORE_USER; > > len = strlen(name); > next_block = slub_debug_string; > @@ -1446,7 +1455,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size, > } > } > > - return flags | slub_debug; > + return flags | slub_debug_local; > } > #else /* !CONFIG_SLUB_DEBUG */ > static inline void setup_object_debug(struct kmem_cache *s, >