Skip to contentSkip to conversation

random: Remove preempt disabled region

PATCH Applied Sebastian Andrzej Siewior 2 participants 2 messages Jul 11, 2018 – Jul 22, 2018 Random number driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 random: Remove preempt disabled region

From: Ingo Molnar <[email protected]>

No need to keep preemption disabled across the whole function.

mix_pool_bytes() uses a spin_lock() to protect the pool and there are other places like write_pool() whhich invoke mix_pool_bytes() without disabling preemption.
credit_entropy_bits() is invoked from other places like add_hwgenerator_randomness() without disabling preemption.

Before commit 95b709b6be49 ("random: drop trickle mode") the function used __this_cpu_inc_return() which would require disabled preemption. The preempt_disable() section was added in commit 43d5d3018c37 ("[PATCH] random driver preempt robustness", history tree). It was claimed that the code relied on "vt_ioctl() being called under BKL".

Cc "Theodore Ts'o" <[email protected]>
[bigeasy: enhance the commit message]
---
 drivers/char/random.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/char/random.c +0 -4
index cd888d4ee605..e43690977b29 100644
@@ -1122,8 +1122,6 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
 	} sample;
 	long delta, delta2, delta3;
 
-	preempt_disable();
-
 	sample.jiffies = jiffies;
 	sample.cycles = random_get_entropy();
 	sample.num = num;
@@ -1161,8 +1159,6 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
 	 * and limit entropy entimate to 12 bits.
 	 */
 	credit_entropy_bits(r, min_t(int, fls(delta>>1), 11));
-
-	preempt_enable();
 }
 
 void add_input_randomness(unsigned int type, unsigned int code,
Signature · 1 line
2.18.0
maintainer Applied
#1 lore raw
Quoted 16 lines · Sebastian Andrzej Siewior

From: Ingo Molnar <[email protected]>

No need to keep preemption disabled across the whole function.

mix_pool_bytes() uses a spin_lock() to protect the pool and there are other places like write_pool() whhich invoke mix_pool_bytes() without disabling preemption.
credit_entropy_bits() is invoked from other places like add_hwgenerator_randomness() without disabling preemption.

Before commit 95b709b6be49 ("random: drop trickle mode") the function used __this_cpu_inc_return() which would require disabled preemption. The preempt_disable() section was added in commit 43d5d3018c37 ("[PATCH] random driver preempt robustness", history tree). It was claimed that the code relied on "vt_ioctl() being called under BKL".

Quoted 5 lines
Cc "Theodore Ts'o" <[email protected]>
[bigeasy: enhance the commit message]

Applied, thanks.

- Ted