[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZmdbcSFmkmh-Cl7R@slm.duckdns.org>
Date: Mon, 10 Jun 2024 10:00:49 -1000
From: Tejun Heo <tj@...nel.org>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
linux-kernel@...r.kernel.org, Zefan Li <lizefan.x@...edance.com>,
Johannes Weiner <hannes@...xchg.org>
Subject: Re: Q: css_task_iter_advance() && dying_tasks
Hello, Oleg.
On Mon, Jun 10, 2024 at 12:50:28PM +0200, Oleg Nesterov wrote:
> I never understood the code in kernel/cgroup/ even remotely, most probably
> I missed something, but let me ask a couple of stupid questions anyway.
>
> cgroup_exit() does
>
> css_set_move_task(tsk, cset, NULL, false);
> list_add_tail(&tsk->cg_list, &cset->dying_tasks);
>
> but unless I am totally confused css_task_iter_advance() always ignores
> the "dying" sub-threads, so perhaps it should do, say,
>
> css_set_move_task(tsk, cset, NULL, false);
> if (delay_group_leader(tsk))
> list_add_tail(&tsk->cg_list, &cset->dying_tasks);
>
> and then cgroup_release() can check list_empty(cg_list) before it takes
> css_set_lock.
>
> No ?
Yeah, I think so. The current code hasn't broken for quite a while but it
also hasn't received much attention after the iterator updates which were
very much in the spirit of just getting it to work. I don't think you're
missing anything.
> Or, perhaps we can do even better? Can't cgroup_exit() do something like
>
> // group_dead should be passed from do_exit()
>
> css_set_move_task(tsk, cset, NULL, false);
>
> if (thread_group_leader(tsk) && !group_dead)
> list_add_tail(&tsk->cg_list, &cset->dying_tasks);
>
> else if (!thread_group_leader(tsk) && group_dead) {
> leader = tsk->group_leader;
> if (!list_empty(leader->cg_list) {
> css_set_skip_task_iters(task_css_set(leader), leader);
> list_del_init(&leader->cg_list);
> }
> }
>
> and then
>
> - kill the atomic_read(&task->signal->live)) check in
> css_task_iter_advance()
>
> - kill the code under css_set_lock in cgroup_release()
That does sound a lot better than the current code. Care to send the patch?
Thanks.
--
tejun
Powered by blists - more mailing lists