Re: [PATCH v11 8/8] vhost: use vhost_tasks for worker threads

From: Linus Torvalds
Date: Sat May 13 2023 - 11:08:29 EST


On Sat, May 13, 2023 at 7:39 AM Thorsten Leemhuis <linux@xxxxxxxxxxxxx> wrote:
>
> Jumping in here, as I found another problem with that patch: it broke
> s2idle on my laptop when a qemu-kvm VM is running, as freezing user
> space processes now fails for me:

Hmm. kthreads have PF_NOFREEZE by default, which is probably the reason.

Adding

current->flags |= PF_NOFREEZE;

to the vhost_task setup might just fix it, but it feels a bit off.

The way io_uring does this is to do

if (signal_pending(current)) {
struct ksignal ksig;

if (!get_signal(&ksig))
continue;
break;
}

in the main loop, which ends up handling the freezer situation too.
But it should handle things like SIGSTOP etc as well, and also exit on
actual signals.

I get the feeling that the whole "vhost_task_should_stop()" logic
should have the exact logic above, and basically make those threads
killable as well.

Hmm?

Linus