From patchwork Thu Oct 3 09:51:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Spelvin X-Patchwork-Id: 11463641 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41C3714B4 for ; Sat, 28 Mar 2020 16:43:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2668D208E0 for ; Sat, 28 Mar 2020 16:43:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2668D208E0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sdf.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6F2DA6B0036; Sat, 28 Mar 2020 12:43:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6C9C96B0037; Sat, 28 Mar 2020 12:43:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 607798E0005; Sat, 28 Mar 2020 12:43:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id 492FB6B0036 for ; Sat, 28 Mar 2020 12:43:33 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 95BE94DA9 for ; Sat, 28 Mar 2020 16:43:32 +0000 (UTC) X-FDA: 76645341864.22.low96_76324e121c20c X-Spam-Summary: 87,8,0,e21131a1b70abbc4,d41d8cd98f00b204,lkml@sdf.org,,RULES_HIT:41:355:379:800:960:973:988:989:1260:1345:1431:1437:1534:1540:1711:1714:1730:1747:1777:1792:2198:2199:2393:2559:2562:2731:3138:3139:3140:3141:3142:3351:3865:3866:3870:3871:3872:3874:4321:5007:6120:6261:10004:11026:11232:11658:11914:12043:12297:12517:12519:12555:12895:12986:13069:13311:13357:13846:14096:14181:14384:14721:21080:21451:21627:21979:30054:30064,0,RBL:205.166.94.20:@sdf.org:.lbl8.mailshell.net-64.201.201.201 62.8.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: low96_76324e121c20c X-Filterd-Recvd-Size: 1867 Received: from mx.sdf.org (mx.sdf.org [205.166.94.20]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Sat, 28 Mar 2020 16:43:32 +0000 (UTC) Received: from sdf.org (IDENT:lkml@sdf.lonestar.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 02SGhPTa005210 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Sat, 28 Mar 2020 16:43:25 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 02SGhPmY017434; Sat, 28 Mar 2020 16:43:25 GMT Message-Id: <202003281643.02SGhPmY017434@sdf.org> From: George Spelvin Date: Thu, 3 Oct 2019 05:51:56 -0400 Subject: [RFC PATCH v1 46/50] mm/shuffle.c: use get_random_max() To: linux-kernel@vger.kernel.org, lkml@sdf.org Cc: Dan Williams , Qian Cai , Kees Cook , Michal Hocko , Andrew Morton , linux-mm@kvack.org X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now that we have it, this is an example of where it helps. Signed-off-by: George Spelvin Cc: Dan Williams Cc: Qian Cai Cc: Kees Cook Cc: Michal Hocko Cc: Andrew Morton Cc: linux-mm@kvack.org --- 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)