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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 19F32C433E0 for ; Wed, 17 Jun 2020 17:54:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D15EB21707 for ; Wed, 17 Jun 2020 17:54:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="D7arZ+rY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D15EB21707 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4F2906B0008; Wed, 17 Jun 2020 13:54:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A10C6B000A; Wed, 17 Jun 2020 13:54:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 390C56B000C; Wed, 17 Jun 2020 13:54:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id 1E5956B0008 for ; Wed, 17 Jun 2020 13:54:12 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 95CF656962 for ; Wed, 17 Jun 2020 17:54:11 +0000 (UTC) X-FDA: 76939452702.02.class23_430f19226e09 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 6B9AE56966 for ; Wed, 17 Jun 2020 17:54:11 +0000 (UTC) X-HE-Tag: class23_430f19226e09 X-Filterd-Recvd-Size: 4721 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Wed, 17 Jun 2020 17:54:10 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id i12so1348907pju.3 for ; Wed, 17 Jun 2020 10:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+xBJoU5J77TMSnbRZSFhHX3Dp+sjAWUA2ZPGmdFDGcg=; b=D7arZ+rYMKO6IBlJVjJzYGvWYy4BqYpAZF05mQbib4+xctfxhPHMgJMPs9OsdTnpcu DVrOdGRQq2dnBQUYNnEXySnJwVfY8E60P/9+r3H4rxc/lPrEKIn13ppMk+TSdpRqYtuF A+7xr5IzglQ1/iHADByfwxPSyoqoBNfJrQbec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+xBJoU5J77TMSnbRZSFhHX3Dp+sjAWUA2ZPGmdFDGcg=; b=NQC0gHvweQZWB+V327k3kiESpcVVc66n2je/zQoFZ4T4WsufYjeuQl+3kmcIxkQYdi lFCbZ3kw41iAP53FkjOHDi2Qe2Qrf+7x/MWHj2JdnQ87jFxTo75g9wGJjGnl5rxLVeRc yO8D/Uqvi7JyRIctadE0UVxFdVtNmRglFEI9c3pZxj20XK+Vb+V+xPGeGEAcX+kzqj6z Bec0s8GxsBhBk7EIk91hk1GROC93E2HS9CABc7+Y+iG2eUBY0AewV8sN0eFa+mLSvLKL NQ6j/z1XE/e4r06kzlPqUhouPgrx+FfGOavQYuhRt1NXfgzd1rHn+TZ/0Qjjr//4vaEX 7eGw== X-Gm-Message-State: AOAM533FPtbsj/2e3Lrr7xoxWXIaV24QZapaflZKncMnU/ZfLhRmHzbf 5KalA5s0ljyUJHGHQhQzF9zHug== X-Google-Smtp-Source: ABdhPJx+r7wpkQkHZx+QQI6IKh4SkzaSGt2+cXjyxOMdYSQaRluqVC41a1oNqCDDlrw7e8Lk4rOX/A== X-Received: by 2002:a17:902:9882:: with SMTP id s2mr238216plp.112.1592416449904; Wed, 17 Jun 2020 10:54:09 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q145sm458842pfq.128.2020.06.17.10.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 10:54:09 -0700 (PDT) Date: Wed, 17 Jun 2020 10:54:07 -0700 From: Kees Cook To: Vlastimil Babka Cc: Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com, vinmenon@codeaurora.org, Matthew Garrett , Roman Gushchin , Jann Horn , Vijayanand Jitta Subject: Re: [PATCH 6/9] mm, slub: introduce static key for slub_debug() Message-ID: <202006171050.D48F4B7@keescook> References: <20200610163135.17364-1-vbabka@suse.cz> <20200610163135.17364-7-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200610163135.17364-7-vbabka@suse.cz> X-Rspamd-Queue-Id: 6B9AE56966 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Wed, Jun 10, 2020 at 06:31:32PM +0200, Vlastimil Babka wrote: > One advantage of CONFIG_SLUB_DEBUG is that a generic distro kernel can be built > with the option enabled, but it's inactive until simply enabled on boot, > without rebuilding the kernel. With a static key, we can further eliminate the > overhead of checking whether a cache has a particular debug flag enabled if we > know that there are no such caches (slub_debug was not enabled during boot). We > use the same mechanism also for e.g. page_owner, debug_pagealloc or kmemcg > functionality. > > This patch introduces the static key and makes the general check for per-cache > debug flags kmem_cache_debug() use it. This benefits several call sites, > including (slow path but still rather frequent) __slab_free(). The next patches > will add more uses. > > Signed-off-by: Vlastimil Babka > --- > mm/slub.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 8dd2925448ae..24d3e5f832aa 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -114,13 +114,21 @@ > * the fast path and disables lockless freelists. > */ > > +#ifdef CONFIG_SLUB_DEBUG > +#ifdef CONFIG_SLUB_DEBUG_ON > +DEFINE_STATIC_KEY_TRUE(slub_debug_enabled); > +#else > +DEFINE_STATIC_KEY_FALSE(slub_debug_enabled); > +#endif > +#endif Yet another potential future user of DEFINE_STATIC_KEY_MAYBE()[1], once I get it landed. :) Reviewed-by: Kees Cook [1] https://lore.kernel.org/lkml/20200324203231.64324-2-keescook@chromium.org/ -- Kees Cook