lkml.org 
[lkml]   [2022]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] random: remove batched entropy locking
On 2022-02-04 16:51:42 [+0100], Jason A. Donenfeld wrote:
> index 455615ac169a..3e54b90a3ff8 100644
> --- a/drivers/char/random.c
> +++ b/drivers/char/random.c
> @@ -1759,41 +1762,54 @@ u64 get_random_u64(void)
> unsigned long flags;
> struct batched_entropy *batch;
> static void *previous;
> + int next_gen;
>
> warn_unseeded_randomness(&previous);
>
> - batch = raw_cpu_ptr(&batched_entropy_u64);
> - spin_lock_irqsave(&batch->batch_lock, flags);
> - if (batch->position % ARRAY_SIZE(batch->entropy_u64) == 0) {
> + batch = this_cpu_ptr(&batched_entropy_u64);
> + local_lock_irqsave(&batch->lock, flags);

Does this compile and work? From the looks of it, this should be:

local_lock_irqsave(&batched_entropy_u64.lock, flags);
batch = this_cpu_ptr(&batched_entropy_u64);

and we could do s/this_cpu_ptr/raw_cpu_ptr/

Sebastian

\
 
 \ /
  Last update: 2022-02-04 16:58    [W:0.099 / U:0.680 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site