Skip to content

Commit 4051a81

Browse files
Sebastian Andrzej SiewiorPeter Zijlstra
authored andcommitted
locking/lockdep: Use sched_clock() for random numbers
Since the rewrote of prandom_u32(), in the commit mentioned below, the function uses sleeping locks which extracing random numbers and filling the batch. This breaks lockdep on PREEMPT_RT because lock_pin_lock() disables interrupts while calling __lock_pin_lock(). This can't be moved earlier because the main user of the function (rq_pin_lock()) invokes that function after disabling interrupts in order to acquire the lock. The cookie does not require random numbers as its goal is to provide a random value in order to notice unexpected "unlock + lock" sites. Use sched_clock() to provide random numbers. Fixes: a0103f4 ("random32: use real rng for non-deterministic randomness") Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/YoNn3pTkm5+QzE5k@linutronix.de
1 parent b13bacc commit 4051a81

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/locking/lockdep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5432,7 +5432,7 @@ static struct pin_cookie __lock_pin_lock(struct lockdep_map *lock)
54325432
* be guessable and still allows some pin nesting in
54335433
* our u32 pin_count.
54345434
*/
5435-
cookie.val = 1 + (prandom_u32() >> 16);
5435+
cookie.val = 1 + (sched_clock() & 0xffff);
54365436
hlock->pin_count += cookie.val;
54375437
return cookie;
54385438
}

0 commit comments

Comments
 (0)