[igt-dev] [PATCH i-g-t] i915: Use O_NONBLOCK for faster ringsize probing

Chris Wilson chris at chris-wilson.co.uk
Fri Oct 11 08:06:42 UTC 2019


When the kernel supports O_NONBLOCK reporting of a full execbuf queue,
take advantage of that to immediately report when the output would block
due to the ring being full.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 lib/i915/gem_ring.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/i915/gem_ring.c b/lib/i915/gem_ring.c
index 9f099edff..5ca2a728b 100644
--- a/lib/i915/gem_ring.c
+++ b/lib/i915/gem_ring.c
@@ -21,6 +21,7 @@
  * IN THE SOFTWARE.
  */
 
+#include <fcntl.h>
 #include <signal.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
@@ -89,11 +90,16 @@ __gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags
 
 	count = 0;
 	do {
-		if (__execbuf(fd, &execbuf) == 0) {
+		int err = __execbuf(fd, &execbuf);
+
+		if (err == 0) {
 			count++;
 			continue;
 		}
 
+		if (err == -EWOULDBLOCK)
+			break;
+
 		if (last[1] == count)
 			break;
 
@@ -102,8 +108,6 @@ __gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags
 		last[1] = last[0];
 		last[0] = count;
 	} while (1);
-
-	igt_assert_eq(__execbuf(fd, &execbuf), -EINTR);
 	igt_assert(count > 2);
 
 	memset(&itv, 0, sizeof(itv));
@@ -145,6 +149,9 @@ gem_measure_ring_inflight(int fd, unsigned int engine, enum measure_ring_flags f
 
 	fd = gem_reopen_driver(fd);
 
+	/* When available, disable execbuf throttling */
+	fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | O_NONBLOCK);
+
 	if (engine == ALL_ENGINES) {
 		for_each_physical_engine(fd, engine) {
 			unsigned int count =
-- 
2.23.0



More information about the igt-dev mailing list