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 BC83EC433F5 for ; Fri, 11 Feb 2022 19:49:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 182436B0078; Fri, 11 Feb 2022 14:49:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 109CD6B007B; Fri, 11 Feb 2022 14:49:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9EE56B007D; Fri, 11 Feb 2022 14:49:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id D33056B0078 for ; Fri, 11 Feb 2022 14:49:35 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7F7B78249980 for ; Fri, 11 Feb 2022 19:49:35 +0000 (UTC) X-FDA: 79131538710.19.4EA13DB Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf18.hostedemail.com (Postfix) with ESMTP id 0CAE11C0006 for ; Fri, 11 Feb 2022 19:49:34 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id e16so10042858qtq.6 for ; Fri, 11 Feb 2022 11:49:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=3K4p9cidMn/Tx0W9hJAw8Kq8LAoL7UjCy3S5gzxmolE=; b=PvH+JCsjOQGyqhEmnNNNCc22Ki5ciMZNdyKZyQKikNJuYLPiYccjhmd5HhonZv9HNn Hd7wGtPTw7piYrgeRxB3mNDdfdFZ6WDzEsmInYQaeljM9qV3EblHxhkfRCeJyQHE0FQw C+sXieo5s6TnitSnyNHkVBIRGywkvVs90vNEUQYDT3j5y23fc5a1sufwdegkSemVkLrE 7uB78csEC0ko/vn+ZE4nXo17Kmq7tE+5cptWq2JC1wReE3gJ6NrXQJSg6Pajdv10jht3 5Fb8ePXc2gqTHAhJGUQnQg0MBWXEqxsg1mz5nB+SJkFAaY6TqgQLs6L3Xn3eO/7iyRwZ mQ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=3K4p9cidMn/Tx0W9hJAw8Kq8LAoL7UjCy3S5gzxmolE=; b=IRhzdlVtuuGZ+G0gJEv416QJW5dIPXkJbcY3gDbLSD8BoK0ZqP0mLxla9TZv6Pswgk dqf7geL3CzAcrH13cvDfrF01273qzFjkPEcP25Lno5oR3l3hKqPFHhmcQZ93rK8lfrNn ZbIWX03X+ZcM9D1Ijw4jberzaBasraPWdWiJ5mhsMZzTO2cqxXvk6QG0bKHPNKoTfLUC i9JHetm72loHyhd9c4NetMEWQ3eE1sVgtw5Biv4aXjVNo/DMMzgXI7B5+Jq2XEMK/0Vb eZZwXCeyDIaAm50BqPTvZIpRlL199KaQHfSJZmfQg7thZlLAxpNrHRGD6V0+vKDssm+r ND+Q== X-Gm-Message-State: AOAM530OlpM5eJA5i/qxdQVRmCM50cKjamrZqMX/PEVPW5Tti8+WYfcq KJMj494uu5gcOExSSV9/Tw8= X-Google-Smtp-Source: ABdhPJziBtRDpl6yACPTwvrPogi70gIB0RmsJdkVTACwFY44039RHw45fPR+zzzKuY/eitDM9E709A== X-Received: by 2002:a05:622a:15ce:: with SMTP id d14mr2322417qty.330.1644608974275; Fri, 11 Feb 2022 11:49:34 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id bj19sm8919070qkb.109.2022.02.11.11.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 11:49:33 -0800 (PST) Date: Fri, 11 Feb 2022 11:47:22 -0800 From: Yury Norov To: Christophe JAILLET , Larry Woodman Cc: 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 Subject: Re: [PATCH 46/49] mm/mempolicy: replace nodes_weight with nodes_weight_eq Message-ID: References: <20220210224933.379149-1-yury.norov@gmail.com> <20220210224933.379149-47-yury.norov@gmail.com> <65ab6b3e-82b4-0a4e-bd6e-5869f735a8f7@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <65ab6b3e-82b4-0a4e-bd6e-5869f735a8f7@wanadoo.fr> Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PvH+JCsj; spf=pass (imf18.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.160.176 as permitted sender) smtp.mailfrom=yury.norov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam07 X-Rspam-User: X-Rspamd-Queue-Id: 0CAE11C0006 X-Stat-Signature: oqpp17zs1wij3jrn8wdad86oj4grnqmz X-HE-Tag: 1644608974-438426 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: + Larry Woodman On Fri, Feb 11, 2022 at 06:44:39PM +0100, Christophe JAILLET wrote: > Le 10/02/2022 =E0 23:49, Yury Norov a =E9crit=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, cons= t nodemask_t *from, > > * [0-7] - > [3,4,5] moves only 0,1,2,6,7. > > */ > > - if ((nodes_weight(*from) !=3D nodes_weight(*to)) && > > + if (!nodes_weight_eq(*from, nodes_weight(*to)) && > > (node_isset(s, *to))) >=20 > Hi, >=20 > I've not looked in details, but would it make sense to hoist the > "(nodes_weight(*from) !=3D nodes_weight(*to))" test out of the > for_each_node_mask() to compute it only once? >=20 > 'from' and 'to' look unmodified in the loop. It seems that 'from' and 'to' are untouched in the outer while() loop as well, so we can compare weights of nodemaps only once at the beginning. Larry, can you please comment on that? Thanks, Yury