lkml.org 
[lkml]   [2016]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] randomize_range: use random long instead of int
Hi William, Kees,

On Mon, Jul 25, 2016 at 11:25:41AM -0700, william.c.roberts@intel.com wrote:
> From: William Roberts <william.c.roberts@intel.com>
>
> Use a long when generating the random range rather than
> an int. This will produce better random distributions as
> well as matching all the types at hand.
>
> Signed-off-by: William Roberts <william.c.roberts@intel.com>
> ---
> drivers/char/random.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)

Upon further review, I think we should dig into this a little bit
deeper. Standby, I'll post an RFC series shortly.

thx,

Jason.

> diff --git a/drivers/char/random.c b/drivers/char/random.c
> index 0158d3b..bbf11b5 100644
> --- a/drivers/char/random.c
> +++ b/drivers/char/random.c
> @@ -1837,7 +1837,8 @@ randomize_range(unsigned long start, unsigned long end, unsigned long len)
>
> if (end <= start + len)
> return 0;
> - return PAGE_ALIGN(get_random_int() % range + start);
> +
> + return PAGE_ALIGN(get_random_long() % range + start);
> }
>
> /* Interface for in-kernel drivers of true hardware RNGs.
> --
> 1.9.1
>

\
 
 \ /
  Last update: 2016-07-26 05:01    [W:0.236 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site