lkml.org 
[lkml]   [2015]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 1/2] vfio: Flush signals on device request interruption
From
Date
Signals don't just interrupt our wait, they remain pending such that
subsequent wait_events timeout immediately. This can cause a CPU to
spin with a single signal. Flush signals if we receive an
interruption and also log information about the reason the task is
blocked.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Cc: stable@vger.kernel.org # v4.0
---
drivers/vfio/vfio.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 0d33662..4c786d4 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -710,6 +710,7 @@ void *vfio_del_group_dev(struct device *dev)
void *device_data = device->device_data;
struct vfio_unbound_dev *unbound;
unsigned int i = 0;
+ long ret;

/*
* The group exists so long as we have a device reference. Get
@@ -755,9 +756,15 @@ void *vfio_del_group_dev(struct device *dev)

vfio_device_put(device);

- } while (wait_event_interruptible_timeout(vfio.release_q,
- !vfio_dev_present(group, dev),
- HZ * 10) <= 0);
+ ret = wait_event_interruptible_timeout(vfio.release_q,
+ !vfio_dev_present(group, dev), HZ * 10);
+ if (ret == -ERESTARTSYS) {
+ flush_signals(current);
+ dev_warn_ratelimited(dev, "Device is currently in use, task \"%s\" (%d) blocked until device is released",
+ current->comm,
+ task_pid_nr(current));
+ }
+ } while (ret <= 0);

vfio_group_put(group);



\
 
 \ /
  Last update: 2015-04-14 20:21    [W:0.093 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site