[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGS_qxqyyH-v4wMJyD1phPP2YA5_6L98C-t4cJtt_SYsSvR3Ag@mail.gmail.com>
Date: Mon, 21 Nov 2022 17:31:03 -0800
From: Daniel Latypov <dlatypov@...gle.com>
To: David Gow <davidgow@...gle.com>
Cc: Brendan Higgins <brendan.higgins@...ux.dev>,
Shuah Khan <skhan@...uxfoundation.org>,
kunit-dev@...glegroups.com, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org, Kees Cook <keescook@...omium.org>,
linux-doc@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH v3 1/3] kunit: Provide a static key to check if KUnit is
actively running tests
On Sat, Nov 19, 2022 at 12:13 AM David Gow <davidgow@...gle.com> wrote:
>
> KUnit does a few expensive things when enabled. This hasn't been a
> problem because KUnit was only enabled on test kernels, but with a few
> people enabling (but not _using_) KUnit on production systems, we need a
> runtime way of handling this.
>
> Provide a 'kunit_running' static key (defaulting to false), which allows
> us to hide any KUnit code behind a static branch. This should reduce the
> performance impact (on other code) of having KUnit enabled to a single
> NOP when no tests are running.
>
> Note that, while it looks unintuitive, tests always run entirely within
> __kunit_test_suites_init(), so it's safe to decrement the static key at
> the end of this function, rather than in __kunit_test_suites_exit(),
> which is only there to clean up results in debugfs.
>
> Signed-off-by: David Gow <davidgow@...gle.com>
Reviewed-by: Daniel Latypov <dlatypov@...gle.com>
I didn't know anything about the static key support in the kernel
before this patch.
But from what I read and saw of other uses, this looks good to me.
One small question/nit about how we declare the key below.
<snip>
> +/* Static key: true if any KUnit tests are currently running */
> +extern struct static_key_false kunit_running;
Is there any documented preference between this and
DECLARE_STATIC_KEY_FALSE(kunit_running);
?
I see 89 instances of this macro and 45 of `extern struct static_key_false`.
So I'd vote for the macro since it seems like the newer approach and
more common.
Daniel
Powered by blists - more mailing lists