Messages in this thread | | | From | "Jason A. Donenfeld" <> | Date | Fri, 11 Feb 2022 14:04:52 +0100 | Subject | Re: [PATCH] random: ensure mix_interrupt_randomness() is consistent |
| |
Sorry, missed this in your last email:
On Fri, Feb 11, 2022 at 9:16 AM Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote: > > + do { > > + count_snapshot = (unsigned int)atomic_read(&fast_pool->count); > > + for (i = 0; i < ARRAY_SIZE(pool); ++i) > > + pool[i] = READ_ONCE(fast_pool->pool_long[i]); > > Why do you avoid memcpy()? Since it is a small memcpy, I'm sure the > compile will inline the register moves.
Because the compiler will otherwise reorder it to be after the two counter reads. I checked. And a barrier() is too heavy as it flushes the writes to the stack instead of keeping them read into registers. READ_ONCE() is the exact semantics we care about here.
Jason
| |