Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2281260rwn; Fri, 16 Sep 2022 08:06:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74Z6xWuezsCZyBgN/iR4oFlZkzYCbQDn2/KUObcbv1sczfXZ7IsbxWkxK+uR1NW4/1ZgaE X-Received: by 2002:a17:903:22c2:b0:178:3c7c:18af with SMTP id y2-20020a17090322c200b001783c7c18afmr297907plg.134.1663340776423; Fri, 16 Sep 2022 08:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663340776; cv=none; d=google.com; s=arc-20160816; b=Omy6th8+lsuFzrVu98pCYtUBD8x7IkTSgzzd3upmpiaY0T97qGh0UJRhkpa+pqiIkR m+cIpJSUS4QJqUX9g4IlvJkSy0x/NQCGpdELi29FDwDytPKm7YNHfr1BjAEHRXAsOXqX earjyI74q3KUpb7wNTwDUIoeHU7TzEcFxjLnOHcObtx4ofshOwanDJFxU682dzLAAHPU caewp6vBnFGNOGA1GuLnkx5oytwZGilbjMeofMdB7BpRGy6QEYAqEbsGVu2ANTZXpb0k s2IKC6qp/Cdu0W6hRAxQgG6fXul4ctScNucxc8JNfRgCi22DDNUYGKOoZ48mCEpWUNGI cUWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=AQYiQoE1MzbspExjoxRIxp8659JqC9N66qASNbjnQqI=; b=phFbF4FuZ2oWz/mMEiwp5FJnojvgqD5MbfT1Dyf6J8wa+I7CdT4eSa1j76KAk6s4GI qmc2F6bJ4vnkYOkcITyAF8hI5GwvgVQ3ReWFr9p6ol9cBVPvByzyu9Abfr4Vb83GogKz RR81RG4Pk5pt3C7cQbQl0ONStVrmEuyaGU19mWJtxo55BBHH35MDbUPqXE+w/9wxeWnC wdw59/Dvy7ZwwTVSlSCYGsc3lSvICgB6aJB062hziwAf7jX//Tl89HvvmnfHBJgu1C5n H3IYOtIni5fP8ql/PBmRRNz7EDi7lNPnfLKyQ2N9zcTcd8PC8VobI4Sah90bZtOPVZKb 1z+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=KlnuYh1s; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020a63ef11000000b0041bb87776ebsi21521190pgh.352.2022.09.16.08.05.51; Fri, 16 Sep 2022 08:06:16 -0700 (PDT) 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=@zx2c4.com header.s=20210105 header.b=KlnuYh1s; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230287AbiIPOvF (ORCPT + 99 others); Fri, 16 Sep 2022 10:51:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbiIPOvD (ORCPT ); Fri, 16 Sep 2022 10:51:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3A98A572E; Fri, 16 Sep 2022 07:51:02 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id E2EEF62C52; Fri, 16 Sep 2022 14:51:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E58EBC43470; Fri, 16 Sep 2022 14:51:00 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="KlnuYh1s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1663339856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AQYiQoE1MzbspExjoxRIxp8659JqC9N66qASNbjnQqI=; b=KlnuYh1sIGr8iLDnyM+oR6yvdq24Mjt7ZamBZ0JSxxSGkgc4FRdQprP+5+Bjt3yAL6YIB7 yqOyyKBd6P9kvimEiqKEMUDql0NS6+PZNFNjavhEaVHVq5YER6w0tDUwuDpWXJ4FBwbo79 gRldpBdze8LjSuUu0ZMBXHkrXyE0qYE= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 1f8ea2d5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 16 Sep 2022 14:50:55 +0000 (UTC) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-3450990b0aeso262117667b3.12; Fri, 16 Sep 2022 07:50:55 -0700 (PDT) X-Gm-Message-State: ACrzQf2BAoZuRL2Uk/12ojcGA6HEUcIrGFUp9jQ8SO8ca83DtEhAguDa nFtlgTj1fy5rIS354EphiTazMUKmOvfuxKMQoKc= X-Received: by 2002:a81:d97:0:b0:348:f982:e2f7 with SMTP id 145-20020a810d97000000b00348f982e2f7mr4722516ywn.414.1663339853668; Fri, 16 Sep 2022 07:50:53 -0700 (PDT) MIME-Version: 1.0 References: <20220915002235.v2.1.I7c0a79e9b3c52584f5b637fde5f1d6f807605806@changeid> In-Reply-To: <20220915002235.v2.1.I7c0a79e9b3c52584f5b637fde5f1d6f807605806@changeid> From: "Jason A. Donenfeld" Date: Fri, 16 Sep 2022 15:50:41 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] random: move add_hwgenerator_randomness()'s wait outside function To: Sven van Ashbrook Cc: LKML , Herbert Xu , Dominik Brodowski , Olivia Mackall , Alex Levin , Andrey Pronin , Stephen Boyd , Rajat Jain , Eric Biggers , Petr Mladek , Sebastian Andrzej Siewior , "Theodore Ts'o" , linux-crypto@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 Hi Sven, On Thu, Sep 15, 2022 at 1:22 AM Sven van Ashbrook wrote: > - if (!kthread_should_stop() && crng_ready()) > - schedule_timeout_interruptible(CRNG_RESEED_INTERVAL); > + return crng_ready() ? CRNG_RESEED_INTERVAL : 0; I was thinking the other day that under certain circumstances, it would be nice if random.c could ask hwrng for more bytes NOW, rather than waiting. With the code as it is currently, this could be accomplished by having a completion event or something similar to that. With your proposed change, now it's left up to the hwrng interface to handle. That's not the end of the world, but it does mean we'd have to come up with a patch down the line that exports a hwrng function saying, "stop the delays and schedule the worker NOW". Now impossible, just more complex, as now the state flow is split across two places. Wondering if you have any thoughts about this. The other thing that occurred to me when reading this patch in context of the other one is that this sleep you're removing here is not the only sleep in the call chain. Each hwrng driver can also sleep, and many do, sometimes for a long time, blocking until there's data available, which might happen after minutes in some cases. So maybe that's something to think about in context of this patchset -- that just moving this to a delayed worker might not actually fix the issue you're having with sleeps. Jason