lkml.org 
[lkml]   [2022]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] locking/lockdep: Use sched_clock() for random numbers.
On Tue, May 17, 2022 at 11:53:43AM +0200, Jason A. Donenfeld wrote:
> Hi Sebastian,
>
> Interesting RT consideration. I hope there aren't too many of these
> special cases that would necessitate a general mechanism. Fingers
> crossed this is the only one.
>
> On Tue, May 17, 2022 at 11:16:14AM +0200, Sebastian Andrzej Siewior wrote:
> > - cookie.val = 1 + (prandom_u32() >> 16);
> > + cookie.val = 1 + (sched_clock() & 0xffff);
> > hlock->pin_count += cookie.val;
>
> I have no idea what the requirements here are. What would happen if you
> just did atomic_inc_return(&some_global) instead? That'd be faster
> anyhow, and it's not like 16 bits gives you much variance anyway...

Also, what is that `1 +` doing there? If the intention is to make sure
this is non-zero, you might want the mask to be 0xfffe? Or you're
counting on the assigned type being a u32 so it all overflows into the
next zone the way you want it? Kinda weird.

Jason

\
 
 \ /
  Last update: 2022-05-17 12:00    [W:0.157 / U:0.652 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site