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.william...@redhat.com> Cc: sta...@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); -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html