Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3259451lfo; Mon, 23 May 2022 00:11:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze6L9cQldygtlbWls3JiF2Nh0S3um+m9M2kTkK/GWoSapDmusafKKnYssJiXJQtfs9M6KI X-Received: by 2002:a63:6a85:0:b0:3fa:722a:fbdc with SMTP id f127-20020a636a85000000b003fa722afbdcmr1639594pgc.174.1653289911153; Mon, 23 May 2022 00:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653289911; cv=none; d=google.com; s=arc-20160816; b=CLvDbJlCV/UtYeY+WyH0QjQoxasx11vwHEcNfBsD7mpRjToc9IaEh6BBWJy0VFFVyv dwD/oy6uQSD5v2ebMjYf1HnPL+UAORsKXNGHpeOzgTI3YvQWMAjG149EeYfvCHleimdH 6PHgRvFThQqLZAbO7jPAkDoretiLQ8qT+4izlHPmNqN2jnRmU7QY6ra96ZlA99WlFUJf XTUriAbj4k0zd7uY1c+U6KPTmW3p9j9sGLYEkCo4X8NlTND/lVFkptPngD/MFh5iOb29 U56MmkHMjqnxzXpn5rqgwJ9l8eIF4rZwSUcxvc02DXactl7d9yCvONEgh4pCmxAJBzvq 70RQ== 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=UxK/166niZcoEyIlhxcsA5FExBrWFEE1gjPJTAretrY=; b=xkrBH4Hpdj0KOIzNgW5ehEA3EJqhIbX9QmLuxQaiy82vSgTeuCKGYQWJiVcptKpzvV kMgLbDaSHHnvMyITvFnIII8pxcOMQoMV4ZTtBre+p5rHBVnO8PN8yQrJJ9SOHrhqOID4 cbID+flmXISEV0ybldcndCaKKSzQOLMCyBRYtPmTKwuCSnIzMqz6NZN9kkUArGMqATXc 9CrVrilwO22/SzAul3AGw12XVmFoUqOVcvOOuopIXezyMO6OiKlBzuMo2ckBwtLPw4S3 Ch1MmZj97Af7tYHWDMgS6WXvXXY2KE8z7mWslroA8/U26h0hwWW+R+Lh8h4LS775NOib mKew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=jvghYB3M; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z19-20020a63c053000000b003c1570c0b89si9356549pgi.91.2022.05.23.00.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:11:51 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=jvghYB3M; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4F76E49F36; Sun, 22 May 2022 23:30:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351283AbiETQDk (ORCPT + 99 others); Fri, 20 May 2022 12:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351327AbiETQDg (ORCPT ); Fri, 20 May 2022 12:03:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD2ED17997B for ; Fri, 20 May 2022 09:03:28 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7AE30B82C7C for ; Fri, 20 May 2022 16:03:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EE89C34100; Fri, 20 May 2022 16:03:25 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="jvghYB3M" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1653062604; 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=UxK/166niZcoEyIlhxcsA5FExBrWFEE1gjPJTAretrY=; b=jvghYB3Mjr+uTh0z/fUkliKoagb2JlTzh/cpznczbWeL8ctfatbWEGAuk30sf8cC6yLfYw BJRv3GvSOroLh7RWTNwR0Qk25GcXDyiUNpoz7IRQ4iwA1K1Hnt56xf6SuPWK913R7e3P6f hw6Y4jY5vhbz668pUlRZft2ZXTW7OhI= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 428e6b79 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Fri, 20 May 2022 16:03:23 +0000 (UTC) Date: Fri, 20 May 2022 18:03:22 +0200 From: "Jason A. Donenfeld" To: Jens Axboe Cc: Theodore Ts'o , Christoph Hellwig , LKML , Al Viro Subject: Re: [PATCH v4 0/3] random: convert to using iters, for Al Viro Message-ID: References: <20220520094459.116240-1-Jason@zx2c4.com> <0a6ed6b9-0917-0d83-5c45-70ff58fad429@kernel.dk> <79024675-9a4a-cb2b-a0ed-91067ef05783@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <79024675-9a4a-cb2b-a0ed-91067ef05783@kernel.dk> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-kernel@vger.kernel.org Hi Jens, On Fri, May 20, 2022 at 09:58:28AM -0600, Jens Axboe wrote: > On 5/20/22 9:55 AM, Jason A. Donenfeld wrote: > > Hi Jens, > > > > On Fri, May 20, 2022 at 09:44:25AM -0600, Jens Axboe wrote: > >> Ran 32, 1k, 4k here and it does seem to be down aboout 3%. Which is > >> definitely bigger than I expected, particularly for larger reads. If > >> anything, the 32b read seems comparably better than eg 1k or 4k, which > >> is also unexpected. Let me do a bit of profiling to see what is up. > > > > Something to keep in mind wrt 32b is that for complicated crypto > > reasons, the function has this logic: > > > > - If len <= 32, generate one 64 byte block and give <= 32 bytes of it to > > the caller. > > > > - If len > 32, generate one 64 byte block, but give 0 of it to the > > caller. Then generate ?len/64? blocks for the caller. > > > > Put together, this means: > > > > - 1..32, 1 block > > - 33..64, 2 blocks > > - 65..128, 3 blocks > > - 129..196, 4 blocks > > > > So you get this sort of shelf where the amortization benefits don't > > really kick in until after 3 blocks. > > Ah I see, I can see if 64b is closer to the change for eg 1k. What I meant by providing all that detail is that from a cycles-per-byte perspective, smaller=more expensive. So it's possible that the difference in the patchset is less visible as it gets lost in the more expensive operation. > >> If you're worried about it, I'd just keep the read/write and add the > >> iter variants on the side. > > > > Not a chance of that. These functions are already finicky as-is; I would > > really hate to have to duplicate all of these paths. > > Then I'd say there are only two options: > > - Add a helper that provides splice for something that only has > read/write set. That'd be fine with me, but wouldn't it involve bringing back set_fs(), because of the copy_to_user() in there? > - Just accept that we're 3% slower reading from /dev/urandom for now, > and maybe 1-2% for small reads. Can't really imagine this being a huge > issue, how many high throughput /dev/urandom read situations exist in > the real world? An option three might be that eventually the VFS overhead is worked out and read_iter() reaches parity. One can hope, I guess. Jason