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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4331AC433FE for ; Thu, 24 Nov 2022 10:43:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D54AC6B0072; Thu, 24 Nov 2022 05:43:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D05276B0074; Thu, 24 Nov 2022 05:43:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCD9F6B0075; Thu, 24 Nov 2022 05:43:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AF8E96B0072 for ; Thu, 24 Nov 2022 05:43:37 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 802A71C6C39 for ; Thu, 24 Nov 2022 10:43:37 +0000 (UTC) X-FDA: 80167999674.16.A9D6D09 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf22.hostedemail.com (Postfix) with ESMTP id 26971C000D for ; Thu, 24 Nov 2022 10:43:35 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so125587pjo.3 for ; Thu, 24 Nov 2022 02:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=D7o+Q8FQkVVgAzFcN2NLb4oct6J+vhahcI9ZllaC/xc=; b=ENsiMTLYW6pY+TXqiwMe9yAzE7xIxAHAvYojejnnesfbaPTF5du1evCp+LELcqgtMr wzilBepNEBUOE7+O4lTmQfemPvWz3bxjj2Hl/O3Pwwj2kOc5dvKQ1ZVhLe+ymVFQ/BO+ E1k/tmWy3r+gFaGtbElSPzOj1d5t7Q71hPD2JiwwNhtDYNbtp8Tmnd1q1j7d+mrS0UVr Tds3ILmu6Ow78KSNg4dgQGC3ZAIIEqeZmGTyBSTywL39zfkxGP4v3IKoxi++qshC4Pu7 N+aaSzPH80DmRqy9UhgaQI9g4OBKiTCY/JCx3rrQTZMw/+2lx/yiD5mumTi2kUSQAXqV RnBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=D7o+Q8FQkVVgAzFcN2NLb4oct6J+vhahcI9ZllaC/xc=; b=qAX/xCcVPwFArBmW+4HXEpXoXYni5YeMkksqiNkpqgs66Zlj5xMUiv9NekgcB3Ar0P CS5U5JYK4GX9TCQ5XVXI4c/olulncaXNRFJEuvfq59+jFdecI9sxmr6+4xZ2La39Ev3m P6sTwB25vQsXT/kTiOPy1KLvWEX5vxrHKB6OkIHsOSgvQuy27X83Vy6Qs7814+m3twAY 7gvm6zQRRdgE/uDyJ70l9XiEGyFsmTwFnxgxD90sx/Dwnst5FB+Nm0ng1l2raKjExZhN 6Rr6H5r2YliF16RQoVqOmsRjSwnnj7RVX2arV7ecse6SDR0BFmA/CDs+CRI4zFLkQp++ Zy6w== X-Gm-Message-State: ANoB5pmFU02/ksThJQC+7w6X+5jooE+sp6XVAVEcTOHxg02oEA21s+v1 8VmQqR5BSnalcN/RFdHn+j0= X-Google-Smtp-Source: AA0mqf7c9YI5PVHpS7E9uLy+27+srHAfhZGrYwmsFfYo8ZR+kxjl6k3hhHGTmywFRno2JGEJ9BHXPQ== X-Received: by 2002:a17:90a:2b0e:b0:20b:cd9:be6d with SMTP id x14-20020a17090a2b0e00b0020b0cd9be6dmr21891498pjc.198.1669286614949; Thu, 24 Nov 2022 02:43:34 -0800 (PST) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id i15-20020a17090332cf00b00185402cfedesm924727plr.246.2022.11.24.02.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 02:43:34 -0800 (PST) Date: Thu, 24 Nov 2022 19:43:27 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: David Gow Cc: Brendan Higgins , Daniel Latypov , Shuah Khan , 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 , Christoph Lameter , Vlastimil Babka , David Rientjes , Andrew Morton Subject: Re: [PATCH v3 3/3] mm: slub: test: Use the kunit_get_current_test() function Message-ID: References: <20221119081252.3864249-1-davidgow@google.com> <20221119081252.3864249-3-davidgow@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221119081252.3864249-3-davidgow@google.com> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669286616; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=D7o+Q8FQkVVgAzFcN2NLb4oct6J+vhahcI9ZllaC/xc=; b=TseeQ8IkTZ/vzSbXYUoOV85RahvbIHjXZiDKho2EAPCek2q87QSuoPrsRQ1v8/WAR3JfBM JxbaWg+nAZ/DtJhp1SMwhLd7s31ikL6oqo8vq+j2EQ9sSlFyxjpqaeuiG6cWm4/LS0Q1mf zk3u7ZrnsXWwFuC5u9vUsPF/wssRuz8= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ENsiMTLY; spf=pass (imf22.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.54 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669286616; a=rsa-sha256; cv=none; b=UuSXjz94tfMgzGYMEFFw4JNXCV/SSbzH2rpWwFWoH4y7/BsUJAZBOSK1Ck8CAOFQUza6Fy 5wHEI9aFDQCs/00XDUkM3oQdp2EKgLQk17ohb6z6GyaZvWeqxQSzDbhYCQwXb+EK6vRfmp Nz8nrslfegBLYvwLWGUsV0XdoyPiet0= X-Rspamd-Queue-Id: 26971C000D Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ENsiMTLY; spf=pass (imf22.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.54 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7fnzupn9gfkebmpe3j4q8y3e9pipq4pr X-HE-Tag: 1669286615-97507 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 Sat, Nov 19, 2022 at 04:12:52PM +0800, 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 Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> with small comment: > --- > > 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. > > We'll take this whole series via the kselftest/kunit tree. > > Changes since v2: > https://lore.kernel.org/all/20221025071907.1251820-3-davidgow@google.com/ > - Get rid of a redundant 'likely' (Thanks Vlastimil Babka) > - Use current->kunit_test directly when we already know a test is > running. (Thanks Vlastimil Babka) > - Add Vlastimil's Acked-by. > > 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 > > Cheers, > -- David > > --- > lib/slub_kunit.c | 1 + > mm/slub.c | 3 ++- > 2 files changed, 3 insertions(+), 1 deletion(-) > > 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 Is this #include needed in slub_kunit.c? > #include > #include > #include > diff --git a/mm/slub.c b/mm/slub.c > index 157527d7101b..1887996cb703 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -39,6 +39,7 @@ > #include > #include > #include > +#include > #include > > #include > @@ -603,7 +604,7 @@ static bool slab_add_kunit_errors(void) > { > struct kunit_resource *resource; > > - if (likely(!current->kunit_test)) > + if (!kunit_get_current_test()) > return false; > > resource = kunit_find_named_resource(current->kunit_test, "slab_errors"); > -- > 2.38.1.584.g0f3c55d4c2-goog > -- Thanks, Hyeonggon