Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH 0/2] vfio: Add signal flush and log more verbosely
@ 2015-04-14 18:14 Alex Williamson
  2015-04-14 18:14 ` [PATCH 1/2] vfio: Flush signals on device request interruption Alex Williamson
  2015-04-14 18:14 ` [PATCH 2/2] vfio-pci: Log device requests more verbosely Alex Williamson
  0 siblings, 2 replies; 3+ messages in thread
From: Alex Williamson @ 2015-04-14 18:14 UTC (permalink / raw)
  To: alex.williamson; +Cc: linux-kernel, kvm

Fix an issue where signals are not flushed causing our interruptible
wait_event to go into a tight loop once a signal is received.  Also
add more logging throughout.  We have no -EBUSY return path for a
driver remove request and it's confusing to users when tasks get
blocked waiting for the device to release.  Provide more clues what's
happening.  Thanks,

Alex

---

Alex Williamson (2):
      vfio: Flush signals on device request interruption
      vfio-pci: Log device requests more verbosely


 drivers/vfio/pci/vfio_pci.c |    8 +++++++-
 drivers/vfio/vfio.c         |   13 ++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] vfio: Flush signals on device request interruption
  2015-04-14 18:14 [PATCH 0/2] vfio: Add signal flush and log more verbosely Alex Williamson
@ 2015-04-14 18:14 ` Alex Williamson
  2015-04-14 18:14 ` [PATCH 2/2] vfio-pci: Log device requests more verbosely Alex Williamson
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2015-04-14 18:14 UTC (permalink / raw)
  To: alex.williamson; +Cc: linux-kernel, kvm

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);
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] vfio-pci: Log device requests more verbosely
  2015-04-14 18:14 [PATCH 0/2] vfio: Add signal flush and log more verbosely Alex Williamson
  2015-04-14 18:14 ` [PATCH 1/2] vfio: Flush signals on device request interruption Alex Williamson
@ 2015-04-14 18:14 ` Alex Williamson
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2015-04-14 18:14 UTC (permalink / raw)
  To: alex.williamson; +Cc: linux-kernel, kvm

Log some clues indicating whether the user is receiving device
request interfaces or not listening.  This can help indicate why a
driver unbind is blocked or explain why QEMU automatically unplugged
a device from the VM.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/vfio/pci/vfio_pci.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index d9f7ec5..5eb9cbe 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -923,8 +923,14 @@ static void vfio_pci_request(void *device_data, unsigned int count)
 	mutex_lock(&vdev->igate);
 
 	if (vdev->req_trigger) {
-		dev_dbg(&vdev->pdev->dev, "Requesting device from user\n");
+		if (!(count % 10))
+			dev_notice_ratelimited(&vdev->pdev->dev,
+				"Relaying device request to user (#%u)\n",
+				count);
 		eventfd_signal(vdev->req_trigger, 1);
+	} else if (count == 0) {
+		dev_warn(&vdev->pdev->dev,
+			"No device request channel registered, blocked until released by user\n");
 	}
 
 	mutex_unlock(&vdev->igate);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-14 18:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-14 18:14 [PATCH 0/2] vfio: Add signal flush and log more verbosely Alex Williamson
2015-04-14 18:14 ` [PATCH 1/2] vfio: Flush signals on device request interruption Alex Williamson
2015-04-14 18:14 ` [PATCH 2/2] vfio-pci: Log device requests more verbosely Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox