All of lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH igt v2] tests/kms_cursor_legacy: Boost timing sensitive subtests to RT prio
Date: Mon, 12 Sep 2016 17:47:57 +0300	[thread overview]
Message-ID: <1473691677-32160-1-git-send-email-imre.deak@intel.com> (raw)
In-Reply-To: <1473689380-30456-1-git-send-email-imre.deak@intel.com>

Even in an otherwise quiescent system there may be user/kernel threads
independent of the test that add enough latency to make timing sensitive
subtests fail. Boost the priority of such subtests to avoid these
failures.

This got rid of sporadic failures in basic-cursor-vs-flip-legacy and
basic-cursor-vs-flip-varying-size with 'missed 1 frame' error message
APL and BSW.

v2:
- Boost the priority in flip_vs_cursor_crc() too.

CC: Chris Wilson <chris@chris-wilson.co.uk>
CC: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 tests/kms_cursor_legacy.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
index 373873a..47dbac9 100644
--- a/tests/kms_cursor_legacy.c
+++ b/tests/kms_cursor_legacy.c
@@ -450,6 +450,39 @@ static unsigned get_vblank(int fd, int pipe, unsigned flags)
 	return vbl.reply.sequence;
 }
 
+struct sched_info {
+	int policy;
+	int prio;
+};
+
+static void boost_to_rt_sched_prio(struct sched_info *old_info)
+{
+	struct sched_param new_param = {
+		.sched_priority = 99,
+	};
+	struct sched_param param;
+	int pid = getpid();
+
+	igt_info("Boosting to RT scheduler priority\n");
+
+	old_info->policy = sched_getscheduler(pid);
+	igt_assert(old_info->policy >= 0);
+	igt_assert(sched_getparam(pid, &param) == 0);
+	old_info->prio = param.sched_priority;
+
+	igt_assert(sched_setscheduler(pid, SCHED_FIFO | SCHED_RESET_ON_FORK,
+				      &new_param) == 0);
+}
+
+static void restore_sched_prio(struct sched_info *info)
+{
+	struct sched_param param = {
+		.sched_priority = info->prio,
+	};
+
+	igt_assert(sched_setscheduler(getpid(), info->policy, &param) == 0);
+}
+
 static void basic_flip_vs_cursor(igt_display_t *display, enum flip_test mode, int nloops)
 {
 	struct drm_mode_cursor arg[2];
@@ -458,6 +491,7 @@ static void basic_flip_vs_cursor(igt_display_t *display, enum flip_test mode, in
 	unsigned vblank_start;
 	int target;
 	enum pipe pipe = find_connected_pipe(display, false);
+	struct sched_info old_sched_info;
 
 	if (mode >= flip_test_atomic)
 		igt_require(display->is_atomic);
@@ -489,6 +523,8 @@ static void basic_flip_vs_cursor(igt_display_t *display, enum flip_test mode, in
 	} else
 		target = 1;
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS);
 	igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start);
 	for (int n = 0; n < target; n++)
@@ -524,6 +560,8 @@ static void basic_flip_vs_cursor(igt_display_t *display, enum flip_test mode, in
 		igt_reset_timeout();
 	} while (nloops--);
 
+	restore_sched_prio(&old_sched_info);
+
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
 	igt_remove_fb(display->drm_fd, &cursor_fb);
@@ -565,6 +603,7 @@ static void two_screens_flip_vs_cursor(igt_display_t *display, int nloops, bool
 	enum pipe pipe2 = find_connected_pipe(display, true);
 	igt_output_t *output2;
 	bool skip_test = false;
+	struct sched_info old_sched_info;
 
 	if (modeset)
 		igt_require(display->is_atomic);
@@ -592,6 +631,8 @@ static void two_screens_flip_vs_cursor(igt_display_t *display, int nloops, bool
 
 	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS);
 	igt_assert_eq(get_vblank(display->drm_fd, pipe, 0), vblank_start);
 	do_ioctl(display->drm_fd, DRM_IOCTL_MODE_CURSOR, &arg[0]);
@@ -636,6 +677,8 @@ static void two_screens_flip_vs_cursor(igt_display_t *display, int nloops, bool
 		}
 	}
 
+	restore_sched_prio(&old_sched_info);
+
 cleanup:
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
@@ -657,6 +700,7 @@ static void basic_cursor_vs_flip(igt_display_t *display, enum flip_test mode, in
 	enum pipe pipe = find_connected_pipe(display, false);
 	igt_output_t *output;
 	uint32_t vrefresh;
+	struct sched_info old_sched_info;
 
 	if (mode >= flip_test_atomic)
 		igt_require(display->is_atomic);
@@ -690,6 +734,8 @@ static void basic_cursor_vs_flip(igt_display_t *display, enum flip_test mode, in
 	igt_debug("Using a target of %ld cursor updates per half-vblank (%u)\n",
 		  target, vrefresh);
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	for (int i = 0; i < nloops; i++) {
 		shared[0] = 0;
 		igt_fork(child, 1) {
@@ -738,6 +784,8 @@ static void basic_cursor_vs_flip(igt_display_t *display, enum flip_test mode, in
 			     shared[0], 2ul*vrefresh*target, vrefresh*target);
 	}
 
+	restore_sched_prio(&old_sched_info);
+
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
 	igt_remove_fb(display->drm_fd, &cursor_fb);
@@ -760,6 +808,7 @@ static void two_screens_cursor_vs_flip(igt_display_t *display, int nloops, bool
 	enum pipe pipe2 = find_connected_pipe(display, true);
 	igt_output_t *output2;
 	bool skip_test = false;
+	struct sched_info old_sched_info;
 
 	shared = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
 	igt_assert(shared != MAP_FAILED);
@@ -790,6 +839,8 @@ static void two_screens_cursor_vs_flip(igt_display_t *display, int nloops, bool
 
 	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	target = 4096;
 	do {
 		vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS);
@@ -856,6 +907,8 @@ static void two_screens_cursor_vs_flip(igt_display_t *display, int nloops, bool
 			     shared[0], 2*60ul*target, 60ul*target);
 	}
 
+	restore_sched_prio(&old_sched_info);
+
 cleanup:
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
@@ -876,6 +929,7 @@ static void flip_vs_cursor_crc(igt_display_t *display, bool atomic)
 	enum pipe pipe = find_connected_pipe(display, false);
 	igt_pipe_crc_t *pipe_crc;
 	igt_crc_t crcs[3];
+	struct sched_info old_sched_info;
 
 	if (atomic)
 		igt_require(display->is_atomic);
@@ -906,6 +960,8 @@ static void flip_vs_cursor_crc(igt_display_t *display, bool atomic)
 	/* Collect reference crc with cursor enabled. */
 	igt_pipe_crc_collect_crc(pipe_crc, &crcs[0]);
 
+	boost_to_rt_sched_prio(&old_sched_info);
+
 	/* Disable cursor, and immediately queue a flip. Check if resulting crc is correct. */
 	for (int i = 1; i >= 0; i--) {
 		vblank_start = get_vblank(display->drm_fd, pipe, DRM_VBLANK_NEXTONMISS);
@@ -926,6 +982,8 @@ static void flip_vs_cursor_crc(igt_display_t *display, bool atomic)
 		igt_assert_crc_equal(&crcs[i], &crcs[2]);
 	}
 
+	restore_sched_prio(&old_sched_info);
+
 	do_cleanup_display(display);
 	igt_remove_fb(display->drm_fd, &fb_info);
 	igt_remove_fb(display->drm_fd, &cursor_fb);
-- 
2.5.0

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

  reply	other threads:[~2016-09-12 14:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12 14:09 [PATCH igt] tests/kms_cursor_legacy: Boost timing sensitive subtests to RT prio Imre Deak
2016-09-12 14:47 ` Imre Deak [this message]
2016-09-12 20:04   ` [PATCH igt v2] " Chris Wilson
2016-09-12 20:57     ` Imre Deak
2016-09-13  7:38       ` Chris Wilson
2016-09-13 11:14         ` Imre Deak

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=1473691677-32160-1-git-send-email-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --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.