* [PATCH -tip] sched/fair: gracefully handle EEVDF scheduling failures
@ 2023-12-08 11:20 Tiwei Bie
2023-12-08 14:32 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Tiwei Bie @ 2023-12-08 11:20 UTC (permalink / raw)
To: peterz, mingo, wuyun.abel
Cc: Tiwei Bie, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
Steven Rostedt, Ben Segall, Mel Gorman,
Daniel Bristot de Oliveira, Valentin Schneider, linux-kernel
The EEVDF scheduling might fail due to unforeseen issues. Previously,
it handled such situations gracefully, which was helpful in identifying
problems, but it no longer does so. Therefore, it would be better to
restore its previous capability.
Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
---
kernel/sched/fair.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bcea3d55d95d..1b83b3a8e630 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -878,7 +878,7 @@ struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
{
struct rb_node *node = cfs_rq->tasks_timeline.rb_root.rb_node;
- struct sched_entity *se = __pick_first_entity(cfs_rq);
+ struct sched_entity *first = __pick_first_entity(cfs_rq);
struct sched_entity *curr = cfs_rq->curr;
struct sched_entity *best = NULL;
@@ -887,7 +887,7 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
* in this cfs_rq, saving some cycles.
*/
if (cfs_rq->nr_running == 1)
- return curr && curr->on_rq ? curr : se;
+ return curr && curr->on_rq ? curr : first;
if (curr && (!curr->on_rq || !entity_eligible(cfs_rq, curr)))
curr = NULL;
@@ -900,14 +900,15 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
return curr;
/* Pick the leftmost entity if it's eligible */
- if (se && entity_eligible(cfs_rq, se)) {
- best = se;
+ if (first && entity_eligible(cfs_rq, first)) {
+ best = first;
goto found;
}
/* Heap search for the EEVD entity */
while (node) {
struct rb_node *left = node->rb_left;
+ struct sched_entity *se;
/*
* Eligible entities in left subtree are always better
@@ -937,6 +938,9 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
if (!best || (curr && entity_before(curr, best)))
best = curr;
+ if (WARN_ONCE(!best, "EEVDF scheduling failed, picking leftmost\n"))
+ best = first;
+
return best;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -tip] sched/fair: gracefully handle EEVDF scheduling failures
2023-12-08 11:20 [PATCH -tip] sched/fair: gracefully handle EEVDF scheduling failures Tiwei Bie
@ 2023-12-08 14:32 ` Peter Zijlstra
2023-12-09 4:51 ` Tiwei Bie
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2023-12-08 14:32 UTC (permalink / raw)
To: Tiwei Bie
Cc: mingo, wuyun.abel, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
Steven Rostedt, Ben Segall, Mel Gorman,
Daniel Bristot de Oliveira, Valentin Schneider, linux-kernel
On Fri, Dec 08, 2023 at 07:20:59PM +0800, Tiwei Bie wrote:
> The EEVDF scheduling might fail due to unforeseen issues. Previously,
I might also fly if I jump up. But is there any actual reason to believe
something like that will happen?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -tip] sched/fair: gracefully handle EEVDF scheduling failures
2023-12-08 14:32 ` Peter Zijlstra
@ 2023-12-09 4:51 ` Tiwei Bie
0 siblings, 0 replies; 3+ messages in thread
From: Tiwei Bie @ 2023-12-09 4:51 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mingo, wuyun.abel, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
Steven Rostedt, Ben Segall, Mel Gorman,
Daniel Bristot de Oliveira, Valentin Schneider, linux-kernel
On 12/8/23 10:32 PM, Peter Zijlstra wrote:
> On Fri, Dec 08, 2023 at 07:20:59PM +0800, Tiwei Bie wrote:
>> The EEVDF scheduling might fail due to unforeseen issues. Previously,
>
> I might also fly if I jump up. But is there any actual reason to believe
> something like that will happen?
Thanks for the quick reply! Sorry, after re-reading the commit log,
it looks confusing to me as well. I didn't mean something like that
will happen. I just thought it might be worthwhile to have a sanity
check on 'best'. Because, the 'best' is initialized to NULL and is
conditionally updated. The added 'WARN_ONCE' on '!best' is more like
a 'default' case to catch an unreachable case in a 'switch' block.
There was a similar check in the past that was helpful. And there
seems to be no harm in doing it. If this is reasonable, I'd like to
submit a v2 patch.
PS. I just noticed that the subject line should start with a uppercase
letter according to the rules in the tip tree handbook [1]. The subject
line should be something like: "sched/fair: Sanity check best in pick_eevdf()".
[1] https://www.kernel.org/doc/html/next/process/maintainer-tip.html#patch-subject
Regards,
Tiwei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-09 5:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-08 11:20 [PATCH -tip] sched/fair: gracefully handle EEVDF scheduling failures Tiwei Bie
2023-12-08 14:32 ` Peter Zijlstra
2023-12-09 4:51 ` Tiwei Bie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox