[PATCH v2 5/5] drm/scheduler: Add a basic test for modifying entities scheduler list
Philipp Stanner
phasta at mailbox.org
Mon Mar 3 13:55:27 UTC 2025
On Fri, 2025-02-21 at 12:09 +0000, Tvrtko Ursulin wrote:
> Add a basic test for exercising modifying the entities scheduler list
> at
> runtime.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Danilo Krummrich <dakr at kernel.org>
> Cc: Matthew Brost <matthew.brost at intel.com>
> Cc: Philipp Stanner <phasta at kernel.org>
> ---
> drivers/gpu/drm/scheduler/tests/tests_basic.c | 73
> ++++++++++++++++++-
> 1 file changed, 72 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/scheduler/tests/tests_basic.c
> b/drivers/gpu/drm/scheduler/tests/tests_basic.c
> index f0e5ae1220c7..2744a8c262c4 100644
> --- a/drivers/gpu/drm/scheduler/tests/tests_basic.c
> +++ b/drivers/gpu/drm/scheduler/tests/tests_basic.c
> @@ -349,6 +349,77 @@ static struct kunit_suite drm_sched_priority = {
> .test_cases = drm_sched_priority_tests,
> };
>
> +static void drm_sched_test_modify_sched(struct kunit *test)
> +{
> + unsigned int i, cur_ent = 0, cur_sched = 0;
> + struct drm_mock_sched_entity *entity[13];
> + struct drm_mock_scheduler *sched[3];
> + struct drm_mock_sched_job *job;
> + const unsigned int qd = 1000;
> + bool done;
> +
> + /*
> + * Submit a bunch of jobs against entities configured with
> different
> + * schedulers and while waiting for them to complete,
> periodically keep
> + * changing schedulers associated with each entity.
> + *
> + * We set up the queue-depth (qd) and job duration so the
> sched modify
> + * loop has some time to interact with submissions to the
> backend and
> + * job completions as they progress.
> + *
> + * For the number of schedulers and entities we use primes
> in order to
> + * perturb the entity->sched assignments with less of a
> regular pattern.
> + */
Move above.
Besides looks quite nice by now
P.
> +
> + for (i = 0; i < ARRAY_SIZE(sched); i++)
> + sched[i] = drm_mock_new_scheduler(test,
> MAX_SCHEDULE_TIMEOUT);
> +
> + for (i = 0; i < ARRAY_SIZE(entity); i++)
> + entity[i] = drm_mock_new_sched_entity(test,
> +
> DRM_SCHED_PRIORITY_NORMAL,
> + sched[i %
> ARRAY_SIZE(sched)]);
> +
> + for (i = 0; i < qd; i++) {
> + job = drm_mock_new_sched_job(test,
> entity[cur_ent++]);
> + cur_ent %= ARRAY_SIZE(entity);
> + drm_mock_sched_job_set_duration_us(job, 1000);
> + drm_mock_sched_job_submit(job);
> + }
> +
> + do {
> + struct drm_gpu_scheduler *modify;
> +
> + usleep_range(200, 500);
> + cur_ent++;
> + cur_ent %= ARRAY_SIZE(entity);
> + cur_sched++;
> + cur_sched %= ARRAY_SIZE(sched);
> + modify = &sched[cur_sched]->base;
> + drm_sched_entity_modify_sched(&entity[cur_ent]-
> >base, &modify,
> + 1);
> + } while (!drm_mock_sched_job_is_finished(job));
> +
> + done = drm_mock_sched_job_wait_finished(job, HZ);
> + KUNIT_ASSERT_EQ(test, done, true);
> +
> + for (i = 0; i < ARRAY_SIZE(entity); i++)
> + drm_mock_sched_entity_free(entity[i]);
> +
> + for (i = 0; i < ARRAY_SIZE(sched); i++)
> + drm_mock_scheduler_fini(sched[i]);
> +}
> +
> +static struct kunit_case drm_sched_modify_sched_tests[] = {
> + KUNIT_CASE(drm_sched_test_modify_sched),
> + {}
> +};
> +
> +static struct kunit_suite drm_sched_modify_sched = {
> + .name = "drm_sched_basic_modify_sched_tests",
> + .test_cases = drm_sched_modify_sched_tests,
> +};
> +
> kunit_test_suites(&drm_sched_basic,
> &drm_sched_timeout,
> - &drm_sched_priority);
> + &drm_sched_priority,
> + &drm_sched_modify_sched);
More information about the dri-devel
mailing list