Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8088899rwi; Tue, 25 Oct 2022 02:15:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Hd/wZ/B1hZBDGpfdOFw8Z1HK9bqrTikaIVnKW6KhudUUInQOGeeJTmKICILHGu+Z7ctTn X-Received: by 2002:a65:40c8:0:b0:434:dfee:8dc1 with SMTP id u8-20020a6540c8000000b00434dfee8dc1mr32954134pgp.156.1666689313520; Tue, 25 Oct 2022 02:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666689313; cv=none; d=google.com; s=arc-20160816; b=ZfIrWL7iV+ehyv+HkEfdDNu+e79qRFUq+t4wFNnLj/FTxYGcTIeUYTY8eYuM5CRb9Q z9AWSbyqI65WaWIqU79BxFF86WKJNoJbqgFMMEDSkMCTraZI/uQrN3bCb7G+Fm3Oe1Lv 420kgcHQWFYbUdEakuIMmSeen07kt0RiMxbnyi3N87XCakZs7Ym2MAcOczliyNueSp33 mUzfTU3+k+7bOHvxQ0ES9jEwEuZaRQ8VrpgfTYdyYoW6rr6mgMt6jxEVoLLgc/87ybXq ZypPJMwfc5nSqv0aC+k6XZ/0ckykkBs7SSYj3eIYRTUYyBUDx2fztMxZTMw7djx1yYHq o2Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=YetzJ42X/TiFjkjg0wNAE3EFsDAzc7c8MsipxnbCcxE=; b=qwDFALgxVlVFBCm/2qBUee4gPkSIftBMVKDe1js/uklaKTfR/tdUvjNmD43PgZNe7m ZqhkbB06bIKKAsJlyRdLSoTkw3P5/bsMuP8ZInc4nlPoivQhLKcu/skGMK9uayBZAuer IYm/oW/VzSVPgGdZe44VLToHz7k+M7NL2VdzcQqixlHKAwFUXR4mN2oS2AJ1MjlxXFpQ LOUQ86f/VK74wrCwEuj7yMRE0ebH0gcBu3mzcDJ9hFe9iIShm9radNdO1JqH38U89XRh 6WpZ/1s9kq2sc6hoq9R/3h4i/N3QBXpTlgRqO7MMGDklu5Adx78iU2XwRN2nejh5qvgf Y3Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=IkqV6NNE; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=bjHzj+Rm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w5-20020a056a0014c500b00567719e34aesi3145174pfu.49.2022.10.25.02.15.01; Tue, 25 Oct 2022 02:15:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=IkqV6NNE; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=bjHzj+Rm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231860AbiJYJNx (ORCPT + 99 others); Tue, 25 Oct 2022 05:13:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231854AbiJYJNi (ORCPT ); Tue, 25 Oct 2022 05:13:38 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B84A17650D; Tue, 25 Oct 2022 02:07:13 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DC3A11FDAB; Tue, 25 Oct 2022 09:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1666688823; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YetzJ42X/TiFjkjg0wNAE3EFsDAzc7c8MsipxnbCcxE=; b=IkqV6NNEd0j9tEUH8n8P5TVYq8QJcf2qkkSZvtymyDkC0UHOtNJyMFPc1+Nz7jmv3G2JWK 3Y4SbGFuVysX2qUopbLtx8JqMj7S4N8Kred7MqPi7Lalf47QOfVbpe9q7yuK97Ts76YBD3 0LthdTBMm+u1MkbQEQE/azZglriD4Yk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1666688823; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YetzJ42X/TiFjkjg0wNAE3EFsDAzc7c8MsipxnbCcxE=; b=bjHzj+RmUQN889rrCKhbHre+JjtU2MXgeAiJQesFc1MOfiqGUlqdHWmNFq1GxdPrI/zTV5 kzxoeEfEn3/pvFCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A4EBD134CA; Tue, 25 Oct 2022 09:07:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id BGB8JzenV2NbNQAAMHmgww (envelope-from ); Tue, 25 Oct 2022 09:07:03 +0000 Message-ID: <9cfaed63-b72f-3fc8-bdc0-c6d7b09ca782@suse.cz> Date: Tue, 25 Oct 2022 11:07:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: [PATCH v2 3/3] mm: slub: test: Use the kunit_get_current_test() function To: David Gow , Brendan Higgins , Daniel Latypov , Shuah Khan Cc: kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , linux-doc@vger.kernel.org, linux-mm@kvack.org, Oliver Glitta , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Christoph Lameter , David Rientjes , Andrew Morton References: <20221025071907.1251820-1-davidgow@google.com> <20221025071907.1251820-3-davidgow@google.com> Content-Language: en-US From: Vlastimil Babka In-Reply-To: <20221025071907.1251820-3-davidgow@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_SOFTFAIL,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/25/22 09:19, David Gow wrote: > Use the newly-added function kunit_get_current_test() instead of > accessing current->kunit_test directly. This function uses a static key > to return more quickly when KUnit is enabled, but no tests are actively > running. There should therefore be a negligible performance impact to > enabling the slub KUnit tests. > > Other than the performance improvement, this should be a no-op. > > Cc: Oliver Glitta > Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> > Cc: Christoph Lameter > Cc: Vlastimil Babka > Cc: David Rientjes > Cc: Andrew Morton > Signed-off-by: David Gow Acked-by: Vlastimil Babka > --- > > This is intended as an example use of the new function. Other users > (such as KASAN) will be updated separately, as there would otherwise be > conflicts. > > Assuming there are no objections, we'll take this whole series via the > kselftest/kunit tree. OK, please do. Some possible improvements below: > There was no v1 of this patch. v1 of the series can be found here: > https://lore.kernel.org/linux-kselftest/20221021072854.333010-1-davidgow@google.com/T/#u > > --- > lib/slub_kunit.c | 1 + > mm/slub.c | 5 +++-- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c > index 7a0564d7cb7a..8fd19c8301ad 100644 > --- a/lib/slub_kunit.c > +++ b/lib/slub_kunit.c > @@ -1,5 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0 > #include > +#include > #include > #include > #include > diff --git a/mm/slub.c b/mm/slub.c > index 157527d7101b..15d10d250ef2 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -39,6 +39,7 @@ > #include > #include > #include > +#include > #include > > #include > @@ -603,10 +604,10 @@ static bool slab_add_kunit_errors(void) > { > struct kunit_resource *resource; > > - if (likely(!current->kunit_test)) > + if (likely(!kunit_get_current_test())) Given that kunit_get_current_test() is basically an inline !static_branch_unlikely(), IMHO the likely() here doesn't add anything and could be removed? > return false; > > - resource = kunit_find_named_resource(current->kunit_test, "slab_errors"); > + resource = kunit_find_named_resource(kunit_get_current_test(), "slab_errors"); We just passed kunit_get_current_test() above so maybe we could just keep using current->kunit_test here? Seems unnecessary adding another jump label. > if (!resource) > return false; >