Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992780AbbEOXQ4 (ORCPT ); Fri, 15 May 2015 19:16:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43376 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2992872AbbEOXPG (ORCPT ); Fri, 15 May 2015 19:15:06 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Williamson Subject: [PATCH 4.0 16/60] vfio: Fix runaway interruptible timeout Date: Fri, 15 May 2015 16:14:17 -0700 Message-Id: <20150515231019.313124278@linuxfoundation.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: <20150515231018.815421141@linuxfoundation.org> References: <20150515231018.815421141@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2296 Lines: 71 4.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alex Williamson commit db7d4d7f40215843000cb9d441c9149fd42ea36b upstream. Commit 13060b64b819 ("vfio: Add and use device request op for vfio bus drivers") incorrectly makes use of an interruptible timeout. When interrupted, the signal remains pending resulting in subsequent timeouts occurring instantly. This makes the loop spin at a much higher rate than intended. Instead of making this completely non-interruptible, we can change this into a sort of interruptible-once behavior and use the "once" to log debug information. The driver API doesn't allow us to abort and return an error code. Signed-off-by: Alex Williamson Fixes: 13060b64b819 Signed-off-by: Greg Kroah-Hartman --- drivers/vfio/vfio.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -711,6 +711,8 @@ void *vfio_del_group_dev(struct device * void *device_data = device->device_data; struct vfio_unbound_dev *unbound; unsigned int i = 0; + long ret; + bool interrupted = false; /* * The group exists so long as we have a device reference. Get @@ -756,9 +758,22 @@ void *vfio_del_group_dev(struct device * vfio_device_put(device); - } while (wait_event_interruptible_timeout(vfio.release_q, - !vfio_dev_present(group, dev), - HZ * 10) <= 0); + if (interrupted) { + ret = wait_event_timeout(vfio.release_q, + !vfio_dev_present(group, dev), HZ * 10); + } else { + ret = wait_event_interruptible_timeout(vfio.release_q, + !vfio_dev_present(group, dev), HZ * 10); + if (ret == -ERESTARTSYS) { + interrupted = true; + dev_warn(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 linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/