mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Luca Boccassi" <bluca@debian.org>,
	"Roman Gushchin" <roman.gushchin@linux.dev>,
	kvm@vger.kernel.org, cgroups@vger.kernel.org,
	"Michal Koutný" <mkoutny@suse.com>,
	linux-kernel@vger.kernel.org
Subject: Re: cgroup2 freezer and kvm_vm_worker_thread()
Date: Wed, 30 Oct 2024 08:14:16 -1000	[thread overview]
Message-ID: <ZyJ3eG8YHeyxqOe_@slm.duckdns.org> (raw)
In-Reply-To: <CABgObfYR6e0XV94USugVOO5XcOfyctr1rAm+ZWJwfu9AHYPtiA@mail.gmail.com>

Hello,

On Wed, Oct 30, 2024 at 01:05:16PM +0100, Paolo Bonzini wrote:
> On Wed, Oct 30, 2024 at 1:25 AM Tejun Heo <tj@kernel.org> wrote:
> > > I'm not sure if the KVM worker thread should process signals.  We want it
> > > to take the CPU time it uses from the guest, but otherwise it's not running
> > > on behalf of userspace in the way that io_wq_worker() is.
> >
> > I see, so io_wq_worker()'s handle signals only partially. It sets
> > PF_USER_WORKER which ignores fatal signals, so the only signals which take
> > effect are STOP/CONT (and friends) which is handled in do_signal_stop()
> > which is also where the cgroup2 freezer is implemented.
> 
> What about SIGKILL? That's the one that I don't want to have for KVM
> workers, because they should only stop when the file descriptor is
> closed.

I don't think SIGKILL does anything for PF_USER_WORKER threads. Those are
all handled in the fatal: label in kernel/signal.c::get_signal() and the
function just returns for PF_USER_WORKER threads. I haven't used it myself
but looking at io_uring usage, it seems pretty straightforward.

> (Replying to Luca: the kthreads are dropping some internal data
> structures that KVM had to "de-optimize" to deal with processor bugs.
> They allow the data structures to be rebuilt in the optimal way using
> large pages).
> 
> > Given that the kthreads are tied to user processes, I think it'd be better
> > to behave similarly to user tasks as possible in this regard if userspace
> > being able to stop/cont these kthreads are okay.
> 
> Yes, I totally agree with you on that, I'm just not sure of the best
> way to do it.
> 
> I will try keeping the kthread and adding allow_signal(SIGSTOP).  That
> should allow me to process the SIGSTOP via get_signal().

I *think* you can just copy what io_wq_worker() is doing.

Thanks.

-- 
tejun

  reply	other threads:[~2024-10-30 18:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29  0:07 Tejun Heo
2024-10-29 20:46 ` Roman Gushchin
2024-10-29 22:59 ` Paolo Bonzini
2024-10-30  0:25   ` Tejun Heo
2024-10-30  0:38     ` Luca Boccassi
2024-10-30 12:05     ` Paolo Bonzini
2024-10-30 18:14       ` Tejun Heo [this message]
2024-11-06 23:21         ` Luca Boccassi
2024-11-06 23:22           ` Paolo Bonzini
2024-11-07 18:05 ` Michal Koutný
2024-11-07 18:54   ` Tejun Heo
2024-11-07 20:48     ` Sean Christopherson

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=ZyJ3eG8YHeyxqOe_@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=bluca@debian.org \
    --cc=cgroups@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=pbonzini@redhat.com \
    --cc=roman.gushchin@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®