[PATCH 3/8] drm/sched: Reduce scheduler's timeout for timeout tests

Tvrtko Ursulin tvrtko.ursulin at igalia.com
Tue May 6 13:20:04 UTC 2025


On 06/05/2025 13:56, Maíra Canal wrote:
> Hi Tvrtko,
> 
> Thanks for your review!
> 
> On 06/05/25 09:03, Tvrtko Ursulin wrote:
>>
>> On 03/05/2025 21:59, Maíra Canal wrote:
>>> As more KUnit tests are introduced to evaluate the basic capabilities of
>>> the `timedout_job()` hook, the test suite will continue to increase in
>>> duration. To reduce the overall running time of the test suite, decrease
>>> the scheduler's timeout for the timeout tests.
>>>
>>> Before this commit:
>>>
>>> [15:42:26] Elapsed time: 15.637s total, 0.002s configuring, 10.387s 
>>> building, 5.229s running
>>>
>>> After this commit:
>>>
>>> [15:45:26] Elapsed time: 9.263s total, 0.002s configuring, 5.168s 
>>> building, 4.037s running
>>>
>>> Signed-off-by: Maíra Canal <mcanal at igalia.com>
>>> ---
>>>   drivers/gpu/drm/scheduler/tests/tests_basic.c | 10 ++++++----
>>>   1 file changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/scheduler/tests/tests_basic.c b/drivers/ 
>>> gpu/drm/scheduler/tests/tests_basic.c
>>> index 
>>> 8f960f0fd31d0af7873f410ceba2d636f58a5474..00c691cb3c306f609684f554f17fcb54ba74cb95 100644
>>> --- a/drivers/gpu/drm/scheduler/tests/tests_basic.c
>>> +++ b/drivers/gpu/drm/scheduler/tests/tests_basic.c
>>> @@ -5,6 +5,8 @@
>>>   #include "sched_tests.h"
>>> +#define MOCK_TIMEOUT (HZ / 5)
>>> +
>>>   /*
>>>    * DRM scheduler basic tests should check the basic functional 
>>> correctness of
>>>    * the scheduler, including some very light smoke testing. More 
>>> targeted tests,
>>> @@ -28,7 +30,7 @@ static void drm_sched_basic_exit(struct kunit *test)
>>>   static int drm_sched_timeout_init(struct kunit *test)
>>>   {
>>> -    test->priv = drm_mock_sched_new(test, HZ);
>>> +    test->priv = drm_mock_sched_new(test, MOCK_TIMEOUT);
>>>       return 0;
>>>   }
>>> @@ -224,17 +226,17 @@ static void drm_sched_basic_timeout(struct 
>>> kunit *test)
>>>       drm_mock_sched_job_submit(job);
>>> -    done = drm_mock_sched_job_wait_scheduled(job, HZ);
>>> +    done = drm_mock_sched_job_wait_scheduled(job, MOCK_TIMEOUT);
>>
>> This wait is accounting for the fact sched->wq needs to run and call - 
>>  >run_job() before job will become scheduled. It is not related to 
>> timeout handling. I was going for a safe value and I think decreasing 
>> it will not speed up the test but may cause sporadic failures.
> 
> I'll address it in v2.
> 
>>
>>>       KUNIT_ASSERT_TRUE(test, done);
>>> -    done = drm_mock_sched_job_wait_finished(job, HZ / 2);
>>> +    done = drm_mock_sched_job_wait_finished(job, MOCK_TIMEOUT / 2);
>>>       KUNIT_ASSERT_FALSE(test, done);
>>>       KUNIT_ASSERT_EQ(test,
>>>               job->flags & DRM_MOCK_SCHED_JOB_TIMEDOUT,
>>>               0);
>>> -    done = drm_mock_sched_job_wait_finished(job, HZ);
>>> +    done = drm_mock_sched_job_wait_finished(job, MOCK_TIMEOUT);
>>>       KUNIT_ASSERT_FALSE(test, done);
>>
>> Above two are related to timeout handling and should be safe to change.
>>
>> With HZ / 5 first assert could have a false negative if timeout work 
>> would run, but later than 100ms (HZ / 5 / 2). And the second a false 
>> negative if it fails to run in 300ms (HZ / 5 / 2 + HZ / 5). Neither 
>> failure sounds likely in the kunit environment so, again, I think 
>> those two are okay to speed up.
> 
> What do you think about using a slightly bigger timeout? Maybe HZ / 4 or
> HZ / 2.

I thought HZ / 5 would be safe so I'd leave it and only tweak if it 
turns out to be a problem.

Regards,

Tvrtko



More information about the etnaviv mailing list