linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Larry Woodman <lwoodman@redhat.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"David Laight" <David.Laight@aculab.com>,
	"Joe Perches" <joe@perches.com>,
	"Dennis Zhou" <dennis@kernel.org>,
	"Emil Renner Berthing" <kernel@esmil.dk>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Matti Vaittinen" <matti.vaittinen@fi.rohmeurope.com>,
	"Alexey Klimov" <aklimov@redhat.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 46/49] mm/mempolicy: replace nodes_weight with nodes_weight_eq
Date: Fri, 11 Feb 2022 11:47:22 -0800	[thread overview]
Message-ID: <Yga9SgUk07Fn7Upx@yury-laptop> (raw)
In-Reply-To: <65ab6b3e-82b4-0a4e-bd6e-5869f735a8f7@wanadoo.fr>

 + Larry Woodman <lwoodman@redhat.com>

On Fri, Feb 11, 2022 at 06:44:39PM +0100, Christophe JAILLET wrote:
> Le 10/02/2022 à 23:49, Yury Norov a écrit :
> > 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.
> > 
> > Signed-off-by: Yury Norov <yury.norov@gmail.com>
> > ---
> >   mm/mempolicy.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > 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.
> >   			 */
> > -			if ((nodes_weight(*from) != 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
> "(nodes_weight(*from) != nodes_weight(*to))" test out of the
> for_each_node_mask() to compute it only once?
> 
> '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


  reply	other threads:[~2022-02-11 19:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220210224933.379149-1-yury.norov@gmail.com>
2022-02-10 22:49 ` [PATCH 24/49] mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate Yury Norov
2022-02-11 10:39   ` Mike Rapoport
2022-02-10 22:49 ` [PATCH 46/49] mm/mempolicy: replace nodes_weight with nodes_weight_eq Yury Norov
2022-02-11 10:40   ` Mike Rapoport
2022-02-11 17:44   ` Christophe JAILLET
2022-02-11 19:47     ` Yury Norov [this message]
2022-02-10 22:49 ` [PATCH 47/49] nodemask: add num_node_state_eq() Yury Norov
2022-02-11 10:41   ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yga9SgUk07Fn7Upx@yury-laptop \
    --to=yury.norov@gmail.com \
    --cc=David.Laight@aculab.com \
    --cc=aklimov@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dennis@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=kernel@esmil.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=lwoodman@redhat.com \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=npiggin@gmail.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox