Re: [PATCH v2] KVM: Move VM's worker kthreads back to the original cgroups before exiting.

From: Michal Koutný
Date: Thu Jan 20 2022 - 10:05:12 EST


On Wed, Jan 19, 2022 at 08:30:43AM -1000, Tejun Heo <tj@xxxxxxxxxx> wrote:
> It'd be nicer if we can make kthread_stop() waiting more regular but I
> couldn't find a good existing place and routing the usual parent
> signaling might be too complicated. Anyone has better ideas?

The regular way is pictured in Paolo's diagram already, the
exit_notify/do_signal_parent -> wait4 path.

Actually, I can see that there exists already kernel_wait() and is used
by a UMH wrapper kthread. kthreadd issues ignore_signals() so (besides
no well defined point of signalling a kthread) the signal notification
is moot and only waking up the waiter is relevant. So kthread_stop()
could wait via kernel_wait() based on pid (extracted from task_struct).

Have I missed an obstacle?


Michal