lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABVgOSnx8s0wL1xYEpwV0+FhyQUhbOVGWWuwpO9rfknSmbhroA@mail.gmail.com>
Date:   Tue, 22 Nov 2022 10:33:22 +0800
From:   David Gow <davidgow@...gle.com>
To:     Daniel Latypov <dlatypov@...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 Tue, Nov 22, 2022 at 9:31 AM Daniel Latypov <dlatypov@...gle.com> wrote:
>
> 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.
>

Yeah, there was no particular reason I put 'extern struct
static_key_false'. I'll change it to DECLARE_STATIC_KEY_FALSE in v3.

Cheers,
-- David

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4003 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ