summaryrefslogtreecommitdiff
path: root/drivers/vhost/vhost.h
diff options
context:
space:
mode:
authorMike Christie <michael.christie@oracle.com>2023-06-26 18:23:07 -0500
committerMichael S. Tsirkin <mst@redhat.com>2023-07-03 12:15:14 -0400
commit228a27cf78afc63a18f744a56740d26570ecaec0 (patch)
treefdf9c8bba4cd440f58f01608456de91c3e5d08c6 /drivers/vhost/vhost.h
parentd74b55e6550225ad0a28f0faa590cc9f780ba392 (diff)
vhost: Allow worker switching while work is queueing
This patch drops the requirement that we can only switch workers if work has not been queued by using RCU for the vq based queueing paths and a mutex for the device wide flush. We can also use this to support SIGKILL properly in the future where we should exit almost immediately after getting that signal. With this patch, when get_signal returns true, we can set the vq->worker to NULL and do a synchronize_rcu to prevent new work from being queued to the vhost_task that has been killed. Signed-off-by: Mike Christie <michael.christie@oracle.com> Message-Id: <20230626232307.97930-18-michael.christie@oracle.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost/vhost.h')
-rw-r--r--drivers/vhost/vhost.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 4920ca63b8de..f1e7d4d13219 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -28,6 +28,8 @@ struct vhost_work {
struct vhost_worker {
struct vhost_task *vtsk;
+ /* Used to serialize device wide flushing with worker swapping. */
+ struct mutex mutex;
struct llist_head work_list;
u64 kcov_handle;
u32 id;
@@ -76,7 +78,7 @@ struct vhost_vring_call {
/* The virtqueue structure describes a queue attached to a device. */
struct vhost_virtqueue {
struct vhost_dev *dev;
- struct vhost_worker *worker;
+ struct vhost_worker __rcu *worker;
/* The actual ring of buffers. */
struct mutex mutex;