From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: [patch 072/128] mm/swapfile.c: use prandom_u32_max() Date: Tue, 02 Jun 2020 13:14:06 -0700 Message-ID: <20200602201406.vRGSyc6UX%akpm@linux-foundation.org> References: <20200602130930.8e8f10fa6f19e3766e70921f@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Return-path: Received: from mail.kernel.org ([198.145.29.99]:58032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbgFBUOI (ORCPT ); Tue, 2 Jun 2020 16:14:08 -0400 In-Reply-To: <20200602130930.8e8f10fa6f19e3766e70921f@linux-foundation.org> Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: akpm@linux-foundation.org, hughd@google.com, linux-mm@kvack.org, mhocko@suse.com, minchan@kernel.org, mm-commits@vger.kernel.org, tim.c.chen@linux.intel.com, torvalds@linux-foundation.org, ying.huang@intel.com From: Huang Ying Subject: mm/swapfile.c: use prandom_u32_max() To improve the code readability and take advantage of the common implementation. Link: http://lkml.kernel.org/r/20200512081013.520201-1-ying.huang@intel.com Signed-off-by: "Huang, Ying" Acked-by: Michal Hocko Cc: Minchan Kim Cc: Tim Chen Cc: Hugh Dickins Signed-off-by: Andrew Morton --- mm/swapfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/swapfile.c~mm-swap-use-prandom_u32_max +++ a/mm/swapfile.c @@ -3209,7 +3209,7 @@ SYSCALL_DEFINE2(swapon, const char __use * select a random position to start with to help wear leveling * SSD */ - p->cluster_next = 1 + (prandom_u32() % p->highest_bit); + p->cluster_next = 1 + prandom_u32_max(p->highest_bit); nr_cluster = DIV_ROUND_UP(maxpages, SWAPFILE_CLUSTER); cluster_info = kvcalloc(nr_cluster, sizeof(*cluster_info), _