From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id AD5B93857B81 for ; Thu, 30 Jun 2022 19:37:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AD5B93857B81 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-101ec2d6087so642966fac.3 for ; Thu, 30 Jun 2022 12:37:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=8bdCGgD6XuRQzuASSvsMPA1ZFtSPwXd97wnb2SujXTk=; b=kMPEPpi91DxpQjFbzHctH1Vqm9NwbQs9M2BbkOCEmKgPqfYBWwn1oBcTO1RMvVV882 duqUfFdvOTE1u67+pYgTauKkP44hbFD9yli+Ah+deqFauyWuF2k/woZqSnEOYw5qn6uB LeY5v7Nm+obwxs9V1x451gKDs+bY9sMXmtGGDs8Ec8X0QM0tDZ4+NOyT0sQ1Cdn1EoEF G3v6/MTgy3pC8/vcI9zs0FCkyxAjxIs8Vb+mZAKdneg4O9ZOmNyePyVRGQKfZRShGZH0 TnUYK5WsX5+P5OBgUDhky/uaPnwMN/7IJ4j2iTp6p3D0iwSfNiJLQiBBmHB0hFU8OW4r BxUQ== X-Gm-Message-State: AJIora+Z8nRvobXnBcMTGmv5YVt7fqSJ44CViZqnRm8/eoUlBylQM2ja +c/qQXK8bfJWHmy7xqgWPG+x8w== X-Google-Smtp-Source: AGRyM1vB7y2W52fI+1q2Xj6a1T0cYK8habWFa3sppfnIX1Odh+jpv27H+sQwfTLjLz3JOJEtmKnkNw== X-Received: by 2002:a05:6870:1601:b0:101:5e61:d8ee with SMTP id b1-20020a056870160100b001015e61d8eemr6093813oae.244.1656617863008; Thu, 30 Jun 2022 12:37:43 -0700 (PDT) Received: from smtpclient.apple ([2804:431:c7cb:fef6:fd34:dd0e:e18b:18e6]) by smtp.gmail.com with ESMTPSA id i2-20020aca2b02000000b00325cda1ff87sm10475469oik.6.2022.06.30.12.37.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jun 2022 12:37:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: [PATCH v8 9/9] manual: Add documentation for arc4random functions From: Adhemerval Zanella In-Reply-To: Date: Thu, 30 Jun 2022 16:37:40 -0300 Cc: GNU C Library , Florian Weimer , Yann Droneaud Content-Transfer-Encoding: quoted-printable Message-Id: <31849D69-B9BC-466E-A972-6BCE8DCAC0C3@linaro.org> References: <20220629213428.3065430-1-adhemerval.zanella@linaro.org> <20220629213428.3065430-10-adhemerval.zanella@linaro.org> <1471BD6A-8680-41E9-9FE5-B1DC45940264@linaro.org> To: Noah Goldstein X-Mailer: Apple Mail (2.3696.100.31) X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2022 19:37:46 -0000 > On 29 Jun 2022, at 19:05, Noah Goldstein = wrote: >=20 > On Wed, Jun 29, 2022 at 2:53 PM Adhemerval Zanella > wrote: >>=20 >>=20 >>=20 >>> On 29 Jun 2022, at 18:45, Noah Goldstein = wrote: >>>=20 >>> On Wed, Jun 29, 2022 at 2:36 PM Adhemerval Zanella via Libc-alpha >>> wrote: >>>>=20 >>>> --- >>>> manual/math.texi | 45 +++++++++++++++++++++++++++++++++++++++++++++ >>>> 1 file changed, 45 insertions(+) >>>>=20 >>>> diff --git a/manual/math.texi b/manual/math.texi >>>> index 477a18b6d1..ab96726e57 100644 >>>> --- a/manual/math.texi >>>> +++ b/manual/math.texi >>>> @@ -1447,6 +1447,7 @@ systems. >>>> * ISO Random:: @code{rand} and friends. >>>> * BSD Random:: @code{random} and friends. >>>> * SVID Random:: @code{drand48} and friends. >>>> +* High Quality Random:: @code{arc4random} and friends. >>>> @end menu >>>>=20 >>>> @node ISO Random >>>> @@ -1985,6 +1986,50 @@ This function is a GNU extension and should = not be used in portable >>>> programs. >>>> @end deftypefun >>>>=20 >>>> +@node High Quality Random >>>> +@subsection High Quality Random Number Functions >>>> + >>>> +This section describes the random number functions provided as a = GNU >>>> +extension, based on OpenBSD interfaces. >>>> + >>>> +@Theglibc{} uses kernel entropy obtained either through = @code{getrandom} >>>> +or by reading @file{/dev/urandom} to seed and periodically re-seed = the >>>> +internal state. A per-thread data pool is used, which allows fast = output >>>> +generation. >>>> + >>>=20 >>> Are we committing to per-thread data pools? I thought there were = ideas to >>> use rseq. >>=20 >> For this version yes, since it works on all supported kernels (even = for the >> ones without getentropy support) and on all architectures. I do not = know how >> feasible it would be to implement per-cpu caches along with rseq and = it would >> require a fallback for older kernel (most likely a per-thread cache = as this >> version), although it might be future improvement. >=20 > I guess do we want to explicitly say per-thread buffer if we may want > to experiment > with something else? >=20 > Just seems like the kind of thing that might make it impossible to = re-implement > another way. >=20 > What about something like: >=20 > "The data-pool is implemented to minimize cross-core contention > allowing fast output generation=E2=80=9D? I take the idea is to avoid adding too much implementation detail to = manual, although I take that documentation and arc4random specification does not define performance or complexity details (as for some STL containers for instance). If we even change the arc4random implementation I would = expect to update this documentation description. But iIt does make sense to define expectations, so I will update with = your suggestion (and Yann remarks).