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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 1C9E2C433DF for ; Thu, 18 Jun 2020 08:32:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D976C204EA for ; Thu, 18 Jun 2020 08:32:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D976C204EA 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 6666C6B0029; Thu, 18 Jun 2020 04:32:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 616EE6B002A; Thu, 18 Jun 2020 04:32:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 553BF6B002B; Thu, 18 Jun 2020 04:32:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0104.hostedemail.com [216.40.44.104]) by kanga.kvack.org (Postfix) with ESMTP id 3A19C6B0029 for ; Thu, 18 Jun 2020 04:32:24 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0457D824556B for ; Thu, 18 Jun 2020 08:32:24 +0000 (UTC) X-FDA: 76941665808.06.stove92_0d0064a26e0e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id D09A81003DAD4 for ; Thu, 18 Jun 2020 08:32:23 +0000 (UTC) X-HE-Tag: stove92_0d0064a26e0e X-Filterd-Recvd-Size: 3150 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Jun 2020 08:32:23 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1EBA8AD35; Thu, 18 Jun 2020 08:32:20 +0000 (UTC) Subject: Re: [PATCH 7/9] mm, slub: introduce kmem_cache_debug_flags() To: Kees Cook 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 References: <20200610163135.17364-1-vbabka@suse.cz> <20200610163135.17364-8-vbabka@suse.cz> <202006171055.64F6EB665@keescook> From: Vlastimil Babka Message-ID: <5dcd5d95-15e9-cc17-908c-a2de9f61e97f@suse.cz> Date: Thu, 18 Jun 2020 10:32:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <202006171055.64F6EB665@keescook> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: D09A81003DAD4 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 6/17/20 7:56 PM, Kees Cook wrote: > On Wed, Jun 10, 2020 at 06:31:33PM +0200, Vlastimil Babka wrote: >> There are few places that call kmem_cache_debug(s) (which tests if any of debug >> flags are enabled for a cache) immediatelly followed by a test for a specific >> flag. The compiler can probably eliminate the extra check, but we can make the >> code nicer by introducing kmem_cache_debug_flags() that works like >> kmem_cache_debug() (including the static key check) but tests for specifig >> flag(s). The next patches will add more users. >> >> Signed-off-by: Vlastimil Babka >> --- >> mm/slub.c | 18 ++++++++++++++---- >> 1 file changed, 14 insertions(+), 4 deletions(-) >> >> diff --git a/mm/slub.c b/mm/slub.c >> index 24d3e5f832aa..c8e8b4ae2451 100644 >> --- a/mm/slub.c >> +++ b/mm/slub.c >> @@ -122,18 +122,28 @@ DEFINE_STATIC_KEY_FALSE(slub_debug_enabled); >> #endif >> #endif >> >> -static inline int kmem_cache_debug(struct kmem_cache *s) >> +/* >> + * Returns true if any of the specified slub_debug flags is enabled for the >> + * cache. Use only for flags parsed by setup_slub_debug() as it also enables >> + * the static key. >> + */ >> +static inline int kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t flags) > > This should return slab_flag_t, yes? bool, actually >> { >> #ifdef CONFIG_SLUB_DEBUG >> if (static_branch_unlikely(&slub_debug_enabled)) >> - return s->flags & SLAB_DEBUG_FLAGS; >> + return s->flags & flags; >> #endif >> return 0; >> } >> >> +static inline int kmem_cache_debug(struct kmem_cache *s) > > And this too, as long as we're making changes here. OK