drm/sched: Speed up some unit tests
Subsystems (3)
PATCH 1/1 drm/sched: Speed up some unit tests
Some tests are on right on the limit of targetting a one second runtime, and some of those have recently been correctly marked as slow. Lets instead make them a bit quicker, by either reducing the amount of submitted jobs or waiting a bit less. For the latter a comment is added to explain why that should be fine, and for the former, they are tests which aim to hit races via stress testing, so reducing the runtime is also fine since the main thing is the number of test runs over time and machines.
--- drivers/gpu/drm/scheduler/tests/tests_basic.c | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-)
drivers/gpu/drm/scheduler/tests/tests_basic.c +20 -8
@@ -382,7 +382,7 @@ static void drm_sched_change_priority(struct kunit *test)struct drm_mock_sched_entity *entity[DRM_SCHED_PRIORITY_COUNT ];struct drm_mock_scheduler *sched = test->priv;struct drm_mock_sched_job *job; -const unsigned int qd =1000 ; +const unsigned int qd =500 ;unsigned int i, cur_ent =0 ;enum drm_sched_priority p;
@@ -421,7 +421,7 @@ static void drm_sched_change_priority(struct kunit *test)static struct kunit_case drm_sched_priority_tests[] = {KUNIT_CASE (drm_sched_priorities), -KUNIT_CASE_SLOW (drm_sched_change_priority), +KUNIT_CASE (drm_sched_change_priority), {} };
@@ -438,7 +438,7 @@ static void drm_sched_test_modify_sched(struct kunit *test)struct drm_mock_sched_entity *entity[13 ];struct drm_mock_scheduler *sched[3 ];struct drm_mock_sched_job *job; -const unsigned int qd =1000 ; +const unsigned int qd =500 ;/* * Submit a bunch of jobs against entities configured with different
@@ -500,6 +500,7 @@ static struct kunit_suite drm_sched_modify_sched = {static void drm_sched_test_credits (struct kunit *test) { +const long timeout =msecs_to_jiffies (200 );struct drm_mock_sched_entity *entity;struct drm_mock_scheduler *sched;struct drm_mock_sched_job *job[2 ];
@@ -523,22 +524,33 @@ static void drm_sched_test_credits(struct kunit *test)drm_mock_sched_job_submit (job[0 ]);drm_mock_sched_job_submit (job[1 ]); - done =drm_mock_sched_job_wait_scheduled (job[0 ],HZ ); + done =drm_mock_sched_job_wait_scheduled (job[0 ], timeout);KUNIT_ASSERT_TRUE (test, done); - done =drm_mock_sched_job_wait_scheduled (job[1 ],HZ ); +/* +* Verify that the scheduler has not consumed more than the configured +* single credit. This can false negative if the system fails to +* execute the scheduler's workqueue two times between submitting two +* jobs and this wait expires, but this is so unlikely that we opt for a +* timeout which does not make the test excessively slow. +*/ + done =drm_mock_sched_job_wait_scheduled (job[1 ], timeout);KUNIT_ASSERT_FALSE (test, done); +/* +* Advance the timeline and make sure the second job gets scheduled and +* completed. +*/ i =drm_mock_sched_advance (sched,1 );KUNIT_ASSERT_EQ (test, i,1 ); - done =drm_mock_sched_job_wait_scheduled (job[1 ],HZ ); + done =drm_mock_sched_job_wait_scheduled (job[1 ], timeout);KUNIT_ASSERT_TRUE (test, done); i =drm_mock_sched_advance (sched,1 );KUNIT_ASSERT_EQ (test, i,1 ); - done =drm_mock_sched_job_wait_finished (job[1 ],HZ ); + done =drm_mock_sched_job_wait_finished (job[1 ], timeout);KUNIT_ASSERT_TRUE (test, done);drm_mock_sched_entity_free (entity);
@@ -546,7 +558,7 @@ static void drm_sched_test_credits(struct kunit *test) }static struct kunit_case drm_sched_credits_tests[] = { -KUNIT_CASE_SLOW (drm_sched_test_credits), +KUNIT_CASE (drm_sched_test_credits), {} };
Signature · 1 line
2.52.0
(Cc: Matt, Christian)
Please send scheduler patches to all scheduler maintainers (and reviewers).
Quoted 1 line · Tvrtko Ursulin
Some tests are on right on the limit of targetting a one second runtime,
s/targetting/targeting/
Quoted 9 lines
and some of those have recently been correctly marked as slow. Lets instead make them a bit quicker, by either reducing the amount of submitted jobs or waiting a bit less. For the latter a comment is added to explain why that should be fine, and for the former, they are tests which aim to hit races via stress testing, so reducing the runtime is also fine since the main thing is the number of test runs over time and machines.
Signed-off-by Tvrtko Ursulin <[email protected]>Reported-by Maxime Ripard <[email protected]>
Should be followed by Closes:, but since the other patch resolved the issue already by flagging the tests, I think this should just be dropped.
drivers/gpu/drm/scheduler/tests/tests_basic.c static void drm_sched_test_credits(struct kunit *test) · line 543
Quoted 4 lines
drivers/gpu/drm/scheduler/tests/tests_basic.c +4
-0+/* +* Advance the timeline and make sure the second job gets scheduled and +* completed. +*/
A bit unrelated to the patch, and I'm also not sure it adds much value, let's drop the comment.
With that,
PATCH v2 1/1 drm/sched: Speed up some unit tests
In reply to Tvrtko UrsulinSome tests are on right on the limit of targetting a one second runtime, and some of those have recently been correctly marked as slow. Lets instead make them a bit quicker, by either reducing the amount of submitted jobs or waiting a bit less. For the latter a comment is added to explain why that should be fine, and for the former, they are tests which aim to hit races via stress testing, so reducing the runtime is also fine since the main thing is the number of test runs over time and machines.
---
v2:
* Downgraded Reported-by: to Cc:
* Dropped one test comment.
--- drivers/gpu/drm/scheduler/tests/tests_basic.c | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/gpu/drm/scheduler/tests/tests_basic.c +16 -8
@@ -382,7 +382,7 @@ static void drm_sched_change_priority(struct kunit *test)struct drm_mock_sched_entity *entity[DRM_SCHED_PRIORITY_COUNT ];struct drm_mock_scheduler *sched = test->priv;struct drm_mock_sched_job *job; -const unsigned int qd =1000 ; +const unsigned int qd =500 ;unsigned int i, cur_ent =0 ;enum drm_sched_priority p;
@@ -421,7 +421,7 @@ static void drm_sched_change_priority(struct kunit *test)static struct kunit_case drm_sched_priority_tests[] = {KUNIT_CASE (drm_sched_priorities), -KUNIT_CASE_SLOW (drm_sched_change_priority), +KUNIT_CASE (drm_sched_change_priority), {} };
@@ -438,7 +438,7 @@ static void drm_sched_test_modify_sched(struct kunit *test)struct drm_mock_sched_entity *entity[13 ];struct drm_mock_scheduler *sched[3 ];struct drm_mock_sched_job *job; -const unsigned int qd =1000 ; +const unsigned int qd =500 ;/* * Submit a bunch of jobs against entities configured with different
@@ -500,6 +500,7 @@ static struct kunit_suite drm_sched_modify_sched = {static void drm_sched_test_credits (struct kunit *test) { +const long timeout =msecs_to_jiffies (200 );struct drm_mock_sched_entity *entity;struct drm_mock_scheduler *sched;struct drm_mock_sched_job *job[2 ];
@@ -523,22 +524,29 @@ static void drm_sched_test_credits(struct kunit *test)drm_mock_sched_job_submit (job[0 ]);drm_mock_sched_job_submit (job[1 ]); - done =drm_mock_sched_job_wait_scheduled (job[0 ],HZ ); + done =drm_mock_sched_job_wait_scheduled (job[0 ], timeout);KUNIT_ASSERT_TRUE (test, done); - done =drm_mock_sched_job_wait_scheduled (job[1 ],HZ ); +/* +* Verify that the scheduler has not consumed more than the configured +* single credit. This can false negative if the system fails to +* execute the scheduler's workqueue two times between submitting two +* jobs and this wait expires, but this is so unlikely that we opt for a +* timeout which does not make the test excessively slow. +*/ + done =drm_mock_sched_job_wait_scheduled (job[1 ], timeout);KUNIT_ASSERT_FALSE (test, done); i =drm_mock_sched_advance (sched,1 );KUNIT_ASSERT_EQ (test, i,1 ); - done =drm_mock_sched_job_wait_scheduled (job[1 ],HZ ); + done =drm_mock_sched_job_wait_scheduled (job[1 ], timeout);KUNIT_ASSERT_TRUE (test, done); i =drm_mock_sched_advance (sched,1 );KUNIT_ASSERT_EQ (test, i,1 ); - done =drm_mock_sched_job_wait_finished (job[1 ],HZ ); + done =drm_mock_sched_job_wait_finished (job[1 ], timeout);KUNIT_ASSERT_TRUE (test, done);drm_mock_sched_entity_free (entity);
@@ -546,7 +554,7 @@ static void drm_sched_test_credits(struct kunit *test) }static struct kunit_case drm_sched_credits_tests[] = { -KUNIT_CASE_SLOW (drm_sched_test_credits), +KUNIT_CASE (drm_sched_test_credits), {} };
Signature · 1 line
2.52.0