Re: [RFC PATCH] cgroup: Return error when attempting to migrate a zombie process

From: Michal Koutný
Date: Tue May 09 2023 - 06:03:56 EST


On Fri, May 05, 2023 at 09:04:37AM -1000, Tejun Heo <tj@xxxxxxxxxx> wrote:
> This seems racy to me. The liveness state can change between here and the
> PF_EXITING check in cgroup_migrate_add_task(), right?

You're right, threadgroup lock won't prevent that (as I got wrongly in
the patch):

cgroup_procs_write_start
do_exit
exit_signals
cgroup_threadgroup_change_begin
tsk->flags |= PF_EXITING
cgroup_threadgroup_change_end
percpu_down_write(&cgroup_threadgroup_rwsem)
...
atomic_read(&live)
...
atomic_dec_and_test(live)
...
cgroup_migrate_add_task
...
percpu_up_write(&cgroup_threadgroup_rwsem)


> Wouldn't it be better to just track how many tasks are tracked and
> return -ESRCH if none was migrated?

Thanks, such an integral sounds better, will see.

Michal

Attachment: signature.asc
Description: PGP signature