diff options
| author | Daniel Borkmann <dborkman@redhat.com> | 2013-11-12 23:45:42 +0100 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2016-09-10 12:06:19 +0200 |
| commit | db0796e74cc9208d7c34ba8d6392f045b92a8222 (patch) | |
| tree | 6d464da76fda2afd221d7450b45e890ad0db534e /lib/random32.c | |
| parent | 2c65c997807fcfae1863809d4b7075e07e7f123b (diff) | |
random32: use msecs_to_jiffies for reseed timer
Use msecs_to_jiffies, for these calculations as different HZ
considerations are taken into account for conversion of the timer
shot, and also it makes the code more readable.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/random32.c')
| -rw-r--r-- | lib/random32.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/random32.c b/lib/random32.c index 4f9d5dffc..1e5b2df44 100644 --- a/lib/random32.c +++ b/lib/random32.c @@ -214,18 +214,22 @@ static DEFINE_TIMER(seed_timer, __prandom_timer, 0, 0); static void __prandom_timer(unsigned long dontcare) { u32 entropy; + unsigned long expires; get_random_bytes(&entropy, sizeof(entropy)); prandom_seed(entropy); + /* reseed every ~60 seconds, in [40 .. 80) interval with slack */ - seed_timer.expires = jiffies + (40 * HZ + (prandom_u32() % (40 * HZ))); + expires = 40 + (prandom_u32() % 40); + seed_timer.expires = jiffies + msecs_to_jiffies(expires * MSEC_PER_SEC); + add_timer(&seed_timer); } static void __init __prandom_start_seed_timer(void) { set_timer_slack(&seed_timer, HZ); - seed_timer.expires = jiffies + 40 * HZ; + seed_timer.expires = jiffies + msecs_to_jiffies(40 * MSEC_PER_SEC); add_timer(&seed_timer); } |
