Re: [PATCH v3] mm/page_alloc: detect allocation forbidden by cpuset and bail out early

From: Michal Hocko
Date: Wed Sep 15 2021 - 07:30:37 EST


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!
> +
> if (is_in_v2_mode())
> hotplug_update_tasks(cs, &new_cpus, &new_mems,
> cpus_updated, mems_updated);
>
> Thanks,
> Feng

--
Michal Hocko
SUSE Labs