From: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: Michal Hocko <mhocko-IBi9RG/b67k@public.gmane.org>
Cc: David Rientjes <rientjes-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Zefan Li <lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>,
Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
Mel Gorman
<mgorman-3eNAlZScCAx27rWaFMvyedHuzzzSOjJt@public.gmane.org>,
Vlastimil Babka <vbabka-AlSwsSmVLrQ@public.gmane.org>,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v3] mm/page_alloc: detect allocation forbidden by cpuset and bail out early
Date: Thu, 16 Sep 2021 16:11:12 +0800 [thread overview]
Message-ID: <20210916081112.GA41645@shbuild999.sh.intel.com> (raw)
In-Reply-To: <YUHZU4OHaJy3WtRk-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
On Wed, Sep 15, 2021 at 01:30:27PM +0200, Michal Hocko wrote:
> On Wed 15-09-21 13:32:47, Feng Tang wrote:
> > On Tue, Sep 14, 2021 at 05:30:03PM -0700, David Rientjes wrote:
> [...]
> > > I'm wondering about a single node nodemask, for example, where all
> > > ZONE_NORMAL memory is hot-removed.
>
> While this is theoretically possible it is highly unlikely to happen.
> Non movable memory just takes one kernel allocation to prevent any
> hotremove operation to finish. I have to say I was not aware of the
> hotplug callback. It all seems rather suspicious. I will have a look.
>
> Anyway something worth having covered "just in case". Thanks for
> pointing it out.
>
> > Thanks for the reminding! Yes, memory hot remove can change the
> > cpuset's effective nodemask, we may need to add similar check inside
> > cpuset_hotplug_update_tasks() which is called by cpuset_hotplug_workfn(),
> > something like below?
> >
> > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> > index 7fa633e..d5f6776 100644
> > --- a/kernel/cgroup/cpuset.c
> > +++ b/kernel/cgroup/cpuset.c
> > @@ -3186,6 +3186,14 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
> > cpus_updated = !cpumask_equal(&new_cpus, cs->effective_cpus);
> > mems_updated = !nodes_equal(new_mems, cs->effective_mems);
> >
> > + if (mems_updated && !cpusets_insane_config() &&
> > + movable_only_nodes(new_mems)) {
> > + static_branch_enable(&cpusets_insane_config_key);
> > + pr_info("Unsupported (movable nodes only) cpuset configuration detected (nmask=%*pbl) after memory hotplug."
> > + "Cpuset allocations might fail even with a lot of memory available.\n",
> > + nodemask_pr_args(new_mems);
> > + }
>
> Please create a helper rather than two copies of the same. Thanks!
Sure. Some draft add-on patch below.
Thanks,
Feng
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 7fa633e..3bb9f4ea 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -391,6 +391,18 @@ static inline bool is_in_v2_mode(void)
(cpuset_cgrp_subsys.root->flags & CGRP_ROOT_CPUSET_V2_MODE);
}
+static inline void check_insane_mems_config(nodemask_t *nodes)
+{
+ if (!cpusets_insane_config() &&
+ movable_only_nodes(nodes)) {
+ static_branch_enable(&cpusets_insane_config_key);
+ pr_info("Unsupported (movable nodes only) cpuset configuration detected (nmask=%*pbl)! "
+ "Cpuset allocations might fail even with a lot of memory available.\n",
+ nodemask_pr_args(nodes));
+ }
+}
+
/*
* Return in pmask the portion of a task's cpusets's cpus_allowed that
* are online and are capable of running the task. If none are found,
@@ -1875,13 +1887,7 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
if (retval < 0)
goto done;
- if (!cpusets_insane_config() &&
- movable_only_nodes(&trialcs->mems_allowed)) {
- static_branch_enable(&cpusets_insane_config_key);
- pr_info("Unsupported (movable nodes only) cpuset configuration detected (nmask=%*pbl)! "
- "Cpuset allocations might fail even with a lot of memory available.\n",
- nodemask_pr_args(&trialcs->mems_allowed));
- }
+ check_insane_mems_config(&trialcs->mems_allowed);
spin_lock_irq(&callback_lock);
cs->mems_allowed = trialcs->mems_allowed;
@@ -3186,6 +3192,9 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
cpus_updated = !cpumask_equal(&new_cpus, cs->effective_cpus);
mems_updated = !nodes_equal(new_mems, cs->effective_mems);
+ if (mems_updated)
+ check_insane_mems_config(&new_mems);
+
if (is_in_v2_mode())
hotplug_update_tasks(cs, &new_cpus, &new_mems,
cpus_updated, mems_updated);
prev parent reply other threads:[~2021-09-16 8:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-14 3:40 [PATCH v3] mm/page_alloc: detect allocation forbidden by cpuset and bail out early Feng Tang
2021-09-14 8:50 ` Michal Hocko
2021-09-24 6:10 ` Feng Tang
[not found] ` <20210924061054.GA72911-H4oSubS0T0ZnxsEdoo2cZdh3ngVCH38I@public.gmane.org>
2021-09-24 7:17 ` Michal Hocko
[not found] ` <1631590828-25565-1-git-send-email-feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2021-09-14 8:01 ` Vlastimil Babka
[not found] ` <24d89efa-502f-e31a-5d45-536352485bbb-AlSwsSmVLrQ@public.gmane.org>
2021-09-14 8:17 ` Michal Hocko
2021-09-15 0:30 ` David Rientjes
[not found] ` <3bd87d8a-d09e-ac7-1d1d-25ad1b9d5ed9-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2021-09-15 5:32 ` Feng Tang
[not found] ` <20210915053247.GG56674-H4oSubS0T0ZnxsEdoo2cZdh3ngVCH38I@public.gmane.org>
2021-09-15 11:30 ` Michal Hocko
[not found] ` <YUHZU4OHaJy3WtRk-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2021-09-16 8:11 ` Feng Tang [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=20210916081112.GA41645@shbuild999.sh.intel.com \
--to=feng.tang-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
--cc=mgorman-3eNAlZScCAx27rWaFMvyedHuzzzSOjJt@public.gmane.org \
--cc=mhocko-IBi9RG/b67k@public.gmane.org \
--cc=rientjes-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=vbabka-AlSwsSmVLrQ@public.gmane.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