From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57942C433EF for ; Fri, 11 Feb 2022 17:44:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C79206B0078; Fri, 11 Feb 2022 12:44:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C28AC6B007B; Fri, 11 Feb 2022 12:44:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF1CB6B007D; Fri, 11 Feb 2022 12:44:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id A0ABB6B0078 for ; Fri, 11 Feb 2022 12:44:46 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5C166181AC9C6 for ; Fri, 11 Feb 2022 17:44:46 +0000 (UTC) X-FDA: 79131224172.15.69C55FB Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr [80.12.242.124]) by imf09.hostedemail.com (Postfix) with ESMTP id B1C3E140009 for ; Fri, 11 Feb 2022 17:44:43 +0000 (UTC) Received: from [192.168.1.18] ([90.126.236.122]) by smtp.orange.fr with ESMTPA id IZyJniOQGeHnVIZyJnZhrl; Fri, 11 Feb 2022 18:44:42 +0100 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Fri, 11 Feb 2022 18:44:42 +0100 X-ME-IP: 90.126.236.122 Message-ID: <65ab6b3e-82b4-0a4e-bd6e-5869f735a8f7@wanadoo.fr> Date: Fri, 11 Feb 2022 18:44:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 46/49] mm/mempolicy: replace nodes_weight with nodes_weight_eq Content-Language: en-GB To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20220210224933.379149-1-yury.norov@gmail.com> <20220210224933.379149-47-yury.norov@gmail.com> From: Christophe JAILLET In-Reply-To: <20220210224933.379149-47-yury.norov@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed X-Rspamd-Queue-Id: B1C3E140009 X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=none; spf=none (imf09.hostedemail.com: domain of christophe.jaillet@wanadoo.fr has no SPF policy when checking 80.12.242.124) smtp.mailfrom=christophe.jaillet@wanadoo.fr X-Stat-Signature: z7wsyj4chfc17ssgsmwfwx5bgu9ywkeu X-Rspamd-Server: rspam11 X-HE-Tag: 1644601483-395127 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.016071, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Le 10/02/2022 =C3=A0 23:49, Yury Norov a =C3=A9crit=C2=A0: > do_migrate_pages() calls nodes_weight() to compare the weight > of nodemask with a given number. We can do it more efficiently with > nodes_weight_eq() because conditional nodes_weight() may stop > traversing the nodemask earlier, as soon as condition is (or is not) > met. >=20 > Signed-off-by: Yury Norov > --- > mm/mempolicy.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 7c852793d9e8..56efd00b1b6e 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -1154,7 +1154,7 @@ int do_migrate_pages(struct mm_struct *mm, const = nodemask_t *from, > * [0-7] - > [3,4,5] moves only 0,1,2,6,7. > */ > =20 > - if ((nodes_weight(*from) !=3D nodes_weight(*to)) && > + if (!nodes_weight_eq(*from, nodes_weight(*to)) && > (node_isset(s, *to))) Hi, I've not looked in details, but would it make sense to hoist the=20 "(nodes_weight(*from) !=3D nodes_weight(*to))" test out of the=20 for_each_node_mask() to compute it only once? 'from' and 'to' look unmodified in the loop. Just my 2c, CJ > continue; > =20