[PATCH i-g-t] tests/perf_pmu: Use perf timestamps when calculating average frequency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>

We can use perf reported timestamps to potentially get a more accurate
frequency average.

Lets see if this improves the situation for sporadic failures like on APL:

 Frequency: min=100, max=750, boost=750 MHz
 Min frequency: requested 90.0, actual 90.0
 Max frequency: requested 749.8, actual 647.9

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
---
 tests/perf_pmu.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 681d4a55d006..14041ee686e8 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -107,7 +107,7 @@ static uint64_t pmu_read_single(int fd)
 	return __pmu_read_single(fd, NULL);
 }
 
-static void pmu_read_multi(int fd, unsigned int num, uint64_t *val)
+static uint64_t pmu_read_multi(int fd, unsigned int num, uint64_t *val)
 {
 	uint64_t buf[2 + num];
 	unsigned int i;
@@ -116,6 +116,8 @@ static void pmu_read_multi(int fd, unsigned int num, uint64_t *val)
 
 	for (i = 0; i < num; i++)
 		val[i] = buf[2 + i];
+
+	return buf[1];
 }
 
 #define assert_within_epsilon(x, ref, tolerance) \
@@ -1167,9 +1169,8 @@ static void
 test_frequency(int gem_fd)
 {
 	uint32_t min_freq, max_freq, boost_freq;
-	uint64_t val[2], start[2];
+	uint64_t val[2], start[2], slept;
 	double min[2], max[2];
-	unsigned long slept;
 	igt_spin_t *spin;
 	int fd, sysfs;
 
@@ -1200,11 +1201,11 @@ test_frequency(int gem_fd)
 
 	gem_quiescent_gpu(gem_fd); /* Idle to be sure the change takes effect */
 	spin = igt_spin_batch_new(gem_fd, 0, I915_EXEC_RENDER, 0);
-	pmu_read_multi(fd, 2, start);
 
-	slept = measured_usleep(batch_duration_ns / 1000);
+	slept = pmu_read_multi(fd, 2, start);
+	measured_usleep(batch_duration_ns / 1000);
+	slept = pmu_read_multi(fd, 2, val) - slept;
 
-	pmu_read_multi(fd, 2, val);
 	min[0] = 1e9*(val[0] - start[0]) / slept;
 	min[1] = 1e9*(val[1] - start[1]) / slept;
 
@@ -1226,11 +1227,11 @@ test_frequency(int gem_fd)
 
 	gem_quiescent_gpu(gem_fd);
 	spin = igt_spin_batch_new(gem_fd, 0, I915_EXEC_RENDER, 0);
-	pmu_read_multi(fd, 2, start);
 
-	slept = measured_usleep(batch_duration_ns / 1000);
+	slept = pmu_read_multi(fd, 2, start);
+	measured_usleep(batch_duration_ns / 1000);
+	slept = pmu_read_multi(fd, 2, val) - slept;
 
-	pmu_read_multi(fd, 2, val);
 	max[0] = 1e9*(val[0] - start[0]) / slept;
 	max[1] = 1e9*(val[1] - start[1]) / slept;
 
-- 
2.14.1

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




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux