From: Peter Senna Tschudin <peter.senna@linux.intel.com>
To: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>,
igt-dev@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org,
Kamil Konieczny <kamil.konieczny@linux.intel.com>,
Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
Chris Wilson <chris.p.wilson@linux.intel.com>
Subject: Re: [PATCH] tests: drm_fdinfo: Fix zero tolerance checks
Date: Mon, 30 Sep 2024 12:47:45 +0200 [thread overview]
Message-ID: <918f0645-c079-49e0-b17a-96dec3a35793@linux.intel.com> (raw)
In-Reply-To: <20240916090329.5279-1-janusz.krzysztofik@linux.intel.com>
On 16.09.2024 11:03, Janusz Krzysztofik wrote:
> When we expect an engine to be busy, we check if its reported busy time
> falls within a +/-5% tolerance range of measurement time period.
> However, when we expect the engine to be idle, we compare its reported
> busy time against zero, still with a +/-5% tolerance range, but now
> calculated against the zero value, then no tolerance at all. Obviously,
> such check fails when the reported busy time is not exactly zero.
>
> Compare engine idle time against measurement time period instead of
> comparing its busy time against zero when we expect the busy time to be
> close to zero. As a debugging aid, display messages with the compared
> values when requested via --debug option or when a failure occurs.
>
Reviewed-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/7742
> Suggested-by: Chris Wilson <chris.p.wilson@linux.intel.com>
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> ---
> tests/intel/drm_fdinfo.c | 51 ++++++++++++++++++++--------------------
> 1 file changed, 25 insertions(+), 26 deletions(-)
>
> diff --git a/tests/intel/drm_fdinfo.c b/tests/intel/drm_fdinfo.c
> index 43216a64e..45d17aaaa 100644
> --- a/tests/intel/drm_fdinfo.c
> +++ b/tests/intel/drm_fdinfo.c
> @@ -107,12 +107,18 @@ static const char *engine_map[] = {
> };
>
> #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 +%.1f%%/-%.1f%% tolerance of %f)\n",\
> - #x, #ref, (double)(x), \
> - (tol_up) * 100.0, (tol_down) * 100.0, \
> - (double)(ref))
> + do { \
> + igt_assert_f((double)(x) <= (1.0 + (tol_up)) * (double)(ref) && \
> + (double)(x) >= (1.0 - (tol_down)) * (double)(ref), \
> + "'%s' != '%s' (%f not within +%.1f%%/-%.1f%% tolerance of %f)\n",\
> + #x, #ref, (double)(x), \
> + (tol_up) * 100.0, (tol_down) * 100.0, \
> + (double)(ref)); \
> + igt_debug("%f within +%.1f%%/-%.1f%% tolerance of %f\n",\
> + (double)(x), \
> + (tol_up) * 100.0, (tol_down) * 100.0, \
> + (double)(ref)); \
> + } while (0)
>
> #define assert_within_epsilon(x, ref, tolerance) \
> __assert_within_epsilon(x, ref, tolerance, tolerance)
> @@ -241,10 +247,8 @@ single(int gem_fd, const intel_ctx_t *ctx,
> else
> end_spin(spin_fd, spin, FLAG_SYNC);
>
> - assert_within_epsilon(val,
> - (flags & TEST_BUSY) && !(flags & TEST_ISOLATION) ?
> - slept : 0.0f,
> - tolerance);
> + assert_within_epsilon((flags & TEST_BUSY) && !(flags & TEST_ISOLATION) ? val : slept - val,
> + slept, tolerance);
>
> /* Check for idle after hang. */
> if (flags & FLAG_HANG) {
> @@ -255,7 +259,7 @@ single(int gem_fd, const intel_ctx_t *ctx,
> slept = measured_usleep(batch_duration_ns / 1000);
> val = read_engine_time(gem_fd, e->class) - val;
>
> - assert_within_epsilon(val, 0, tolerance);
> + assert_within_epsilon(slept - val, slept, tolerance);
> }
>
> igt_spin_free(spin_fd, spin);
> @@ -328,11 +332,8 @@ busy_check_all(int gem_fd, const intel_ctx_t *ctx,
>
> log_busy(num_classes, val);
>
> - for (i = 0; i < num_classes; i++) {
> - double target = i == e->class ? slept : 0.0f;
> -
> - assert_within_epsilon(val[i], target, tolerance);
> - }
> + for (i = 0; i < num_classes; i++)
> + assert_within_epsilon(i == e->class ? val[i] : slept - val[i], slept, tolerance);
>
> gem_quiescent_gpu(gem_fd);
> }
> @@ -405,9 +406,9 @@ most_busy_check_all(int gem_fd, const intel_ctx_t *ctx,
> log_busy(num_classes, val);
>
> for (i = 0; i < num_classes; i++) {
> - double target = slept * busy_class[i];
> + double target = slept * busy_class[i] ?: slept;
>
> - assert_within_epsilon(val[i], target, tolerance);
> + assert_within_epsilon(busy_class[i] ? val[i] : slept - val[i], target, tolerance);
> }
> gem_quiescent_gpu(gem_fd);
> }
> @@ -460,9 +461,9 @@ all_busy_check_all(int gem_fd, const intel_ctx_t *ctx,
> log_busy(num_classes, val);
>
> for (i = 0; i < num_classes; i++) {
> - double target = slept * busy_class[i];
> + double target = slept * busy_class[i] ?: slept;
>
> - assert_within_epsilon(val[i], target, tolerance);
> + assert_within_epsilon(busy_class[i] ? val[i] : slept - val[i], target, tolerance);
> }
> gem_quiescent_gpu(gem_fd);
> }
> @@ -601,10 +602,8 @@ virtual(int i915, const intel_ctx_cfg_t *base_cfg, unsigned int flags)
> else
> end_spin(i915, spin, FLAG_SYNC);
>
> - assert_within_epsilon(val,
> - flags & TEST_BUSY ?
> - slept : 0.0f,
> - tolerance);
> + assert_within_epsilon(flags & TEST_BUSY ? val : slept - val,
> + slept, tolerance);
>
> /* Check for idle after hang. */
> if (flags & FLAG_HANG) {
> @@ -616,7 +615,7 @@ virtual(int i915, const intel_ctx_cfg_t *base_cfg, unsigned int flags)
> 1000);
> val = read_engine_time(i915, class) - val;
>
> - assert_within_epsilon(val, 0, tolerance);
> + assert_within_epsilon(slept - val, slept, tolerance);
> }
>
> igt_spin_free(i915, spin);
> @@ -724,7 +723,7 @@ virtual_all(int i915, const intel_ctx_cfg_t *base_cfg, unsigned int flags)
> 1000);
> val = read_engine_time(i915, class) - val;
>
> - assert_within_epsilon(val, 0, tolerance);
> + assert_within_epsilon(slept - val, slept, tolerance);
> }
>
> igt_spin_free(i915, spin);
next prev parent reply other threads:[~2024-09-30 10:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-16 9:03 [PATCH] tests: drm_fdinfo: Fix zero tolerance checks Janusz Krzysztofik
2024-09-16 11:40 ` ✓ CI.xeBAT: success for " Patchwork
2024-09-16 12:00 ` ✓ Fi.CI.BAT: " Patchwork
2024-09-16 14:05 ` ✗ CI.xeFULL: failure " Patchwork
2024-09-16 14:38 ` Janusz Krzysztofik
2024-09-16 16:53 ` ✗ Fi.CI.IGT: " Patchwork
2024-09-17 8:01 ` Janusz Krzysztofik
2024-09-30 10:47 ` Peter Senna Tschudin [this message]
2024-09-30 11:30 ` [PATCH] " Janusz Krzysztofik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=918f0645-c079-49e0-b17a-96dec3a35793@linux.intel.com \
--to=peter.senna@linux.intel.com \
--cc=chris.p.wilson@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=janusz.krzysztofik@linux.intel.com \
--cc=kamil.konieczny@linux.intel.com \
--cc=tvrtko.ursulin@igalia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox