diff mbox series

[1/5] drm/i915/selftests: Skip unstable timing measurements

Message ID 20210107221724.10036-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [1/5] drm/i915/selftests: Skip unstable timing measurements | expand

Commit Message

Chris Wilson Jan. 7, 2021, 10:17 p.m. UTC
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>
---
 drivers/gpu/drm/i915/selftests/intel_memory_region.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Andi Shyti Jan. 8, 2021, 12:26 p.m. UTC | #1
Hi Chris,

> diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> index 75839db63bea..59c58a276677 100644
> --- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> +++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> @@ -852,6 +852,9 @@ static int _perf_memcpy(struct intel_memory_region *src_mr,
>  		}
>  
>  		sort(t, ARRAY_SIZE(t), sizeof(*t), wrap_ktime_compare, NULL);
> +		if (!t[0])
> +			continue;
> +

are you assuming here that if t[0] is '0', also the rest of 't'
is '0'?

Andi

>  		pr_info("%s src(%s, %s) -> dst(%s, %s) %14s %4llu KiB copy: %5lld MiB/s\n",
>  			__func__,
>  			src_mr->name,
Chris Wilson Jan. 8, 2021, 1:26 p.m. UTC | #2
Quoting Andi Shyti (2021-01-08 12:26:45)
> Hi Chris,
> 
> > diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > index 75839db63bea..59c58a276677 100644
> > --- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > +++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > @@ -852,6 +852,9 @@ static int _perf_memcpy(struct intel_memory_region *src_mr,
> >               }
> >  
> >               sort(t, ARRAY_SIZE(t), sizeof(*t), wrap_ktime_compare, NULL);
> > +             if (!t[0])
> > +                     continue;
> > +
> 
> are you assuming here that if t[0] is '0', also the rest of 't'
> is '0'?

It's sorted into ascending order with ktime_t... Hmm, s64 not u64 as I
presumed. So better to check <= 0.
-Chris
Andi Shyti Jan. 8, 2021, 1:51 p.m. UTC | #3
Hi Chris,

> > > diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > > index 75839db63bea..59c58a276677 100644
> > > --- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > > +++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > > @@ -852,6 +852,9 @@ static int _perf_memcpy(struct intel_memory_region *src_mr,
> > >               }
> > >  
> > >               sort(t, ARRAY_SIZE(t), sizeof(*t), wrap_ktime_compare, NULL);
> > > +             if (!t[0])
> > > +                     continue;
> > > +
> > 
> > are you assuming here that if t[0] is '0', also the rest of 't'
> > is '0'?
> 
> It's sorted into ascending order with ktime_t... Hmm, s64 not u64 as I
> presumed. So better to check <= 0.

by division by 0 I guess you mean here:

	div64_u64(mul_u32_u32(4 * size,
			      1000 * 1000 * 1000),
		  t[1] + 2 * t[2] + t[3]) >> 20);

why are you testing t[0]? Did I miss anything else?

Andi
Chris Wilson Jan. 8, 2021, 1:54 p.m. UTC | #4
Quoting Andi Shyti (2021-01-08 13:51:54)
> Hi Chris,
> 
> > > > diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > > > index 75839db63bea..59c58a276677 100644
> > > > --- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > > > +++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > > > @@ -852,6 +852,9 @@ static int _perf_memcpy(struct intel_memory_region *src_mr,
> > > >               }
> > > >  
> > > >               sort(t, ARRAY_SIZE(t), sizeof(*t), wrap_ktime_compare, NULL);
> > > > +             if (!t[0])
> > > > +                     continue;
> > > > +
> > > 
> > > are you assuming here that if t[0] is '0', also the rest of 't'
> > > is '0'?
> > 
> > It's sorted into ascending order with ktime_t... Hmm, s64 not u64 as I
> > presumed. So better to check <= 0.
> 
> by division by 0 I guess you mean here:
> 
>         div64_u64(mul_u32_u32(4 * size,
>                               1000 * 1000 * 1000),
>                   t[1] + 2 * t[2] + t[3]) >> 20);
> 
> why are you testing t[0]? Did I miss anything else?

Since t[0] is the most negative value, if it is <= 0 that implies at
least one of the measurements was bad. If any are bad, all are bad by
association. I considered checking t[4] to make sure that at least the
best was good enough, but paranoia won.
-Chris
Andi Shyti Jan. 8, 2021, 3:04 p.m. UTC | #5
Hi Chris,

> > > > > diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > > > > index 75839db63bea..59c58a276677 100644
> > > > > --- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > > > > +++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
> > > > > @@ -852,6 +852,9 @@ static int _perf_memcpy(struct intel_memory_region *src_mr,
> > > > >               }
> > > > >  
> > > > >               sort(t, ARRAY_SIZE(t), sizeof(*t), wrap_ktime_compare, NULL);
> > > > > +             if (!t[0])
> > > > > +                     continue;
> > > > > +
> > > > 
> > > > are you assuming here that if t[0] is '0', also the rest of 't'
> > > > is '0'?
> > > 
> > > It's sorted into ascending order with ktime_t... Hmm, s64 not u64 as I
> > > presumed. So better to check <= 0.
> > 
> > by division by 0 I guess you mean here:
> > 
> >         div64_u64(mul_u32_u32(4 * size,
> >                               1000 * 1000 * 1000),
> >                   t[1] + 2 * t[2] + t[3]) >> 20);
> > 
> > why are you testing t[0]? Did I miss anything else?
> 
> Since t[0] is the most negative value, if it is <= 0 that implies at
> least one of the measurements was bad. If any are bad, all are bad by
> association. I considered checking t[4] to make sure that at least the
> best was good enough, but paranoia won.

yes, that's what I actually meant with the first question.

Thanks,
Andi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/selftests/intel_memory_region.c b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
index 75839db63bea..59c58a276677 100644
--- a/drivers/gpu/drm/i915/selftests/intel_memory_region.c
+++ b/drivers/gpu/drm/i915/selftests/intel_memory_region.c
@@ -852,6 +852,9 @@  static int _perf_memcpy(struct intel_memory_region *src_mr,
 		}
 
 		sort(t, ARRAY_SIZE(t), sizeof(*t), wrap_ktime_compare, NULL);
+		if (!t[0])
+			continue;
+
 		pr_info("%s src(%s, %s) -> dst(%s, %s) %14s %4llu KiB copy: %5lld MiB/s\n",
 			__func__,
 			src_mr->name,