Commit 8557c862 authored by Yury Norov [NVIDIA]'s avatar Yury Norov [NVIDIA] Committed by Yury Norov
Browse files

clocksource: Improve randomness in clocksource_verify_choose_cpus()



The current algorithm of picking a random CPU works OK for dense online
cpumask, but if cpumask is non-dense, the distribution of picked CPUs
is skewed.

For example, on 8-CPU board with CPUs 4-7 offlined, the probability of
selecting CPU 0 is 5/8. Accordingly, cpus 1, 2 and 3 are chosen with
probability 1/8 each. The proper algorithm should pick each online CPU
with probability 1/4.

Switch it to cpumask_random(), which has better statistical
characteristics.

CC: Andrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarJohn Stultz <jstultz@google.com>
Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatar"Yury Norov [NVIDIA]" <yury.norov@gmail.com>
parent 012b1043
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment