From: Alex Williamson <alex.williamson@redhat.com>
To: alex.williamson@redhat.com
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: [PATCH 1/2] vfio: Flush signals on device request interruption
Date: Tue, 14 Apr 2015 12:14:45 -0600 [thread overview]
Message-ID: <20150414181445.6081.32372.stgit@gimli.home> (raw)
In-Reply-To: <20150414180228.6081.10459.stgit@gimli.home>
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);
next prev parent reply other threads:[~2015-04-14 18:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2015-04-14 18:14 ` [PATCH 2/2] vfio-pci: Log device requests " Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150414181445.6081.32372.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox