From: David Rientjes <rientjes@google.com>
To: Wei Yang <richardw.yang@linux.intel.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/vmscan.c: only adjust related kswapd cpu affinity when online cpu
Date: Sun, 26 Jan 2020 14:44:31 -0800 (PST) [thread overview]
Message-ID: <alpine.DEB.2.21.2001261443020.164983@chino.kir.corp.google.com> (raw)
In-Reply-To: <20200126132052.11921-1-richardw.yang@linux.intel.com>
On Sun, 26 Jan 2020, Wei Yang wrote:
> When onlining a cpu, kswapd_cpu_online() is called to adjust kswapd cpu
> affinity.
>
> Current routine does like this:
>
> * Iterate all the numa node
> * Adjust cpu affinity when node has an online cpu
>
> Actually we could improve this by:
>
> * Just adjust the numa node to which current online cpu belongs
>
> Because we know which numa node the cpu belongs to and this cpu would
> not affect other node.
>
Is there ever a situation where the cpu to be onlined would have appeared
in the cpumask of another node and so a different kswapd's cpumask would
now include an off-node cpu?
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
> mm/vmscan.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 572fb17c6273..19c92d35045c 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -4049,18 +4049,19 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim)
> restore their cpu bindings. */
> static int kswapd_cpu_online(unsigned int cpu)
> {
> - int nid;
> + int nid = cpu_to_node(cpu);
> + pg_data_t *pgdat;
> + const struct cpumask *mask;
>
> - for_each_node_state(nid, N_MEMORY) {
> - pg_data_t *pgdat = NODE_DATA(nid);
> - const struct cpumask *mask;
> + if (!node_state(nid, N_MEMORY))
> + return 0;
>
> - mask = cpumask_of_node(pgdat->node_id);
> + pgdat = NODE_DATA(nid);
> + mask = cpumask_of_node(nid);
> +
> + /* One of our CPUs online: restore mask */
> + set_cpus_allowed_ptr(pgdat->kswapd, mask);
>
> - if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids)
> - /* One of our CPUs online: restore mask */
> - set_cpus_allowed_ptr(pgdat->kswapd, mask);
> - }
> return 0;
> }
>
> --
> 2.17.1
>
>
>
next prev parent reply other threads:[~2020-01-26 22:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-26 13:20 [PATCH] mm/vmscan.c: only adjust related kswapd cpu affinity when online cpu Wei Yang
2020-01-26 22:44 ` David Rientjes [this message]
2020-01-28 0:39 ` Wei Yang
2020-02-14 5:32 ` Andrew Morton
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=alpine.DEB.2.21.2001261443020.164983@chino.kir.corp.google.com \
--to=rientjes@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=richardw.yang@linux.intel.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).