[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3myr57cw3qepul7igpifypxx4xd2buo2y453xlqhdw4xgjokc4@vi3odjfo3ahc>
Date: Tue, 11 Apr 2023 14:23:32 +0200
From: Michal Koutný <mkoutny@...e.com>
To: Gang Li <ligang.bdlg@...edance.com>
Cc: Waiman Long <longman@...hat.com>, Michal Hocko <mhocko@...e.com>,
cgroups@...r.kernel.org, linux-mm@...ck.org, rientjes@...gle.com,
Zefan Li <lizefan.x@...edance.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] mm: oom: introduce cpuset oom
Hello.
On Tue, Apr 11, 2023 at 02:58:15PM +0800, Gang Li <ligang.bdlg@...edance.com> wrote:
> +int cpuset_scan_tasks(int (*fn)(struct task_struct *, void *), void *arg)
> +{
> + int ret = 0;
> + struct css_task_iter it;
> + struct task_struct *task;
> + struct cpuset *cs;
> + struct cgroup_subsys_state *pos_css;
> +
> + /*
> + * Situation gets complex with overlapping nodemasks in different cpusets.
> + * TODO: Maybe we should calculate the "distance" between different mems_allowed.
> + *
> + * But for now, let's make it simple. Just iterate through all cpusets
> + * with the same mems_allowed as the current cpuset.
> + */
> + cpuset_read_lock();
> + rcu_read_lock();
> + cpuset_for_each_descendant_pre(cs, pos_css, &top_cpuset) {
> + if (nodes_equal(cs->mems_allowed, task_cs(current)->mems_allowed)) {
> + css_task_iter_start(&(cs->css), CSS_TASK_ITER_PROCS, &it);
> + while (!ret && (task = css_task_iter_next(&it)))
> + ret = fn(task, arg);
> + css_task_iter_end(&it);
> + }
> + }
> + rcu_read_unlock();
> + cpuset_read_unlock();
> + return ret;
> +}
I see this traverses all cpusets without the hierarchy actually
mattering that much. Wouldn't the CONSTRAINT_CPUSET better achieved by
globally (or per-memcg) scanning all processes and filtering with:
nodes_intersect(current->mems_allowed, p->mems_allowed)
(`current` triggers the OOM, `p` is the iterated task)
?
Thanks,
Michal
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists