From patchwork Mon Aug 29 18:16:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9304309 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 94814601C0 for ; Mon, 29 Aug 2016 18:16:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A58F28935 for ; Mon, 29 Aug 2016 18:16:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F2432894A; Mon, 29 Aug 2016 18:16:23 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F041928935 for ; Mon, 29 Aug 2016 18:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755096AbcH2SQV (ORCPT ); Mon, 29 Aug 2016 14:16:21 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35584 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbcH2SQU (ORCPT ); Mon, 29 Aug 2016 14:16:20 -0400 Received: by mail-wm0-f68.google.com with SMTP id i5so10588212wmg.2 for ; Mon, 29 Aug 2016 11:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=X+pdE4ui3uTEGM+d71zpngpu5h2jivURZgBGnf20eGU=; b=C/wPbFBtiAqKOwVwxhU6defpihyuWYOJFXssYALsrB/JyXnVyODr22lztvmiAPcBjD FdIHsbNh9kU6I1Bi8dgXo2kS5EG424e5w6MboEp6F3WKb0jIJ09CbA/Teb6gv0pY9Pol lwxn9J4q9h1AAiNjUkyRpmms8Af/gqI5O9qWybhpQvcP1Gb3LkW+Ke2fugv6eQvf3uSv LpRvNPsYoqB4MabcLKd09CDiPBzL57wfUzdFiHSzqmZjNrHNthJeCZYvOply5s+AzeTO zUj59bcQvCcNsBHVo1lAMmdII/sRaxAwmBGrNszBy2g9zewla1iLeI+QgKmR/c2typkP ql+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=X+pdE4ui3uTEGM+d71zpngpu5h2jivURZgBGnf20eGU=; b=P3KuW47d/raqW5WsNmgyCmnMdHR0B54KFrtmSvfNKkOJRd7iImj2ybuL/QFi0H5mXS 8KCJ1O9KfJ96uXirD6TDahYXVz/Qz8umyWzHIgC0Ud45swKAPTDCSzW3KH/jtZQHNwX3 Jq6dKYCRnwX0482m4t6L/idJ4RMzYP+/dnkxVFetBQX6nQV/kOA/rAQrFdH3HyvqhEUl S3AWM0B97WcIL6BHEA85MtgodYj4ut7/BFkNGFBfGJPZTdpeeopORV2uBagSqhID3CvE MG1AR7c4vlYYuWGsI1A9TxAxxAxryfqsvcrIZMDWB8bJLLaf2lJob6BK0Chv8AYwloLq PPdQ== X-Gm-Message-State: AE9vXwM1b/UioIknnroDXEAvErbQYT6dzgj0SgZi+NUGosMl7SnXNWmXSIRhjE01vHKhJg== X-Received: by 10.28.60.136 with SMTP id j130mr12502428wma.93.1472494578791; Mon, 29 Aug 2016 11:16:18 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id vh6sm35547622wjb.0.2016.08.29.11.16.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Aug 2016 11:16:17 -0700 (PDT) From: Chris Wilson To: dri-devel@lists.freedesktop.org Cc: Chris Wilson , Sumit Semwal , Gustavo Padovan , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH] dma-buf/sync-file: Avoid enable fence signaling if poll(.timeout=0) Date: Mon, 29 Aug 2016 19:16:13 +0100 Message-Id: <20160829181613.30722-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160829070834.22296-11-chris@chris-wilson.co.uk> References: <20160829070834.22296-11-chris@chris-wilson.co.uk> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we being polled with a timeout of zero, a nonblocking busy query, we don't need to install any fence callbacks as we will not be waiting. As we only install the callback once, the overhead comes from the atomic bit test that also causes serialisation between threads. Signed-off-by: Chris Wilson Cc: Sumit Semwal Cc: Gustavo Padovan Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linaro-mm-sig@lists.linaro.org Reviewed-by: Gustavo Padovan --- drivers/dma-buf/sync_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c index 486d29c1a830..abb5fdab75fd 100644 --- a/drivers/dma-buf/sync_file.c +++ b/drivers/dma-buf/sync_file.c @@ -306,7 +306,8 @@ static unsigned int sync_file_poll(struct file *file, poll_table *wait) poll_wait(file, &sync_file->wq, wait); - if (!test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) { + if (!poll_does_not_wait(wait) && + !test_and_set_bit(POLL_ENABLED, &sync_file->fence->flags)) { if (fence_add_callback(sync_file->fence, &sync_file->cb, fence_check_cb_func) < 0) wake_up_all(&sync_file->wq);