All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michal Koutný" <mkoutny-IBi9RG/b67k@public.gmane.org>
To: Vipin Sharma <vipinsh-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: pbonzini-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	seanjc-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org,
	hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
	dmatlack-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	jiangshanlai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2] KVM: Move VM's worker kthreads back to the original cgroups before exiting.
Date: Wed, 5 Jan 2022 19:04:20 +0100	[thread overview]
Message-ID: <20220105180420.GC6464@blackbody.suse.cz> (raw)
In-Reply-To: <20211222225350.1912249-1-vipinsh-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>

Hi Vipin.

On Wed, Dec 22, 2021 at 10:53:50PM +0000, Vipin Sharma <vipinsh-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> wrote:
> VM worker kthreads can linger in the VM process's cgroup for sometime
> after KVM terminates the VM process.

Why is it a problem? And how long are we talking about?

> A VM process can terminate between the time window of exit_mm() to
> cgroup_exit(), leaving only worker kthreads in the cgroup.

Even kthreads should eventually have PF_EXITING set, they shouldd be
treated as "user-space" zombies by cgroups, i.e. mostly invisible (e.g.
it doesn't prevent rmdir'ing the cgroup).

(And after the last task_struct reference is gone, the cgroup structs
can be released too. Maybe the cause is holding the reference to the KVM
worker thread somewhere for too long.)

> 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.

BTW this used to be done for "user-space" tasks too (migrate to root
cgroup) but it was replaced with the less transactional "ignore zombies"
approach. So this change seems inconsistent.


Regards,
Michal

WARNING: multiple messages have this Message-ID (diff)
From: "Michal Koutný" <mkoutny@suse.com>
To: Vipin Sharma <vipinsh@google.com>
Cc: pbonzini@redhat.com, seanjc@google.com, tj@kernel.org,
	lizefan.x@bytedance.com, hannes@cmpxchg.org, dmatlack@google.com,
	jiangshanlai@gmail.com, kvm@vger.kernel.org,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] KVM: Move VM's worker kthreads back to the original cgroups before exiting.
Date: Wed, 5 Jan 2022 19:04:20 +0100	[thread overview]
Message-ID: <20220105180420.GC6464@blackbody.suse.cz> (raw)
In-Reply-To: <20211222225350.1912249-1-vipinsh@google.com>

Hi Vipin.

On Wed, Dec 22, 2021 at 10:53:50PM +0000, Vipin Sharma <vipinsh@google.com> wrote:
> VM worker kthreads can linger in the VM process's cgroup for sometime
> after KVM terminates the VM process.

Why is it a problem? And how long are we talking about?

> A VM process can terminate between the time window of exit_mm() to
> cgroup_exit(), leaving only worker kthreads in the cgroup.

Even kthreads should eventually have PF_EXITING set, they shouldd be
treated as "user-space" zombies by cgroups, i.e. mostly invisible (e.g.
it doesn't prevent rmdir'ing the cgroup).

(And after the last task_struct reference is gone, the cgroup structs
can be released too. Maybe the cause is holding the reference to the KVM
worker thread somewhere for too long.)

> 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.

BTW this used to be done for "user-space" tasks too (migrate to root
cgroup) but it was replaced with the less transactional "ignore zombies"
approach. So this change seems inconsistent.


Regards,
Michal

  parent reply	other threads:[~2022-01-05 18:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22 22:53 [PATCH v2] KVM: Move VM's worker kthreads back to the original cgroups before exiting Vipin Sharma
2021-12-22 22:53 ` Vipin Sharma
     [not found] ` <20211222225350.1912249-1-vipinsh-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2021-12-28 17:17   ` Sean Christopherson
2021-12-28 17:17     ` Sean Christopherson
     [not found]     ` <YctGtWzYcNP2iTaN-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2022-01-18 19:53       ` Vipin Sharma
2022-01-18 19:53         ` Vipin Sharma
2022-01-05 18:04   ` Michal Koutný [this message]
2022-01-05 18:04     ` Michal Koutný
2022-01-18 20:25     ` Vipin Sharma
2022-01-18 20:25       ` Vipin Sharma
     [not found]       ` <CAHVum0e84nUcGtdPYQaJDQszKj-QVP5gM+nteBpSTaQ2sWYpmQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-01-18 20:39         ` Tejun Heo
2022-01-18 20:39           ` Tejun Heo
2022-01-19 18:02           ` Paolo Bonzini
     [not found]             ` <7a0bc562-9f25-392d-5c05-9dbcd350d002-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2022-01-19 18:30               ` Tejun Heo
2022-01-19 18:30                 ` Tejun Heo
     [not found]                 ` <YehY0z2vHYVZk52J-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2022-01-19 18:49                   ` Vipin Sharma
2022-01-19 18:49                     ` Vipin Sharma
2022-01-19 19:05                     ` Tejun Heo
2022-01-20 15:05                 ` Michal Koutný
     [not found]                   ` <20220120150502.GC27269-9OudH3eul5jcvrawFnH+a6VXKuFTiq87@public.gmane.org>
2022-02-16 17:37                     ` Vipin Sharma
2022-02-16 17:37                       ` Vipin Sharma
     [not found]                       ` <CAHVum0fOP-2XcUcG3PqW08DY7CmpDroG6Fcv9KoD1FqLmGpB8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-02-16 19:48                         ` Paolo Bonzini
2022-02-16 19:48                           ` Paolo Bonzini
2022-02-25 17:37                       ` Michal Koutný

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220105180420.GC6464@blackbody.suse.cz \
    --to=mkoutny-ibi9rg/b67k@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dmatlack-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    --cc=jiangshanlai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
    --cc=pbonzini-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=seanjc-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=vipinsh-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.