From patchwork Tue May 19 09:54:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 6441381 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 36A2BC0432 for ; Wed, 20 May 2015 01:18:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C488203DF for ; Wed, 20 May 2015 01:18:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 444CA203B7 for ; Wed, 20 May 2015 01:18:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 964DC88525; Tue, 19 May 2015 18:18:32 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by gabe.freedesktop.org (Postfix) with ESMTP id B66AD6E5E8; Tue, 19 May 2015 02:54:56 -0700 (PDT) Received: from zmail25.collab.prod.int.phx2.redhat.com (zmail25.collab.prod.int.phx2.redhat.com [10.5.83.31]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4J9ssjl043670; Tue, 19 May 2015 05:54:54 -0400 Date: Tue, 19 May 2015 05:54:54 -0400 (EDT) From: Frediano Ziglio To: spice-devel@lists.freedesktop.org, David Airlie , dri-devel@lists.freedesktop.org, Dave Airlie Message-ID: <163000764.1114319.1432029294390.JavaMail.zimbra@redhat.com> In-Reply-To: <1591625424.1112688.1432028990916.JavaMail.zimbra@redhat.com> Subject: [PATCH] Do not loop on ERESTARTSYS using interruptible waits MIME-Version: 1.0 X-Originating-IP: [10.36.6.24] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - FF38 (Linux)/8.0.6_GA_5922) Thread-Topic: Do not loop on ERESTARTSYS using interruptible waits Thread-Index: LOX3Jmty/uqEX4p42DGJ7itJRa4rcw== X-Mailman-Approved-At: Tue, 19 May 2015 18:18:31 -0700 Cc: linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This problem happens using KMS surfaces and QXL driver. To easy reproduce use KDE Plasma (which use surfaces a lot) and assure you are using KMS surfaces (QXL driver on Fedora/RedHat has a patch to stop using them). Open some complex application like LibreOffice and after a while your machine get stuck using 100% CPU on Xorg. The problem occurs as creating new surfaces not interruptible wait are used however instead of returning ERESTARTSYS back to userspace you try to loop but wait routines always keep returning ERESTARTSYS once the signal is marked. On out of memory conditions TTM module try to move objects to system memory and QXL assure surface is updated before the move. The fix handle differently this case using no interruptible wait so wait functions will wait instead of returning ERESTARTSYS. Note the when the loop occurs driver will send a lot of update requests causing more CPU usage on Qemu side too. Signed-off-by: Frediano Ziglio --- qxl/qxl_cmd.c | 12 +++--------- qxl/qxl_drv.h | 2 +- qxl/qxl_ioctl.c | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drivers/gpu/drm/qxl/qxl_cmd.c b/qxl/qxl_cmd.c index 9782364..bd5404e 100644 --- a/drivers/gpu/drm/qxl/qxl_cmd.c +++ b/drivers/gpu/drm/qxl/qxl_cmd.c @@ -317,14 +317,11 @@ static void wait_for_io_cmd(struct qxl_device *qdev, uint8_t val, long port) { int ret; -restart: ret = wait_for_io_cmd_user(qdev, val, port, false); - if (ret == -ERESTARTSYS) - goto restart; } int qxl_io_update_area(struct qxl_device *qdev, struct qxl_bo *surf, - const struct qxl_rect *area) + const struct qxl_rect *area, bool intr) { int surface_id; uint32_t surface_width, surface_height; @@ -350,7 +347,7 @@ int qxl_io_update_area(struct qxl_device *qdev, struct qxl_bo *surf, mutex_lock(&qdev->update_area_mutex); qdev->ram_header->update_area = *area; qdev->ram_header->update_surface = surface_id; - ret = wait_for_io_cmd_user(qdev, 0, QXL_IO_UPDATE_AREA_ASYNC, true); + ret = wait_for_io_cmd_user(qdev, 0, QXL_IO_UPDATE_AREA_ASYNC, intr); mutex_unlock(&qdev->update_area_mutex); return ret; } @@ -588,10 +585,7 @@ int qxl_update_surface(struct qxl_device *qdev, struct qxl_bo *surf) rect.right = surf->surf.width; rect.top = 0; rect.bottom = surf->surf.height; -retry: - ret = qxl_io_update_area(qdev, surf, &rect); - if (ret == -ERESTARTSYS) - goto retry; + ret = qxl_io_update_area(qdev, surf, &rect, false); return ret; } diff --git a/drivers/gpu/drm/drivers/gpu/drm/qxl/qxl_drv.h b/qxl/qxl_drv.h index 7c6cafe..6745c44 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.h +++ b/drivers/gpu/drm/qxl/qxl_drv.h @@ -462,7 +462,7 @@ void qxl_io_memslot_add(struct qxl_device *qdev, uint8_t id); void qxl_io_notify_oom(struct qxl_device *qdev); int qxl_io_update_area(struct qxl_device *qdev, struct qxl_bo *surf, - const struct qxl_rect *area); + const struct qxl_rect *area, bool intr); void qxl_io_reset(struct qxl_device *qdev); void qxl_io_monitors_config(struct qxl_device *qdev); diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/qxl/qxl_ioctl.c index b110883..afd7297 100644 --- a/drivers/gpu/drm/qxl/qxl_ioctl.c +++ b/drivers/gpu/drm/qxl/qxl_ioctl.c @@ -348,7 +348,7 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data, goto out2; if (!qobj->surface_id) DRM_ERROR("got update area for surface with no id %d\n", update_area->handle); - ret = qxl_io_update_area(qdev, qobj, &area); + ret = qxl_io_update_area(qdev, qobj, &area, true); out2: qxl_bo_unreserve(qobj);