From: "Elliott, Robert (Servers)" <elliott@hpe.com>
To: Eric Biggers <ebiggers@kernel.org>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>
Cc: "stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] crypto: avoid unnecessary work when self-tests are disabled
Date: Thu, 10 Nov 2022 04:36:17 +0000 [thread overview]
Message-ID: <MW5PR84MB18426B2DDE014FBE9F91C016AB019@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20221110023738.147128-1-ebiggers@kernel.org>
> -----Original Message-----
> From: Eric Biggers <ebiggers@kernel.org>
> Sent: Wednesday, November 9, 2022 8:38 PM
> Subject: [PATCH] crypto: avoid unnecessary work when self-tests are
> disabled
>
> Currently, registering an algorithm with the crypto API always causes a
> notification to be posted to the "cryptomgr", which then creates a
> kthread to self-test the algorithm. However, if self-tests are disabled
> in the kconfig (as is the default option), then this kthread just
> notifies waiters that the algorithm has been tested, then exits.
>
> This causes a significant amount of overhead, especially in the kthread
> creation and destruction, which is not necessary at all. For example,
> in a quick test I found that booting a "minimum" x86_64 kernel with all
> the crypto options enabled (except for the self-tests) takes about 400ms
> until PID 1 can start. Of that, a full 13ms is spent just doing this
> pointless dance, involving a kthread being created, run, and destroyed
> over 200 times. That's over 3% of the entire kernel start time.
>
> Fix this by just skipping the creation of the test larval and the
> posting of the registration notification entirely, when self-tests are
> disabled. Also compile out the unnecessary code in algboss.c.
>
...
> +#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
> +static int cryptomgr_schedule_test(struct crypto_alg *alg)
> +{
> + return 0;
> +}
> +#else
The crypto/kdf_sp800108.c init function currently ignores both
CONFIG_CRYPTO_MANAGER_DISABLE_TESTS and the cryptomgr module's
notests module parameter and always runs its self-test, as described in
https://lore.kernel.org/lkml/MW5PR84MB1842811C4EECC0F4B35B5FB3AB709@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM/T/#t
Paul reported that taking 262 ms on his system; I measured 1.4 s on
my system.
It'd be nice if a patch series improving how DISABLE_TESTS is honored
would tackle that module too.
next prev parent reply other threads:[~2022-11-10 4:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 2:37 [PATCH] crypto: avoid unnecessary work when self-tests are disabled Eric Biggers
2022-11-10 4:36 ` Elliott, Robert (Servers) [this message]
2022-11-10 5:17 ` Eric Biggers
2022-11-10 5:38 ` Eric Biggers
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=MW5PR84MB18426B2DDE014FBE9F91C016AB019@MW5PR84MB1842.NAMPRD84.PROD.OUTLOOK.COM \
--to=elliott@hpe.com \
--cc=ebiggers@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=stable@vger.kernel.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