Re: [GIT PULL] random number generator updates for 6.1-rc1

From: Jason A. Donenfeld
Date: Mon Oct 10 2022 - 14:32:48 EST


Hey Linus,

On Mon, Oct 10, 2022 at 10:48:42AM -0700, Linus Torvalds wrote:
> On Mon, Oct 3, 2022 at 10:45 AM Jason A. Donenfeld <Jason@xxxxxxxxx> wrote:
> >
> > - The original jitter algorithm intended (I believe) to schedule the timer for
> > the next jiffy, not the next-next jiffy, yet it used mod_timer(jiffies + 1),
> > which will fire on the next-next jiffy, instead of what I believe was
> > intended, mod_timer(jiffies), which will fire on the next jiffy. So fix
> > that. (If you did actually intend the next-next jiffy for this voodoo, let
> > me know and I'll happily send you a new pull.)
>
> Just as long as you verified that yes, it will actually do the next timer.
>
> At some point we had timer logic that went "trigger timer callback
> immediately if it was in the past". I didn't want to have to worry
> about that, this the "jiffies + 1".
>
> I suspect we long ago got rid of that "trigger immediately" because of
> deadlocks, and that I was just being a worry-wart about behavior that
> we haven't had for decades, so your patch looks fine. But you might
> want to make sure.

I checked this and it works. Sultan and I jumped pretty far down the
timers rabbit hole in the process of investigating 748bc4dd9e66
("random: use expired timer rather than wq for mixing fast pool"). If
you grep the kernel, expiring at "jiffies" is a fairly common pattern
too.

Jason