[Intel-gfx] [PATCH igt] tests/kms_cursor_legacy: Boost timing sensitive subtests to RT prio

Imre Deak imre.deak at intel.com
Mon Sep 12 14:09:40 UTC 2016


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.

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

diff --git a/tests/kms_cursor_legacy.c b/tests/kms_cursor_legacy.c
index 373873a..ac4cffa 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);
@@ -524,6 +558,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 +601,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 +629,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 +675,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 +698,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 +732,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 +782,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 +806,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 +837,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 +905,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);
-- 
2.5.0



More information about the Intel-gfx mailing list