lkml.org 
[lkml]   [2022]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] vhost: Provide a kernel warning if mutex is held whilst clean-up in progress
Date
All workers/users should be halted before any clean-up should take place.

Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/vhost/vhost.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index bbaff6a5e21b8..d935d2506963f 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -693,6 +693,9 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
int i;

for (i = 0; i < dev->nvqs; ++i) {
+ /* Ideally all workers should be stopped prior to clean-up */
+ WARN_ON(mutex_is_locked(&dev->vqs[i]->mutex));
+
mutex_lock(&dev->vqs[i]->mutex);
if (dev->vqs[i]->error_ctx)
eventfd_ctx_put(dev->vqs[i]->error_ctx);
--
2.35.1.574.g5d30c73bfb-goog
\
 
 \ /
  Last update: 2022-03-03 16:20    [W:0.057 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site