diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2007-10-17 02:27:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:42:53 -0400 |
commit | c17ac85504efec5f3a9b0c5b05bffd6f30e5b655 (patch) | |
tree | 8643b155ac0530142f2149ddf590ab08bb03b8c2 | |
parent | b2d9323d139f5c384fa1ef1d74773b4db1c09b3d (diff) |
Make rcutorture RNG use temporal entropy
Repost of http://lkml.org/lkml/2007/8/10/472 made available by request.
The locking used by get_random_bytes() can conflict with the
preempt_disable() and synchronize_sched() form of RCU. This patch changes
rcutorture's RNG to gather entropy from the new cpu_clock() interface
(relying on interrupts, preemption, daemons, and rcutorture's reader
thread's rock-bottom scheduling priority to provide useful entropy), and
also adds and EXPORT_SYMBOL_GPL() to make that interface available to GPLed
kernel modules such as rcutorture.
Passes several hours of rcutorture.
[ego@in.ibm.com: Use raw_smp_processor_id() in rcu_random()]
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/rcutorture.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c index dd413bf6a1d2..c3e165c2318f 100644 --- a/kernel/rcutorture.c +++ b/kernel/rcutorture.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <linux/notifier.h> | 41 | #include <linux/notifier.h> |
42 | #include <linux/freezer.h> | 42 | #include <linux/freezer.h> |
43 | #include <linux/cpu.h> | 43 | #include <linux/cpu.h> |
44 | #include <linux/random.h> | ||
45 | #include <linux/delay.h> | 44 | #include <linux/delay.h> |
46 | #include <linux/byteorder/swabb.h> | 45 | #include <linux/byteorder/swabb.h> |
47 | #include <linux/stat.h> | 46 | #include <linux/stat.h> |
@@ -165,16 +164,14 @@ struct rcu_random_state { | |||
165 | 164 | ||
166 | /* | 165 | /* |
167 | * Crude but fast random-number generator. Uses a linear congruential | 166 | * Crude but fast random-number generator. Uses a linear congruential |
168 | * generator, with occasional help from get_random_bytes(). | 167 | * generator, with occasional help from cpu_clock(). |
169 | */ | 168 | */ |
170 | static unsigned long | 169 | static unsigned long |
171 | rcu_random(struct rcu_random_state *rrsp) | 170 | rcu_random(struct rcu_random_state *rrsp) |
172 | { | 171 | { |
173 | long refresh; | ||
174 | |||
175 | if (--rrsp->rrs_count < 0) { | 172 | if (--rrsp->rrs_count < 0) { |
176 | get_random_bytes(&refresh, sizeof(refresh)); | 173 | rrsp->rrs_state += |
177 | rrsp->rrs_state += refresh; | 174 | (unsigned long)cpu_clock(raw_smp_processor_id()); |
178 | rrsp->rrs_count = RCU_RANDOM_REFRESH; | 175 | rrsp->rrs_count = RCU_RANDOM_REFRESH; |
179 | } | 176 | } |
180 | rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD; | 177 | rrsp->rrs_state = rrsp->rrs_state * RCU_RANDOM_MULT + RCU_RANDOM_ADD; |