Skip to content

vhost: Support SIGKILL by flushing and exiting

Mike Christie virtualization 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 22 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9vhost-scsi: Handle vhost_vq_work_queue failures for eventsdrivers/vhost/scsi.c+12 -50 replies
2/9vhost-scsi: Handle vhost_vq_work_queue failures for cmdsdrivers/vhost/scsi.c+12 -10 replies
3/9vhost-scsi: Use system wq to flush dev for TMFsdrivers/vhost/scsi.c+19 -200 replies
4/9vhost: Remove vhost_vq_flushdrivers/vhost/vhost.c drivers/vhost/vhost.h+0 -130 replies
5/9vhost_scsi: Handle vhost_vq_work_queue failures for TMFsdrivers/vhost/scsi.c+2 -10 replies
6/9vhost: Use virtqueue mutex for swapping workerdrivers/vhost/vhost.c+12 -60 replies
7/9vhost: Release worker mutex during flushesdrivers/vhost/vhost.c+30 -140 replies
8/9vhost_task: Handle SIGKILL by flushing work and exitingdrivers/vhost/vhost.c drivers/vhost/vhost.h include/linux/sched/vhost_task.h +1 more+88 -240 replies
9/9kernel: Remove signal hacks for vhost_tasksfs/coredump.c kernel/exit.c kernel/signal.c+3 -100 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/9] vhost: Support SIGKILL by flushing and exiting

The following patches were made over Linus's tree and also apply over mst's vhost branch. The patches add the ability for vhost_tasks to handle SIGKILL by flushing queued works, stop new works from being queued, and prepare the task for an early exit.

This removes the need for the signal/coredump hacks added in:

Commit f9010dbdce91 ("fork, vhost: Use CLONE_THREAD to fix freezer/ps regression")

when the vhost_task patches were initially merged and fix the issue in this thread:

https://lore.kernel.org/all/[email protected]/

Long Background:

The original vhost worker code didn't support any signals. If the userspace application that owned the worker got a SIGKILL, the app/ process would exit dropping all references to the device and then the file operation's release function would be called. From there we would wait on running IO then cleanup the device's memory.

When we switched to vhost_tasks being a thread in the owner's process we added some hacks to the signal/coredump code so we could continue to wait on running IO and process it from the vhost_task. The idea was that we would eventually remove the hacks. We recently hit this bug:

https://lore.kernel.org/all/[email protected]/

It turns out only vhost-scsi had an issue where it would send a command to the block/LIO layer, wait for a response and then process in the vhost task. So patches 1-5 prepares vhost-scsi to handle when the vhost_task is killed while we still have commands outstanding. The next patches then prepare and convert the vhost and vhost_task layers to handle SIGKILL by flushing running works, marking the vhost_task as dead so there's no future uses, then exiting.