* [PATCH resend] drivers/char/random.c: remove unused dont_count_entropy
@ 2018-02-28 23:22 Rasmus Villemoes
2018-03-01 0:05 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Villemoes @ 2018-02-28 23:22 UTC (permalink / raw)
To: Theodore Ts'o, Arnd Bergmann, Greg Kroah-Hartman
Cc: Rasmus Villemoes, linux-kernel
Ever since "random: kill dead extract_state struct" [1], the
dont_count_entropy member of struct timer_rand_state has been
effectively unused. Since it hasn't found a new use in 12 years, it's
probably safe to finally kill it.
[1] Pre-git, https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=c1c48e61c251f57e7a3f1bf11b3c462b2de9dcb5
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/char/random.c | 53 ++++++++++++++++++++++++---------------------------
1 file changed, 25 insertions(+), 28 deletions(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index e5b3d3ba4660..767c6c10f9a3 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -963,7 +963,6 @@ static ssize_t extract_crng_user(void __user *buf, size_t nbytes)
struct timer_rand_state {
cycles_t last_time;
long last_delta, last_delta2;
- unsigned dont_count_entropy:1;
};
#define INIT_TIMER_RAND_STATE { INITIAL_JIFFIES, };
@@ -1029,35 +1028,33 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
* We take into account the first, second and third-order deltas
* in order to make our estimate.
*/
+ delta = sample.jiffies - state->last_time;
+ state->last_time = sample.jiffies;
+
+ delta2 = delta - state->last_delta;
+ state->last_delta = delta;
+
+ delta3 = delta2 - state->last_delta2;
+ state->last_delta2 = delta2;
+
+ if (delta < 0)
+ delta = -delta;
+ if (delta2 < 0)
+ delta2 = -delta2;
+ if (delta3 < 0)
+ delta3 = -delta3;
+ if (delta > delta2)
+ delta = delta2;
+ if (delta > delta3)
+ delta = delta3;
- if (!state->dont_count_entropy) {
- delta = sample.jiffies - state->last_time;
- state->last_time = sample.jiffies;
-
- delta2 = delta - state->last_delta;
- state->last_delta = delta;
-
- delta3 = delta2 - state->last_delta2;
- state->last_delta2 = delta2;
-
- if (delta < 0)
- delta = -delta;
- if (delta2 < 0)
- delta2 = -delta2;
- if (delta3 < 0)
- delta3 = -delta3;
- if (delta > delta2)
- delta = delta2;
- if (delta > delta3)
- delta = delta3;
+ /*
+ * delta is now minimum absolute delta.
+ * Round down by 1 bit on general principles,
+ * and limit entropy entimate to 12 bits.
+ */
+ credit_entropy_bits(r, min_t(int, fls(delta>>1), 11));
- /*
- * delta is now minimum absolute delta.
- * Round down by 1 bit on general principles,
- * and limit entropy entimate to 12 bits.
- */
- credit_entropy_bits(r, min_t(int, fls(delta>>1), 11));
- }
preempt_enable();
}
--
2.15.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH resend] drivers/char/random.c: remove unused dont_count_entropy
2018-02-28 23:22 [PATCH resend] drivers/char/random.c: remove unused dont_count_entropy Rasmus Villemoes
@ 2018-03-01 0:05 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2018-03-01 0:05 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Arnd Bergmann, Greg Kroah-Hartman, linux-kernel
On Thu, Mar 01, 2018 at 12:22:47AM +0100, Rasmus Villemoes wrote:
> Ever since "random: kill dead extract_state struct" [1], the
> dont_count_entropy member of struct timer_rand_state has been
> effectively unused. Since it hasn't found a new use in 12 years, it's
> probably safe to finally kill it.
>
> [1] Pre-git, https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=c1c48e61c251f57e7a3f1bf11b3c462b2de9dcb5
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> drivers/char/random.c | 53 ++++++++++++++++++++++++---------------------------
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-01 0:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-28 23:22 [PATCH resend] drivers/char/random.c: remove unused dont_count_entropy Rasmus Villemoes
2018-03-01 0:05 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox