Re: [PATCH] sched/deadline: Zero out positive runtime after throttling constrained tasks

From: Xunlei Pang
Date: Wed May 10 2017 - 21:37:32 EST


On 05/10/2017 at 09:36 PM, Steven Rostedt wrote:
> On Wed, 10 May 2017 21:03:37 +0800
> Xunlei Pang <xlpang@xxxxxxxxxx> wrote:
>
>> When a contrained task is throttled by dl_check_constrained_dl(),
>> it may carry the remaining positive runtime, as a result when
>> dl_task_timer() fires and calls replenish_dl_entity(), it will
>> not be replenished correctly due to the positive dl_se->runtime.
>>
>> This patch assigns its runtime to 0 if positive after throttling.
>>
>> Fixes: df8eac8cafce ("sched/deadline: Throttle a constrained deadline task activated after the deadline)
>> Cc: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
>> Signed-off-by: Xunlei Pang <xlpang@xxxxxxxxxx>
>> ---
>> kernel/sched/deadline.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
>> index a2ce590..d3d291e 100644
>> --- a/kernel/sched/deadline.c
>> +++ b/kernel/sched/deadline.c
>> @@ -723,6 +723,8 @@ static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se)
>> if (unlikely(dl_se->dl_boosted || !start_dl_timer(p)))
>> return;
>> dl_se->dl_throttled = 1;
>> + if (dl_se->runtime > 0)
>> + dl_se->runtime = 0;
> This makes sense to me, but should we have any accounting for runtime
> that was missed due to wakeups and such?

It sounds a good idea, will try to add that to "/proc/<pid>/sched".

Looks like we should also catch and handle the deadline miss in dl_runtime_exceeded(),
I guess we can add the accounting together.

Regards,
Xunlei