From: Mike Rapoport <rppt@kernel.org>
To: Yury Norov <yury.norov@gmail.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 47/49] nodemask: add num_node_state_eq()
Date: Fri, 11 Feb 2022 12:41:42 +0200 [thread overview]
Message-ID: <YgY9Zl3HryDSSBI9@kernel.org> (raw)
In-Reply-To: <20220210224933.379149-48-yury.norov@gmail.com>
On Thu, Feb 10, 2022 at 02:49:31PM -0800, Yury Norov wrote:
> Page allocator uses num_node_state() to compare number of nodes with a
> given number. The underlying code calls bitmap_weight(), and we can do
> it more efficiently with num_node_state_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>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
> ---
> include/linux/nodemask.h | 5 +++++
> mm/page_alloc.c | 2 +-
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
> index 197598e075e9..c5014dbf3cce 100644
> --- a/include/linux/nodemask.h
> +++ b/include/linux/nodemask.h
> @@ -466,6 +466,11 @@ static inline int num_node_state(enum node_states state)
> return nodes_weight(node_states[state]);
> }
>
> +static inline int num_node_state_eq(enum node_states state, int num)
> +{
> + return nodes_weight_eq(node_states[state], num);
> +}
> +
> #define for_each_node_state(__node, __state) \
> for_each_node_mask((__node), node_states[__state])
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index cface1d38093..897e64b66ca4 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -8434,7 +8434,7 @@ void __init page_alloc_init(void)
> int ret;
>
> #ifdef CONFIG_NUMA
> - if (num_node_state(N_MEMORY) == 1)
> + if (num_node_state_eq(N_MEMORY, 1))
> hashdist = 0;
> #endif
>
> --
> 2.32.0
>
>
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2022-02-11 10:41 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
2022-02-10 22:49 ` [PATCH 47/49] nodemask: add num_node_state_eq() Yury Norov
2022-02-11 10:41 ` Mike Rapoport [this message]
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=YgY9Zl3HryDSSBI9@kernel.org \
--to=rppt@kernel.org \
--cc=David.Laight@aculab.com \
--cc=aklimov@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--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=matti.vaittinen@fi.rohmeurope.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.org \
--cc=yury.norov@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).