From patchwork Wed Apr 26 01:36:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andres Rodriguez X-Patchwork-Id: 9700169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 760406020A for ; Wed, 26 Apr 2017 01:36:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5078B28464 for ; Wed, 26 Apr 2017 01:36:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45225284DB; Wed, 26 Apr 2017 01:36:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D859428464 for ; Wed, 26 Apr 2017 01:36:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D14656E356; Wed, 26 Apr 2017 01:36:39 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-it0-x243.google.com (mail-it0-x243.google.com [IPv6:2607:f8b0:4001:c0b::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF51389F07 for ; Wed, 26 Apr 2017 01:36:38 +0000 (UTC) Received: by mail-it0-x243.google.com with SMTP id 70so5077456ita.2 for ; Tue, 25 Apr 2017 18:36:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LGHQ6zI/r/plaYWCJaDK1LEJraB1azCEL5uTcN4Uceo=; b=m/+b9juSFfjrGaOcK6fvvj7ZGF9JjQWp7R3FqXbf3yv8D+lg8RiZ/9Ovtzn6YS5MRb rTCO7pdyHAM86Y32Z8eERnTv8BWvqKb6novMlBflF6BjviAYDm2IsL80t35f/dB4+/gl hnkyczl18q+5Kcb8Bp5fLF2YP5FwddJKBL68v/y88Bf2fMbcsS7ubJK52hzLoyT3jmkw uGt4CkROG5VBfiflVBoLXLiv4pL+NOofizOCjIs21UTp5hJDLdr9eKCSyUrKECptEkCE 2Zr/VZ1WM6SbZ2RzXPWEb8ovtEufhyKEAjFVhj35I8U7iWpPI2Z0QUwNFvMaJ4LAerUw UCeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LGHQ6zI/r/plaYWCJaDK1LEJraB1azCEL5uTcN4Uceo=; b=f7XC6fe9Zy9tucW8ikamMcPvsJdLZ+RdFiW8rY1LDpB9VnM3u3Py7atuFL2HRd9AvU uCB37iwRmLXGZjL3dG2e619d4qdU49lQTqabMZ1akaqEhLmWy+nMv2P2P7jcB6D8p2tX aYauEnKnvvHjTs1p4/G5aU/YIMgbN/p/fpquQdxMJl7yU5xd5n+wJ0WcdTtDIM1u4hMt fA32Org6GpzTicZ4IXa4W+k6e5vmon85kBzuQpX7nMwOdw334/47zqx3QVo5a8yCIUfm 2U8yF3rtKz6TPyqoHEkWItOKtpDf4weKT+obExlyaVufndrxFP/M21H9D0lF7754ADgv bncg== X-Gm-Message-State: AN3rC/5ZYtpkRuLxqIIfX1piwqTErrFWVsZ34+p0ua3UFikPzSKbk3N+ UbkEB4RUmKlyng== X-Received: by 10.36.155.194 with SMTP id o185mr4438874itd.64.1493170598019; Tue, 25 Apr 2017 18:36:38 -0700 (PDT) Received: from localhost.localdomain (toroon474qw-lp140-01-70-31-87-10.dsl.bell.ca. [70.31.87.10]) by smtp.gmail.com with ESMTPSA id i11sm2534185itf.10.2017.04.25.18.36.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Apr 2017 18:36:37 -0700 (PDT) From: Andres Rodriguez To: dri-devel@lists.freedesktop.org Subject: [PATCH] dma-buf: avoid scheduling on fence status query Date: Tue, 25 Apr 2017 21:36:32 -0400 Message-Id: <20170426013632.4716-1-andresx7@gmail.com> X-Mailer: git-send-email 2.9.3 Cc: andresx7@gmail.com 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When a timeout of zero is specified, the caller is only interested in the fence status. In the current implementation, dma_fence_default_wait will always call schedule_timeout() at least once for an unsignaled fence. This adds a significant overhead to a fence status query. Avoid this overhead by returning early if a zero timeout is specified. Signed-off-by: Andres Rodriguez --- This heavily affects the performance of the Source2 engine running on radv. This patch improves dota2(radv) perf on a i7-6700k+RX480 system from 72fps->81fps. drivers/dma-buf/dma-fence.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index 0918d3f..348e9e2 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -380,6 +380,9 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) return ret; + if (!timeout) + return 0; + spin_lock_irqsave(fence->lock, flags); if (intr && signal_pending(current)) {