linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: David Gow <davidgow@google.com>,
	Brendan Higgins <brendan.higgins@linux.dev>,
	Daniel Latypov <dlatypov@google.com>,
	Shuah Khan <skhan@linuxfoundation.org>
Cc: 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>,
	David Rientjes <rientjes@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2 3/3] mm: slub: test: Use the kunit_get_current_test() function
Date: Tue, 25 Oct 2022 11:07:03 +0200	[thread overview]
Message-ID: <9cfaed63-b72f-3fc8-bdc0-c6d7b09ca782@suse.cz> (raw)
In-Reply-To: <20221025071907.1251820-3-davidgow@google.com>

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;
>  



  reply	other threads:[~2022-10-25  9:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25  7:19 [PATCH v2 1/3] kunit: Provide a static key to check if KUnit is actively running tests David Gow
2022-10-25  7:19 ` [PATCH v2 2/3] kunit: Use the static key when retrieving the current test David Gow
2022-10-25  7:19 ` [PATCH v2 3/3] mm: slub: test: Use the kunit_get_current_test() function David Gow
2022-10-25  9:07   ` Vlastimil Babka [this message]
2022-10-25 14:42   ` kernel test robot
2022-10-25 22:34   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9cfaed63-b72f-3fc8-bdc0-c6d7b09ca782@suse.cz \
    --to=vbabka@suse.cz \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=brendan.higgins@linux.dev \
    --cc=cl@linux.com \
    --cc=davidgow@google.com \
    --cc=dlatypov@google.com \
    --cc=glittao@gmail.com \
    --cc=keescook@chromium.org \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox