Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp180065pxb; Thu, 14 Jan 2021 03:11:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJytfVDQtoCFV3s0iMLyXd4idTWdpV965OL84vwQ1iaNorvC9Dgvrl8NfpYIXwYRJkr4IVeu X-Received: by 2002:a17:906:2f83:: with SMTP id w3mr5040187eji.292.1610622665705; Thu, 14 Jan 2021 03:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610622665; cv=none; d=google.com; s=arc-20160816; b=bKdVWhy5MGuXAvdQsgAjpDpO6QNKiwvezIYrxdBA8p2YIFvLQqFlHALTQ+KutLgfBT 8kktDEomgWnMv+bRGDuZhKRkKRiltJwHlQxFQFpzVt5zoyBWwHnBB8uhU6pNR99Ywi7S h8WQaERXddqsj5jo7XWDqn2IprGbwA6IEw06JxvMZQRk17rX4/xGgfY5Oeatz6+dM252 l9egHJ4qqVcqbKYijxz3gS15nJrx/HaM10tg4rUj9ACLbpqeSKctZ/SzyrsYnLL051Pb 8qEaNi5+Dv6rwBOaLA4QqUgpWRQLyhInr26rnEVh9pfUXKtPHPlmKxpmc+cWyQlzbNUI H1Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=t5z5Y/cTyEPu8PVNnSKFKf2r8lO1AvuecRqZf7AKDfs=; b=ePmykDzLQ850EpYpvIkbqpe7vjYzlC6eHKN9xIU4oygPb1yqQxoiH7m6TIRV+x8Urc 4mThx16E96rVpNItx1uF3h9xXlbAzLg3b9xFAAC8kvouS9fzRcUOAZNKm7soyFAxu8LT 2R+M0ww0EtDGnAteT1RICIAi5/HGRjsho5tgzi74y3GB4cHBoikqze2wAN20+CkmGhd6 4RjCJoNiaAuaKvds/wQBBU11t6jwYMj9nYZKyknS/CHDrVy+/W0FDiayt8gKpoUWp8dF Xtmzll8Y/1+peE8kVDM9eej7ZI4StZr6kvFyfpmIBeYSLI2xctbv2ku2u+1o1/4nl8Nl nOiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lx1si222247ejb.146.2021.01.14.03.10.41; Thu, 14 Jan 2021 03:11:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727349AbhANLIg (ORCPT + 99 others); Thu, 14 Jan 2021 06:08:36 -0500 Received: from mx2.suse.de ([195.135.220.15]:45842 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbhANLIg (ORCPT ); Thu, 14 Jan 2021 06:08:36 -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 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, >