Message ID | 20221025071907.1251820-3-davidgow@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp859912wru; Tue, 25 Oct 2022 00:33:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66/G+/ikp+tqtJEQLz0Na5IwziiqLzW0Wos1tMx8QokvSGpPcsena0jA0kkzq6YGjdmq9d X-Received: by 2002:a17:903:40cb:b0:17f:6e08:6eac with SMTP id t11-20020a17090340cb00b0017f6e086eacmr37531102pld.80.1666683229724; Tue, 25 Oct 2022 00:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666683229; cv=none; d=google.com; s=arc-20160816; b=s2RO5Y7LYyzTIi1NotHAIb5kUNHCLs3A33aGXnz9nDt07WaO68eTtqWR6RByXtcG6N IFfDQJVMpDDnCRgpLKRvVQ3NOkb3SKaRGLV530bvKG3KrqadJrmmKoKjnmv2FseG1+UN ptPUECcctnpDqkdzTKiC9nsqksCMxvYAXb0pJgyC118TcFXGloo+PLxSUQcP2GjHz+6v 61WoAzIkRFYqg1am3L/+Qt5gBfGhMteRK9RRJY86v8Z9WiVXTZEM9F6FiudNY+1hzh2m unmAspevxVSF3Y6cSxDRH84S9HyQd79pKHc3FdF2MudHJ5qljuZ5rbOmCVt68C5mp0r6 n/sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=KA5AmQjfCAbtpdHkGDjwVts9T7CuDkkry+0zPgKF0lM=; b=IgqRhHNYIdIidMr9UV//7GXlV4H8jy4vgs6lrhRybrDvvr+YARFtZjcgl32sqRvndo i9r76SaLsLI13BdOoQBcaOY7heATtby1l0th9jNJbNljqA17V6Ml26tXvfa2JPbqPNwm A333iu1vOEDlykZRYYM1dtHuOhTDjujB3TRtJ7wiHoKzkxanf+L7S6tM40hlQ6iD2C5o Yn9/MyYOZsidnkxgwiV7FdUU1E4pyEGHp9obPLfdOgeyCd4j8vI8gG+SGxiJvePbtFg2 HCONLXVKUJaZzRSTpOCSi9xLc6NaaRvnQ9fa8B2V81ucoSrrlYuNfzBuxNcimfGO7Irf vNDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ho9NvHEq; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a170902d88d00b001868ef35f09si2198858plz.258.2022.10.25.00.33.36; Tue, 25 Oct 2022 00:33:49 -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=@google.com header.s=20210112 header.b=ho9NvHEq; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231486AbiJYHTs (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Tue, 25 Oct 2022 03:19:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231629AbiJYHTd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Oct 2022 03:19:33 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5C012BE09 for <linux-kernel@vger.kernel.org>; Tue, 25 Oct 2022 00:19:30 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-360a7ff46c3so111050707b3.12 for <linux-kernel@vger.kernel.org>; Tue, 25 Oct 2022 00:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=KA5AmQjfCAbtpdHkGDjwVts9T7CuDkkry+0zPgKF0lM=; b=ho9NvHEqLfDplAjRx3uXKJiU3DoSROQtKqQ8jRhFd0Ck3bp2UOpw8N9lYdxjatKuYv co/P5Nk6CLcK/+U9EK4lL66rumOXMbWTwndY1+zqeBCGNIjWtMZexvP1r8fzZLGhIbkU URsp7CuLP4czyMYdx7nshdoj5wFvyKDgBctnpRho0U/7PipKMJWU+msjlZHwvoClSw6O EvgkK+rfUfDrf/fynysJgKuFNt/SnjNJ/7x0wc8t7u3GvmcbGHIzDOGamTDQO4RMxpdU hh8nQ1fXv3LVNN0nD4AItp5Or8XNWSODER0ITRmk2Az9YLODBHDSLXNZo3mhj/LYKCQs eyxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KA5AmQjfCAbtpdHkGDjwVts9T7CuDkkry+0zPgKF0lM=; b=MvJTt1GvyBc5fnPmee/coaae5ECv1CxyLCHGaon7dYwcNa4srNE93k44RQZ+lfkGSF 1GrC7R/P0r/OZCZY4GJcA1rkmRIL6RhEACTqgjyDzcyv5jnDjsZxLHJSjoERXRQ1BMz9 5gxMgSwEjgQscOOOmaSFTCDdPC8k4pLN5rilj4d+kRAkm2fa34evef3kap+neePdy9tJ 2WbX5pUz3dHP65bjztPTV56gpSGxFyUXzMClJqr3KdBpKvlc77ZQ7GRGgxikWZz635Ei 4l9D3ABJvwSExaHiL8zfuLQ0t904LOab3DgKoDlPSD78eLHA9Su7PVZ3ZeS74sAPIRMN BN0A== X-Gm-Message-State: ACrzQf26em5UTwTXzrdPnN2rWEmcFC9BpdkZfDcc6IGIadvBV5x4VmYW 6ZUCeI2r5yF3o7sBrRL2bUEmOBvZlU2J4g== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a81:6907:0:b0:34a:51ce:3b38 with SMTP id e7-20020a816907000000b0034a51ce3b38mr32787158ywc.151.1666682369948; Tue, 25 Oct 2022 00:19:29 -0700 (PDT) Date: Tue, 25 Oct 2022 15:19:07 +0800 In-Reply-To: <20221025071907.1251820-1-davidgow@google.com> Mime-Version: 1.0 References: <20221025071907.1251820-1-davidgow@google.com> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog Message-ID: <20221025071907.1251820-3-davidgow@google.com> Subject: [PATCH v2 3/3] mm: slub: test: Use the kunit_get_current_test() function From: David Gow <davidgow@google.com> To: Brendan Higgins <brendan.higgins@linux.dev>, Daniel Latypov <dlatypov@google.com>, Shuah Khan <skhan@linuxfoundation.org> Cc: David Gow <davidgow@google.com>, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>, linux-doc@vger.kernel.org, linux-mm@kvack.org, Oliver Glitta <glittao@gmail.com>, Hyeonggon Yoo <42.hyeyoo@gmail.com>, Christoph Lameter <cl@linux.com>, Vlastimil Babka <vbabka@suse.cz>, David Rientjes <rientjes@google.com>, Andrew Morton <akpm@linux-foundation.org> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747644034753459694?= X-GMAIL-MSGID: =?utf-8?q?1747644034753459694?= |
Series |
[v2,1/3] kunit: Provide a static key to check if KUnit is actively running tests
|
|
Commit Message
David Gow
Oct. 25, 2022, 7:19 a.m. UTC
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 <glittao@gmail.com>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Gow <davidgow@google.com>
---
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.
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(-)
Comments
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 <glittao@gmail.com> > Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> > Cc: Christoph Lameter <cl@linux.com> > Cc: Vlastimil Babka <vbabka@suse.cz> > Cc: David Rientjes <rientjes@google.com> > Cc: Andrew Morton <akpm@linux-foundation.org> > Signed-off-by: David Gow <davidgow@google.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> > --- > > 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 <kunit/test.h> > +#include <kunit/test-bug.h> > #include <linux/mm.h> > #include <linux/slab.h> > #include <linux/module.h> > 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 <linux/memcontrol.h> > #include <linux/random.h> > #include <kunit/test.h> > +#include <kunit/test-bug.h> > #include <linux/sort.h> > > #include <linux/debugfs.h> > @@ -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; >
Hi David,
I love your patch! Yet something to improve:
[auto build test ERROR on vbabka-slab/for-next]
[also build test ERROR on kees/for-next/pstore linus/master v6.1-rc2 next-20221025]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221025-152023
base: git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git for-next
patch link: https://lore.kernel.org/r/20221025071907.1251820-3-davidgow%40google.com
patch subject: [PATCH v2 3/3] mm: slub: test: Use the kunit_get_current_test() function
config: s390-defconfig (attached as .config)
compiler: s390-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/048f50673812037a89a222fd04beaeaa59a2c2bb
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221025-152023
git checkout 048f50673812037a89a222fd04beaeaa59a2c2bb
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> s390-linux-ld: mm/slub.o:(__jump_table+0xc8): undefined reference to `kunit_running'
s390-linux-ld: mm/slub.o: `kunit_running' non-PLT reloc for symbol defined in shared library and accessed from executable (rebuild file with -fPIC ?)
s390-linux-ld: final link failed: bad value
pahole: .tmp_vmlinux.btf: No such file or directory
.btf.vmlinux.bin.o: file not recognized: file format not recognized
Hi David,
I love your patch! Yet something to improve:
[auto build test ERROR on vbabka-slab/for-next]
[also build test ERROR on kees/for-next/pstore linus/master v6.1-rc2 next-20221025]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221025-152023
base: git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git for-next
patch link: https://lore.kernel.org/r/20221025071907.1251820-3-davidgow%40google.com
patch subject: [PATCH v2 3/3] mm: slub: test: Use the kunit_get_current_test() function
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/048f50673812037a89a222fd04beaeaa59a2c2bb
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221025-152023
git checkout 048f50673812037a89a222fd04beaeaa59a2c2bb
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
m68k-linux-ld: mm/slub.o: in function `slab_add_kunit_errors':
>> slub.c:(.text+0x1262): undefined reference to `kunit_running'
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 <kunit/test.h> +#include <kunit/test-bug.h> #include <linux/mm.h> #include <linux/slab.h> #include <linux/module.h> 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 <linux/memcontrol.h> #include <linux/random.h> #include <kunit/test.h> +#include <kunit/test-bug.h> #include <linux/sort.h> #include <linux/debugfs.h> @@ -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())) return false; - resource = kunit_find_named_resource(current->kunit_test, "slab_errors"); + resource = kunit_find_named_resource(kunit_get_current_test(), "slab_errors"); if (!resource) return false;