[Intel-gfx] [PATCH i-g-t 3/3] tests/gem_exec_schedule: Add test for resetting preemptive batch

Chris Wilson chris at chris-wilson.co.uk
Mon Dec 4 17:42:02 UTC 2017


Quoting Antonio Argenziano (2017-12-04 17:23:15)
> This patch adds a test that will trigger a preemption of a low priority
> batch by a 'bad' batch buffer which will hang. The test aims at making
> sure that a hanging high priority batch will not disrupt the submission
> flow of low priority contexts.
> 
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Michal Winiarski <michal.winiarski at intel.com>
> Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
> ---
>  tests/gem_exec_schedule.c | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c
> index ae44a6c0..5a4d63f9 100644
> --- a/tests/gem_exec_schedule.c
> +++ b/tests/gem_exec_schedule.c
> @@ -511,6 +511,39 @@ static void preempt_self(int fd, unsigned ring)
>         gem_close(fd, result);
>  }
>  
> +static void bad_preemptive(int fd, unsigned ring)
> +{
> +       igt_spin_t *spin[16];
> +       igt_spin_t *bad;
> +       uint32_t ctx[2];
> +
> +       ctx[LO] = gem_context_create(fd);
> +       gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
> +
> +       ctx[HI] = gem_context_create(fd);
> +       gem_context_set_priority(fd, ctx[HI], MAX_PRIO);
> +
> +       for (int n = 0; n < 16; n++) {
> +               gem_context_destroy(fd, ctx[LO]);
> +               ctx[LO] = gem_context_create(fd);
> +               gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
> +
> +               spin[n] = __igt_spin_batch_new(fd, ctx[LO], ring, 0, true);
> +               igt_debug("spin[%d].handle=%d\n", n, spin[n]->handle);
> +       }
> +
> +       bad = igt_spin_batch_new(fd, ctx[HI], ring, 0, false);
> +       gem_wait(fd, bad->handle, NULL);
> +
> +       for (int n = 0; n < 16; n++) {
> +               igt_assert(gem_bo_busy(fd, spin[n]->handle));
> +               igt_spin_batch_free(fd, spin[n]);
> +       }

Is this really policy you want to enforce? I certainly don't intend to
mandate that the kernel isn't allowed to use RT throttling.

> +
> +       gem_context_destroy(fd, ctx[LO]);
> +       gem_context_destroy(fd, ctx[HI]);
> +}
> +
>  static void deep(int fd, unsigned ring)
>  {
>  #define XS 8
> @@ -1033,6 +1066,12 @@ igt_main
>                                                 preempt(fd, e->exec_id | e->flags, NEW_CTX | HANG_LP);
>                                                 igt_fork_hang_detector(fd);
>                                         }
> +
> +                                       igt_subtest_f("bad-preemptive-%s", e->name) {
> +                                               igt_stop_hang_detector();
> +                                               bad_preemptive(fd, e->exec_id | e->flags);
> +                                               igt_fork_hang_detector(fd);
> +                                       }

Split into non-hang/hang portions and use igt_subtest_group +
igt_fixture.
-Chris


More information about the Intel-gfx mailing list