From patchwork Fri Jan 27 17:42:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9542401 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 1A440604A0 for ; Fri, 27 Jan 2017 17:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DC9C276D6 for ; Fri, 27 Jan 2017 17:42:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0280927D4A; Fri, 27 Jan 2017 17:42:33 +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_SIGNED, 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 BC1EB276D6 for ; Fri, 27 Jan 2017 17:42:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6178E6EDF7; Fri, 27 Jan 2017 17:42:33 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id F189D6EDF4 for ; Fri, 27 Jan 2017 17:42:30 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id y143so18990626pfb.1 for ; Fri, 27 Jan 2017 09:42:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5b9nG87DpQWCYzz9p7rVmUyLfInsxVpAu023OOIFUfQ=; b=EYTBCiIcMw2qNDE0TGpJig9jkd7FJbpgmUw4xHzNK3gdTTYyjKmSKX8bvwrr/Rcvln /FxsZxeiuSxr8O02YrcL4SqvXf6sCw0HDoTLyJ3rrAG2LtQY6qMEtT3UR3EubKElHhM/ WYUprTmXR+LEAIdcP/ao7Er7OABw13N/zm+EeaQ4MnG7d2jhC2sGXB4RxN3YT8CCBSNX zYOgL/xe2WcvR7Km303wb1kwurp656mPPjNHnKuyZcryy4NbE05qKYvcLuHSk+vuKTmV 9Jm60aE8SXYb8M3/ekAwekAWlYg+d2lvwZuodrgA3bD1RlrR7KLqqO2VwihUHQjvIDm5 LFmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5b9nG87DpQWCYzz9p7rVmUyLfInsxVpAu023OOIFUfQ=; b=tNFaZNhVDnhol8IEK0J3TFyGHu+tvvqYMaPzKGe58EW5UIuggMrJYYpmvXNXn2FqxJ eqKOxo7r1MbJ1OSiX8E+BCX8LkpYmjpmpsueecm/uCypbD5l+qy+2EUMNKnKc5Fr16BL 2e2wjuDkdOIl9yAajXnC8WX9KvpMZKgxZymfX+qsLFavSs4MP+A3jh8LaafCw65+Jacv zph4OXMF/W91yi45Tlu2mxVIqqhYdMTwfnzOzSmfQYgdspM3wM4jcSiU59S1H4JwmOjm pbhhXn7+SYJC3D3K1WxqyhLgX91P8LF+FzhCaUvb4hlDjZe8oeBI3leWLY7YUv7Qi/8z keJA== X-Gm-Message-State: AIkVDXIRXJgd+Rae8YSejh58zAZsyqHD8Em+s9/jKte+/FLlIcH8sBwFo7bQCbNRuOfjEQ== X-Received: by 10.84.148.134 with SMTP id k6mr14345226pla.142.1485538950580; Fri, 27 Jan 2017 09:42:30 -0800 (PST) Received: from sixbynine.org ([207.194.157.2]) by smtp.gmail.com with ESMTPSA id e4sm7570203pgc.45.2017.01.27.09.42.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Jan 2017 09:42:30 -0800 (PST) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Fri, 27 Jan 2017 09:42:02 -0800 Message-Id: <20170127174205.15325-3-robert@sixbynine.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170127174205.15325-1-robert@sixbynine.org> References: <20170127174205.15325-1-robert@sixbynine.org> Subject: [Intel-gfx] [PATCH v2 2/5] drm/i915/perf: avoid poll, read, EAGAIN busy loops X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP If the function for checking whether there is OA buffer data available (during a poll or blocking read) has false positives then we want to avoid a situation where the subsequent read() returns EAGAIN (after a more accurate check) followed by a poll() immediately reporting the same false positive POLLIN event and effectively maintaining a busy loop until there really is data. This makes sure that we clear the .pollin event status whenever we return EAGAIN to userspace which will throttle subsequent POLLIN events and repeated attempts to read to the 5ms intervals of the hrtimer callback we have. Signed-off-by: Robert Bragg Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/i915_perf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index b0eec762b9b4..4bb7333dac45 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -1352,7 +1352,15 @@ static ssize_t i915_perf_read(struct file *file, mutex_unlock(&dev_priv->perf.lock); } - if (ret >= 0) { + /* We allow the poll checking to sometimes report false positive POLLIN + * events where we might actually report EAGAIN on read() if there's + * not really any data available. In this situation though we don't + * want to enter a busy loop between poll() reporting a POLLIN event + * and read() returning -EAGAIN. Clearing the oa.pollin state here + * effectively ensures we back off until the next hrtimer callback + * before reporting another POLLIN event. + */ + if (ret >= 0 || ret == -EAGAIN) { /* Maybe make ->pollin per-stream state if we support multiple * concurrent streams in the future. */