Re: [RFC PATCH v1 46/50] mm/shuffle.c: use get_random_max()
From: Dan Williams
Date: Sat Mar 28 2020 - 14:23:39 EST
On Sat, Mar 28, 2020 at 9:43 AM George Spelvin <lkml@xxxxxxx> wrote:
>
> Now that we have it, this is an example of where it helps.
I didn't get copied on the cover and this series does not seem to be
threaded in a way lore can find the cover either:
https://lore.kernel.org/r/202003281643.02SGhPmY017434@xxxxxxx
Mind including a short blurb about what it is and why it helps in the changelog?
>
> Signed-off-by: George Spelvin <lkml@xxxxxxx>
> Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
> Cc: Qian Cai <cai@xxxxxx>
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> Cc: Michal Hocko <mhocko@xxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: linux-mm@xxxxxxxxx
> ---
> mm/shuffle.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/shuffle.c b/mm/shuffle.c
> index b3fe97fd66541..e0ed247f8d907 100644
> --- a/mm/shuffle.c
> +++ b/mm/shuffle.c
> @@ -135,7 +135,7 @@ void __meminit __shuffle_zone(struct zone *z)
> * in the zone.
> */
> j = z->zone_start_pfn +
> - ALIGN_DOWN(get_random_long() % z->spanned_pages,
> + ALIGN_DOWN(get_random_max(z->spanned_pages),
> order_pages);
> page_j = shuffle_valid_page(j, order);
> if (page_j && page_j != page_i)
> --
> 2.26.0
>