[igt-dev] [PATCH i-g-t] tests/perf: oa-exponents: rework match computation

Lionel Landwerlin lionel.g.landwerlin at intel.com
Sat Mar 17 18:12:48 UTC 2018


In commit c3d11ca104fa2f706e0b85941354e159634ea4ee ("tests/perf: make
oa-exponents subtest more reliable") we introduced a new method to
count the number of matches for expected timestamp delta between OA
timer reports. We had to leave some room for error because of patterns
like this :

(perf:405) DEBUG: report0019 ts=e217de20 hw_id=0x00000014 delta=64
(perf:405) DEBUG: report0020 ts=e217de60 hw_id=0x00000014 delta=64
(perf:405) DEBUG: report0021 ts=e217dea0 hw_id=0x00000014 delta=64
(perf:405) DEBUG: report0022 ts=e217df66 hw_id=0x00000014 delta=198 ******
(perf:405) DEBUG: report0023 ts=e217dfa0 hw_id=0x00000014 delta=58 ******
(perf:405) DEBUG: report0024 ts=e217dfe0 hw_id=0x00000014 delta=64
(perf:405) DEBUG: report0025 ts=e217e020 hw_id=0x00000014 delta=64
(perf:405) DEBUG: report0026 ts=e217e060 hw_id=0x00000014 delta=64

Although it's not clear exactly why the OA unit is behaving this way,
what seems to be consistent is that if it misses a dead line to
produce a report (delta of 198), it will catch up on the next report
(delta of 58).

The combination of both deltas 198 + 58 is a multiple of the expected
delta. This change takes this into account to test whether this
matches the expectation.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105483
---
 tests/perf.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/tests/perf.c b/tests/perf.c
index 153f30eb..6d8ff578 100644
--- a/tests/perf.c
+++ b/tests/perf.c
@@ -1766,21 +1766,37 @@ test_oa_exponents(void)
 			  timer_reports[0].report[1],
 			  oa_report_get_ctx_id(timer_reports[0].report));
 		for (int i = 1; i < n_timer_reports; i++) {
+			uint32_t prev_delta = i == 1 ? 0 :
+				(timer_reports[i - 1].report[1] - timer_reports[i - 2].report[1]);
 			uint32_t delta =
 				timer_reports[i].report[1] - timer_reports[i - 1].report[1];
+			uint32_t next_delta = i == (n_timer_reports - 1) ? 0 :
+				(timer_reports[i + 1].report[1] - timer_reports[i].report[1]);
+			/* We consider delta in timestamp to match if :
+			 *
+			 *    - it's strictly equal
+			 *
+			 *    - or either the sum of current delta and the
+			 *      previous or following delta should be a multiple
+			 *      of the expected delta.
+			 */
+			bool delta_match = expected_timestamp_delta == delta ||
+				((delta + prev_delta) % expected_timestamp_delta) == 0 ||
+				((delta + next_delta) % expected_timestamp_delta) == 0;
 
 			igt_debug("report%04i ts=%08x hw_id=0x%08x delta=%u %s\n", i,
 				  timer_reports[i].report[1],
 				  oa_report_get_ctx_id(timer_reports[i].report),
-				  delta, delta == expected_timestamp_delta ? "" : "******");
+				  delta, delta_match ? "" : "******");
 
-			matches += expected_timestamp_delta <= delta;
+			if (delta_match)
+				matches++;
 		}
 
-		igt_debug("matches=%u/%u\n", matches, n_timer_reports - 1);
-
-		/* Allow for a couple of errors. */
-		igt_assert_lte(n_timer_reports - 3, matches);
+		/* We have n reports there we can only compute n - 1
+		 * deltas. They all have to match the expected delta value.
+		 */
+		igt_assert_lte(n_timer_reports - 1, matches);
 	}
 
 	load_helper_stop();
-- 
2.16.2



More information about the igt-dev mailing list