Messages in this thread | ![/](/images/icornerl.gif) | | From | Lai Jiangshan <> | Date | Wed, 15 Dec 2021 00:14:17 +0800 | Subject | Re: [PATCH] KVM: Move VM's worker kthreads back to the original cgroups before exiting. |
| |
On Tue, Dec 14, 2021 at 4:13 PM Vipin Sharma <vipinsh@google.com> wrote: > > VM worker kthreads can linger in the VM process's cgroup for sometime > after KVM temrinates the VM process. > > KVM terminates the worker kthreads by calling kthread_stop() which waits > on the signal generated by exit_mm() in do_exit() during kthread's exit. > However, these kthreads are removed from the cgroup using cgroup_exit() > call which happens after exit_mm() in do_exit(). A VM process can > terminate between the time window of exit_mm() to cgroup_exit(), leaving > only worker kthreads in the cgroup. > > Moving worker kthreads back to the original cgroup (kthreadd_task's > cgroup) makes sure that cgroup is empty as soon as the main VM process > is terminated. > > Signed-off-by: Vipin Sharma <vipinsh@google.com> > --- > virt/kvm/kvm_main.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-)
Hello
Off-topic, can this kvm worker_thread and the thread to do async pagefault be possibly changed to use something like io_uring's IOWQ (fs/io-wq.c) created by create_io_thread()?
So that every resource the threads used are credited to the process of the vm.
Thanks Lai
| ![\](/images/icornerr.gif) |