[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YzII8VrYmIowfbgA@yury-laptop>
Date: Mon, 26 Sep 2022 13:17:53 -0700
From: Yury Norov <yury.norov@...il.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>
Cc: linux-mm@...ck.org, akpm@...ux-foundation.org,
Wei Xu <weixugc@...gle.com>, Huang Ying <ying.huang@...el.com>,
Yang Shi <shy828301@...il.com>,
Davidlohr Bueso <dave@...olabs.net>,
Tim C Chen <tim.c.chen@...el.com>,
Michal Hocko <mhocko@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Hesham Almatary <hesham.almatary@...wei.com>,
Dave Hansen <dave.hansen@...el.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Alistair Popple <apopple@...dia.com>,
Dan Williams <dan.j.williams@...el.com>,
Johannes Weiner <hannes@...xchg.org>, jvgediya.oss@...il.com,
Bharata B Rao <bharata@....com>
Subject: Re: [PATCH v15 10/10] lib/nodemask: Optimize node_random for
nodemask with single NUMA node
Hi Aneesh,
Please CC maintainers in your recipient list.
On Thu, Aug 18, 2022 at 06:40:42PM +0530, Aneesh Kumar K.V wrote:
> The most common case for certain node_random usage (demotion nodemask) is with
> nodemask weight 1. We can avoid calling get_random_init() in that case and
> always return the only node set in the nodemask.
Can you move the comment about get_random_int() to the code?.
> A simple test as below
> before = rdtsc_ordered();
> for (i= 0; i < 100; i++) {
> rand = node_random(&nmask);
> }
> after = rdtsc_ordered();
>
> Without fix after - before : 16438
> With fix after - before : 816
>
> Reviewed-by: "Huang, Ying" <ying.huang@...el.com>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@...ux.ibm.com>
> ---
> include/linux/nodemask.h | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
> index 4b71a96190a8..ac5b6a371be5 100644
> --- a/include/linux/nodemask.h
> +++ b/include/linux/nodemask.h
> @@ -504,12 +504,21 @@ static inline int num_node_state(enum node_states state)
> static inline int node_random(const nodemask_t *maskp)
> {
> #if defined(CONFIG_NUMA) && (MAX_NUMNODES > 1)
> - int w, bit = NUMA_NO_NODE;
> + int w, bit;
>
> w = nodes_weight(*maskp);
> - if (w)
> + switch (w) {
> + case 0:
> + bit = NUMA_NO_NODE;
> + break;
Why not 'return NUMA_NO_NODE' instead of break thing?
> + case 1:
> + bit = first_node(*maskp);
> + break;
> + default:
> bit = bitmap_ord_to_pos(maskp->bits,
> - get_random_int() % w, MAX_NUMNODES);
> + get_random_int() % w, MAX_NUMNODES);
Don't fix tabs - it trashes the history.
> + break;
> + }
> return bit;
> #else
> return 0;
> --
> 2.37.2
>
>
Powered by blists - more mailing lists