The commit 6bc912b71b6f ("sched: SCHED_OTHER vs SCHED_IDLE isolation")
defines the behavior of SCHED_IDLE as following:
- no SCHED_IDLE buddies
- never let SCHED_IDLE preempt on wakeup
- always preempt SCHED_IDLE on wakeup
- limit SLEEPER fairness for SCHED_IDLE
and the 3rd rule is broken if !WAKEUP_PREEMPTION due to recently merged
commit faa42d29419d ("sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy")
Although WAKEUP_PREEMPTION is mainly there for debug purpose to provide
a way to check whether a performance degrade of certain workload is due
to overscheduling or not, it is still kind of weird that we treat sched-
idle cpus as idle but don't let the non-idle tasks preempt the sched-idle
cpus in debug mode (!WAKEUP_PREEMPTION).
Fix it by strictly following the aforementioned rules.
Fixes: faa42d29419d ("sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy")
Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
---
kernel/sched/fair.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index aaa9822e9562..a7eeb72d57aa 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8785,9 +8785,6 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
if (test_tsk_need_resched(rq->curr))
return;
- if (!sched_feat(WAKEUP_PREEMPTION))
- return;
-
find_matching_se(&se, &pse);
WARN_ON_ONCE(!pse);
@@ -8806,6 +8803,9 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
goto preempt;
}
+ if (!sched_feat(WAKEUP_PREEMPTION))
+ return;
+
/*
* IDLE entities do not preempt others.
*/
--
2.37.3
On Thu, 27 Feb 2025 at 09:58, Abel Wu <wuyun.abel@bytedance.com> wrote:
>
> The commit 6bc912b71b6f ("sched: SCHED_OTHER vs SCHED_IDLE isolation")
> defines the behavior of SCHED_IDLE as following:
>
> - no SCHED_IDLE buddies
> - never let SCHED_IDLE preempt on wakeup
> - always preempt SCHED_IDLE on wakeup
> - limit SLEEPER fairness for SCHED_IDLE
>
> and the 3rd rule is broken if !WAKEUP_PREEMPTION due to recently merged
> commit faa42d29419d ("sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy")
>
> Although WAKEUP_PREEMPTION is mainly there for debug purpose to provide
> a way to check whether a performance degrade of certain workload is due
> to overscheduling or not, it is still kind of weird that we treat sched-
> idle cpus as idle but don't let the non-idle tasks preempt the sched-idle
> cpus in debug mode (!WAKEUP_PREEMPTION).
>
> Fix it by strictly following the aforementioned rules.
>
> Fixes: faa42d29419d ("sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy")
> Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
WAKEUP_PREEMPTION seems to be still used so
Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> kernel/sched/fair.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index aaa9822e9562..a7eeb72d57aa 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8785,9 +8785,6 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
> if (test_tsk_need_resched(rq->curr))
> return;
>
> - if (!sched_feat(WAKEUP_PREEMPTION))
> - return;
> -
> find_matching_se(&se, &pse);
> WARN_ON_ONCE(!pse);
>
> @@ -8806,6 +8803,9 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
> goto preempt;
> }
>
> + if (!sched_feat(WAKEUP_PREEMPTION))
> + return;
> +
> /*
> * IDLE entities do not preempt others.
> */
> --
> 2.37.3
>
On 2/28/25 10:26 PM, Vincent Guittot wrote:
> On Thu, 27 Feb 2025 at 09:58, Abel Wu <wuyun.abel@bytedance.com> wrote:
>>
>> The commit 6bc912b71b6f ("sched: SCHED_OTHER vs SCHED_IDLE isolation")
>> defines the behavior of SCHED_IDLE as following:
>>
>> - no SCHED_IDLE buddies
>> - never let SCHED_IDLE preempt on wakeup
>> - always preempt SCHED_IDLE on wakeup
>> - limit SLEEPER fairness for SCHED_IDLE
>>
>> and the 3rd rule is broken if !WAKEUP_PREEMPTION due to recently merged
>> commit faa42d29419d ("sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy")
>>
>> Although WAKEUP_PREEMPTION is mainly there for debug purpose to provide
>> a way to check whether a performance degrade of certain workload is due
>> to overscheduling or not, it is still kind of weird that we treat sched-
>> idle cpus as idle but don't let the non-idle tasks preempt the sched-idle
>> cpus in debug mode (!WAKEUP_PREEMPTION).
>>
>> Fix it by strictly following the aforementioned rules.
>>
>> Fixes: faa42d29419d ("sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy")
>> Signed-off-by: Abel Wu <wuyun.abel@bytedance.com>
>
> WAKEUP_PREEMPTION seems to be still used so
>
> Acked-by: Vincent Guittot <vincent.guittot@linaro.org>
Thanks!
© 2016 - 2025 Red Hat, Inc.