All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Bragg <robert@sixbynine.org>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 2/5] drm/i915/perf: avoid poll, read, EAGAIN busy loops
Date: Fri, 27 Jan 2017 09:42:02 -0800	[thread overview]
Message-ID: <20170127174205.15325-3-robert@sixbynine.org> (raw)
In-Reply-To: <20170127174205.15325-1-robert@sixbynine.org>

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 <robert@sixbynine.org>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
---
 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.
 		 */
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-01-27 17:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 17:42 [PATCH v2 0/5] drm/i915/perf: Improve handling of OA tail race Robert Bragg
2017-01-27 17:42 ` [PATCH v2 1/5] drm/i915/perf: fix gen7_append_oa_reports comment Robert Bragg
2017-01-27 17:42 ` Robert Bragg [this message]
2017-01-27 17:42 ` [PATCH v2 3/5] drm/i915/perf: avoid read back of head register Robert Bragg
2017-01-27 17:42 ` [PATCH v2 4/5] drm/i915/perf: no head/tail ref in gen7_oa_read Robert Bragg
2017-01-27 17:42 ` [PATCH v2 5/5] drm/i915/perf: improve tail race workaround Robert Bragg
2017-01-30 15:24 ` ✓ Fi.CI.BAT: success for drm/i915/perf: Improve handling of OA tail race (rev2) Patchwork
2017-02-13  4:57 ` [PATCH v2 0/5] drm/i915/perf: Improve handling of OA tail race Kenneth Graunke
2017-02-13 14:36 Robert Bragg
2017-02-13 14:36 ` [PATCH v2 2/5] drm/i915/perf: avoid poll, read, EAGAIN busy loops Robert Bragg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170127174205.15325-3-robert@sixbynine.org \
    --to=robert@sixbynine.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.