[igt-dev] [PATCH i-g-t v3 2/3] tests/perf_pmu: Handle thermally throttled devices
Tvrtko Ursulin
tursulin at ursulin.net
Mon Feb 12 11:35:38 UTC 2018
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Some systems cannot reach the advertised maximum frequency due throttling.
Handle them by considering a 100MHz lower limit.
v2: Use more relaxed tolerance only in the downward direction.
(Chris Wilson)
v3: Improved assert message. (Chris Wilson)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
---
tests/perf_pmu.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index afc7dc992681..cf701bbd3f18 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -120,11 +120,16 @@ static uint64_t pmu_read_multi(int fd, unsigned int num, uint64_t *val)
return buf[1];
}
+#define __assert_within_epsilon(x, ref, tol_up, tol_down) \
+ igt_assert_f((double)(x) <= (1.0 + (tol_up)) * (double)(ref) && \
+ (double)(x) >= (1.0 - (tol_down)) * (double)(ref), \
+ "'%s' != '%s' (%f not within +%f%%/-%f%% tolerance of %f)\n",\
+ #x, #ref, (double)(x), \
+ (tol_up) * 100.0, (tol_down) * 100.0, \
+ (double)(ref))
+
#define assert_within_epsilon(x, ref, tolerance) \
- igt_assert_f((double)(x) <= (1.0 + (tolerance)) * (double)(ref) && \
- (double)(x) >= (1.0 - (tolerance)) * (double)(ref), \
- "'%s' != '%s' (%f not within %f%% tolerance of %f)\n",\
- #x, #ref, (double)(x), (tolerance) * 100.0, (double)(ref))
+ __assert_within_epsilon(x, ref, tolerance, tolerance)
/*
* Helper for cases where we assert on time spent sleeping (directly or
@@ -1229,8 +1234,13 @@ test_frequency(int gem_fd)
min[0], min[1]);
igt_info("Max frequency: requested %.1f, actual %.1f\n",
max[0], max[1]);
+
assert_within_epsilon(min[0], min_freq, tolerance);
- assert_within_epsilon(max[0], max_freq, tolerance);
+ /*
+ * On thermally throttled devices we cannot be sure maximum frequency
+ * can be reached so use larger tolerance downards.
+ */
+ __assert_within_epsilon(max[0], max_freq, tolerance, 0.15f);
}
static bool wait_for_rc6(int fd)
--
2.14.1
More information about the igt-dev
mailing list