Re: [PATCH] sched/core: Fix the bug that sched_core_find() may return throttled task

From: cruzzhao
Date: Thu Sep 01 2022 - 05:59:21 EST




在 2022/9/1 下午5:02, Peter Zijlstra 写道:
> On Wed, Aug 31, 2022 at 02:49:18PM +0800, Cruz Zhao wrote:
>> When a cfs_rq is throttled, the cookie'd task in this cfs_rq wouldn't
>> dequeue from the core tree, and sched_core_find() may return this task,
>> which will result that the throttled task running on the cpu.
>>
>> To resolve this problem, we pick the first cookie matched task and
>> unthrottled task.
>
> You mean: first that that both matches the cookie and is not throttled.
>

Yeah, I mean "the first cookie matched and not throttled task".

> Except I think you can have the same problem with the RT crud.

Sure, there's the same problem with the RT crud.

There's also a problem that the priority of the tasks in the core_tree
won't change since sched_core_enqueue(), but the priority of cfs tasks
will change as vruntime changes. And sched_core_find() may not pick the
cookie matched task with the highest priority.

I tried to combine the core_tree with cfs_rq (dl_rq, rt_rq should also
be considered) to solve this problem, but I haven't come up with a
simple and graceful solution yet.