Re: [PATCH] random: Fix the issue of '_might_sleep' function running in an atomic contex

From: Guoyong Wang
Date: Tue Mar 19 2024 - 05:31:29 EST


On Mon, 18 Mar 2024 21:00:42 +0100, Jason A. Donenfeld wrote:
> I'm wondering, though, rather than introducing a second function, maybe
> execute_in_process_context() should just gain a `&& !in_atomic()`.
> That'd make things a bit simpler.

> However, I'm pretty sure in_atomic() isn't actually a reliable way of
> determining that, depending on config. So maybe this should just call
> the worker always (if system_wq isn't null).

> Alternatively, any chance the call to add_input_randomness() could be
> moved outside the spinlock, or does this not look possible?

Hi Jason,

Thanks for your suggestions.

I am inclined to accept your second suggestion. My reluctance to accept
the first is due to the concern that "&& !in_atomic()" could potentially
alter the original meaning of the 'execute_in_process_context' interface.
Regarding the third suggestion, modifying the logic associated with 'input'
is not recommended.