Date: Tue, 21 Aug 2018 17:56:40 -0700 From: Conrad Meyer <cem@freebsd.org> To: RW <rwmaillists@googlemail.com> Cc: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: Re: rand_harvestq high cpu usage when /dev/urandom is used Message-ID: <CAG6CVpWftgLHs5AZnyT2%2BGLW2LDCtjjLb83SS94V2syC4N=_8A@mail.gmail.com> In-Reply-To: <20180822011901.6eb678cb@gumby.homeunix.com> References: <CAO3OKx_3nKDEKP_eii0QoC7DG57Y_KLrHxwJrV7r7UMRL%2BX5_A@mail.gmail.com> <20180820184337.6e07e951@gumby.homeunix.com> <20180822011901.6eb678cb@gumby.homeunix.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Aug 21, 2018 at 5:19 PM, RW via freebsd-hackers <freebsd-hackers@freebsd.org> wrote: > > I think I see what is going on. If you have a hardware entropy source > then when you read N bytes out of /dev/random, random_sources_feed() > tries to put at least that amount into each of the entropy pools (32 > for fortuna). So if you are reading at 100MB/s, you are trying to feed > 3.2GB/s into the pools. Overwriting a slow drive from /dev/random seems > to be enough to waste a CPU core my PC. Yep, I came to a similar conclusion[1]. I think you're off by a factor of two, though =E2=80=94 it's even worse than that! It tries to res= eed 64x as many bytes from the configured random sources as data read out of the random device. > Fortuna is only allowed to resend after 100ms, and anything more than > 1kB/reseed (pools*keysize) is a waste of CPU cycles. IMO > random_sources_feed() should limit itself to RANDOM_KEYSIZE bytes per > call for each pool/source combination - even that's overkill. I am less familiar on what Fortuna permits, but yeah, clearly what we have now is excessive. Best, Conrad [1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D230808#c1
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpWftgLHs5AZnyT2%2BGLW2LDCtjjLb83SS94V2syC4N=_8A>