Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp128947rwb; Wed, 9 Nov 2022 21:23:10 -0800 (PST) X-Google-Smtp-Source: AMsMyM7DEvFyFRU2KqKfp07iG+RRlTyxgBj+KTB38IAw3aqeA70fVqvLDcA20nQfL0vg1ALHLxgP X-Received: by 2002:a17:902:e888:b0:186:a6be:1106 with SMTP id w8-20020a170902e88800b00186a6be1106mr62440115plg.150.1668057789913; Wed, 09 Nov 2022 21:23:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668057789; cv=none; d=google.com; s=arc-20160816; b=H3uvQD+W00YjtgFQNLe6nMKo8c0hc95sqi42itBlcv/sPg76OB9AzSa67criHBcEtf MLZuDP8JtPMgFxdnaNysI+GRZLQQ7XcP2vAlbpYrjuRT7zqhrn8RYlXnKHLBgnb9/1GN ZxmNebuoGYbSCmBlovPDX4jKngMH8T/bJjKxwlzyCpC2lyln1e1wXjQWiDGAkT3UBunk QK1EAOzzIKyApOWQLu2EIo0crmXm+gL72lhFVMr08KCB1IUD3TR8x4e4J16q91wX5Meq QQySWBO8FY9Sz5HBlDze4lOmQjaCbtCXb6LI8KzGS7CELREndqKlD0mJmNBc2P0qQbUJ K3wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=U9fwbckS+78K9nkD8cMTEL6vGBAQgTBmwsCi3bf0H50=; b=mQZeXteqafXuDqTFnQfKm3ejyAKGTloubvRnkAWXQzaKyghZAuwrtsw16axMDsos9k kuljpSdQRaxT+Oq5cfUy3iZx5oKBWrZ1FHpuO1AWd439lNgQARzNnPa0YKDnugKFnqew 5Sl06yy5NPkGbKr2G5Jhi8kK5mGZeKGy/pWH8E5f+y3AmtZ2QiVYZN8BTAAJW7lCcMmT wxzI2cisD0UAt56SS9AS+WyBnR7ZBfshseJHLFhgJznMMMqEYK09B+TkGb4JaJQlsPhw i8IUYPV1+CyNpdinyM9xpsRu9V2332Vi11jXiXjmzcrLNOzMFyzenVkw8iwYfzSzAB+A E22Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gcoh40LF; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f24-20020a17090a9b1800b002112dce273esi3014396pjp.118.2022.11.09.21.22.47; Wed, 09 Nov 2022 21:23:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gcoh40LF; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbiKJFRl (ORCPT + 99 others); Thu, 10 Nov 2022 00:17:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbiKJFRl (ORCPT ); Thu, 10 Nov 2022 00:17:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44E802098F; Wed, 9 Nov 2022 21:17:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DA35BB8204F; Thu, 10 Nov 2022 05:17:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BF9EC433D6; Thu, 10 Nov 2022 05:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668057457; bh=U7Ij5rr5CuBSj0KhRp8f5GgpbSuZW4Sm6iJWVpUw4pA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Gcoh40LFPAc6tVx3NzisbmxoaRi1SpDqFGBSoT1xD8fLzrMMdF0MsK4n4PePkaxjQ Xc4Jn2yx3I39PltG7smnKHuZytIclyT0Xt3t0OhNrhxT5+8fRBMPF7wIK6FVyKkcjF p0Fu66v6zh0yNr+gxZT/AIDPHMLPF5hYpSanrZE1IQJe/F+d/o5XNIFm5WNleR30a9 gc2Et23gQqUEUNe5+rXkZTZq55rS99Zuc0zPllsOiRvrueZxjnLr5VQJPd4eiHNEjX d1KQvD0GrCZU98frnIXyJEEd65EF7q9DGzghaYk1rDDTZp8jZ0vj6iBZa5p78a53Qo 6eLdaijY541bA== Date: Wed, 9 Nov 2022 21:17:35 -0800 From: Eric Biggers To: "Elliott, Robert (Servers)" Cc: "linux-crypto@vger.kernel.org" , "stable@vger.kernel.org" Subject: Re: [PATCH] crypto: avoid unnecessary work when self-tests are disabled Message-ID: References: <20221110023738.147128-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Nov 10, 2022 at 04:36:17AM +0000, Elliott, Robert (Servers) wrote: > > > -----Original Message----- > > From: Eric Biggers > > 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. That should be a separate patch, but yes, it should only run the test if !IS_ENABLED(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS), like what everywhere else does. - Eric