lkml.org 
[lkml]   [2021]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [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

\
 
 \ /
  Last update: 2021-12-14 17:15    [W:0.195 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site