On Thu, Nov 10, 2022 at 12:13:41AM -0800, Eric Biggers wrote: > From: Eric Biggers <ebiggers@xxxxxxxxxx> > > 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. > > Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx> > --- > crypto/algapi.c | 151 ++++++++++++++++++++++++++---------------------- > 1 file changed, 82 insertions(+), 69 deletions(-) FYI, I realized that this patch breaks CRYPTO_MSG_ALG_LOADED (it isn't always sent now). So I'll have to send a new version at least for that. - Eric