linux-stable/arch/x86
Mike Christie f9010dbdce fork, vhost: Use CLONE_THREAD to fix freezer/ps regression
When switching from kthreads to vhost_tasks two bugs were added:
1. The vhost worker tasks's now show up as processes so scripts doing
ps or ps a would not incorrectly detect the vhost task as another
process.  2. kthreads disabled freeze by setting PF_NOFREEZE, but
vhost tasks's didn't disable or add support for them.

To fix both bugs, this switches the vhost task to be thread in the
process that does the VHOST_SET_OWNER ioctl, and has vhost_worker call
get_signal to support SIGKILL/SIGSTOP and freeze signals. Note that
SIGKILL/STOP support is required because CLONE_THREAD requires
CLONE_SIGHAND which requires those 2 signals to be supported.

This is a modified version of the patch written by Mike Christie
<michael.christie@oracle.com> which was a modified version of patch
originally written by Linus.

Much of what depended upon PF_IO_WORKER now depends on PF_USER_WORKER.
Including ignoring signals, setting up the register state, and having
get_signal return instead of calling do_group_exit.

Tidied up the vhost_task abstraction so that the definition of
vhost_task only needs to be visible inside of vhost_task.c.  Making
it easier to review the code and tell what needs to be done where.
As part of this the main loop has been moved from vhost_worker into
vhost_task_fn.  vhost_worker now returns true if work was done.

The main loop has been updated to call get_signal which handles
SIGSTOP, freezing, and collects the message that tells the thread to
exit as part of process exit.  This collection clears
__fatal_signal_pending.  This collection is not guaranteed to
clear signal_pending() so clear that explicitly so the schedule()
sleeps.

For now the vhost thread continues to exist and run work until the
last file descriptor is closed and the release function is called as
part of freeing struct file.  To avoid hangs in the coredump
rendezvous and when killing threads in a multi-threaded exec.  The
coredump code and de_thread have been modified to ignore vhost threads.

Remvoing the special case for exec appears to require teaching
vhost_dev_flush how to directly complete transactions in case
the vhost thread is no longer running.

Removing the special case for coredump rendezvous requires either the
above fix needed for exec or moving the coredump rendezvous into
get_signal.

Fixes: 6e890c5d50 ("vhost: use vhost_tasks for worker threads")
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Co-developed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-06-01 17:15:33 -04:00
..
boot * Do conditional __tdx_hypercall() 'output' processing via an 2023-04-28 09:36:09 -07:00
coco * Do conditional __tdx_hypercall() 'output' processing via an 2023-04-28 09:36:09 -07:00
configs
crypto This push fixes an alignment crash in x86/aria. 2023-05-29 07:05:49 -04:00
entry Objtool changes for v6.4: 2023-04-28 14:02:54 -07:00
events perf/x86/uncore: Correct the number of CHAs on SPR 2023-05-24 22:19:41 +02:00
hyperv Objtool changes for v6.4: 2023-04-28 14:02:54 -07:00
ia32
include fork, vhost: Use CLONE_THREAD to fix freezer/ps regression 2023-06-01 17:15:33 -04:00
kernel fork, vhost: Use CLONE_THREAD to fix freezer/ps regression 2023-06-01 17:15:33 -04:00
kvm KVM: VMX: add MSR_IA32_TSX_CTRL into msrs_to_save 2023-05-21 04:05:51 -04:00
lib x86: re-introduce support for ERMS copies for user space accesses 2023-05-26 12:34:20 -07:00
math-emu
mm x86/mm: Avoid incomplete Global INVLPG flushes 2023-05-17 08:55:02 -07:00
net
pci xen: branch for v6.4-rc4 2023-05-27 09:42:56 -07:00
platform Objtool changes for v6.4: 2023-04-28 14:02:54 -07:00
power x86/cpu: Mark {hlt,resume}_play_dead() __noreturn 2023-04-14 17:31:27 +02:00
purgatory purgatory: fix disabling debug info 2023-04-08 19:36:53 +09:00
ras
realmode
tools ELF: fix all "Elf" typos 2023-04-08 13:45:37 -07:00
um um: make stub data pages size tweakable 2023-04-20 23:08:43 +02:00
video
virt/vmx/tdx
xen Objtool changes for v6.4: 2023-04-28 14:02:54 -07:00
.gitignore
Kbuild
Kconfig Add support for new Linear Address Masking CPU feature. This is similar 2023-04-28 09:43:49 -07:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug docs: move x86 documentation into Documentation/arch/ 2023-03-30 12:58:51 -06:00
Makefile x86/build: Make 64-bit defconfig the default 2023-02-15 14:20:17 +01:00
Makefile.um um: Only disable SSE on clang to work around old GCC bugs 2023-04-04 09:57:05 +02:00
Makefile_32.cpu