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

From: Vipin Sharma
Date: Tue Dec 14 2021 - 22:59:27 EST


On Tue, Dec 14, 2021 at 9:16 AM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Tue, Dec 14, 2021, Vipin Sharma wrote:
> > + WARN_ON(cgroup_attach_task_all(kthreadd_task, current));
>
> As the build bot noted, kthreadd_task isn't exported, and I doubt you'll convince
> folks to let you export it.
>
> Why is it problematic for the kthread to linger in the cgroup? Conceptually, it's
> not really wrong.

Issue comes when a process tries to clear up the resources when a VM
shutdown/dies. The process sometimes get an EBUSY error when it tries
to delete the cgroup directories which were created for that VM. It is
also difficult to know how many times to retry or how much time to
wait before the cgroup is empty. This issue is not always happening.