Re: [PATCH RFC v1] random: do not take spinlocks in irq handler

From: Jason A. Donenfeld
Date: Sat Feb 05 2022 - 07:51:19 EST


Hi Sultan,

On Sat, Feb 5, 2022 at 5:02 AM Sultan Alsawaf <sultan@xxxxxxxxxxxxxxx> wrote:
> The __this_cpu_{ATOMIC_OP}() functions are for atomically performing a single
> per-CPU operation for the current CPU from contexts that permit CPU migration.
> Since this code is safe from CPU migrations (add_interrupt_randomness() runs in
> hardirq context), the atomic per-CPU helpers are unneeded. Instead of using
> __this_cpu_inc_return() and __this_cpu_or(), we can operate on the per-CPU
> pointer directly without any extra safety (e.g., `++fast_pool->count` can be
> used in place of `__this_cpu_inc_return(irq_randomness.count)`).

Oh, right, thanks. We're already in irq so we don't have to worried
about load,add,store being cut up in any way. I'll go back to simple
increments for v3.

Jason