drm/i915/selftests: Skip unstable timing measurements
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 8 Jan 2021 20:40:21 +0000 (20:40 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 8 Jan 2021 21:35:54 +0000 (21:35 +0000)
If any of the perf tests run into 0 time, not only are we liable to
divide by zero, but the result would be highly questionable.
Nevertheless, let's not have a div-by-zero error.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Andi Shyti <andi.shyti@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210108204026.20682-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/selftests/intel_memory_region.c

index 75839db..ce7adfa 100644 (file)
@@ -852,14 +852,22 @@ static int _perf_memcpy(struct intel_memory_region *src_mr,
                }
 
                sort(t, ARRAY_SIZE(t), sizeof(*t), wrap_ktime_compare, NULL);
+               if (t[0] <= 0) {
+                       /* ignore the impossible to protect our sanity */
+                       pr_debug("Skipping %s src(%s, %s) -> dst(%s, %s) %14s %4lluKiB copy, unstable measurement [%lld, %lld]\n",
+                                __func__,
+                                src_mr->name, repr_type(src_type),
+                                dst_mr->name, repr_type(dst_type),
+                                tests[i].name, size >> 10,
+                                t[0], t[4]);
+                       continue;
+               }
+
                pr_info("%s src(%s, %s) -> dst(%s, %s) %14s %4llu KiB copy: %5lld MiB/s\n",
                        __func__,
-                       src_mr->name,
-                       repr_type(src_type),
-                       dst_mr->name,
-                       repr_type(dst_type),
-                       tests[i].name,
-                       size >> 10,
+                       src_mr->name, repr_type(src_type),
+                       dst_mr->name, repr_type(dst_type),
+                       tests[i].name, size >> 10,
                        div64_u64(mul_u32_u32(4 * size,
                                              1000 * 1000 * 1000),
                                  t[1] + 2 * t[2] + t[3]) >> 20);