Skip to content

Commit dae4320

Browse files
author
Peter Zijlstra
committed
sched: Fixup set_next_task() implementations
The rule is that: pick_next_task() := pick_task() + set_next_task(.first = true) Turns out, there's still a few things in pick_next_task() that are missing from that combination. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7d2180d commit dae4320

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

kernel/sched/deadline.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,6 +2386,9 @@ static void set_next_task_dl(struct rq *rq, struct task_struct *p, bool first)
23862386
update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 0);
23872387

23882388
deadline_queue_push_tasks(rq);
2389+
2390+
if (hrtick_enabled(rq))
2391+
start_hrtick_dl(rq, &p->dl);
23892392
}
23902393

23912394
static struct sched_dl_entity *pick_next_dl_entity(struct dl_rq *dl_rq)
@@ -2452,9 +2455,6 @@ static struct task_struct *pick_next_task_dl(struct rq *rq)
24522455
if (!p->dl_server)
24532456
set_next_task_dl(rq, p, true);
24542457

2455-
if (hrtick_enabled(rq))
2456-
start_hrtick_dl(rq, &p->dl);
2457-
24582458
return p;
24592459
}
24602460

kernel/sched/fair.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8760,6 +8760,9 @@ static struct task_struct *pick_task_fair(struct rq *rq)
87608760
return task_of(se);
87618761
}
87628762

8763+
static void __set_next_task_fair(struct rq *rq, struct task_struct *p, bool first);
8764+
static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first);
8765+
87638766
struct task_struct *
87648767
pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
87658768
{
@@ -8808,33 +8811,17 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
88088811

88098812
put_prev_entity(cfs_rq, pse);
88108813
set_next_entity(cfs_rq, se);
8814+
8815+
__set_next_task_fair(rq, p, true);
88118816
}
88128817

8813-
goto done;
8818+
return p;
8819+
88148820
simple:
88158821
#endif
88168822
if (prev)
88178823
put_prev_task(rq, prev);
8818-
8819-
for_each_sched_entity(se)
8820-
set_next_entity(cfs_rq_of(se), se);
8821-
8822-
done: __maybe_unused;
8823-
#ifdef CONFIG_SMP
8824-
/*
8825-
* Move the next running task to the front of
8826-
* the list, so our cfs_tasks list becomes MRU
8827-
* one.
8828-
*/
8829-
list_move(&p->se.group_node, &rq->cfs_tasks);
8830-
#endif
8831-
8832-
if (hrtick_enabled_fair(rq))
8833-
hrtick_start_fair(rq, p);
8834-
8835-
update_misfit_status(p, rq);
8836-
sched_fair_update_stop_tick(rq, p);
8837-
8824+
set_next_task_fair(rq, p, true);
88388825
return p;
88398826

88408827
idle:
@@ -13145,12 +13132,7 @@ static void switched_to_fair(struct rq *rq, struct task_struct *p)
1314513132
}
1314613133
}
1314713134

13148-
/* Account for a task changing its policy or group.
13149-
*
13150-
* This routine is mostly called to set cfs_rq->curr field when a task
13151-
* migrates between groups/classes.
13152-
*/
13153-
static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first)
13135+
static void __set_next_task_fair(struct rq *rq, struct task_struct *p, bool first)
1315413136
{
1315513137
struct sched_entity *se = &p->se;
1315613138

@@ -13163,6 +13145,27 @@ static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first)
1316313145
list_move(&se->group_node, &rq->cfs_tasks);
1316413146
}
1316513147
#endif
13148+
if (!first)
13149+
return;
13150+
13151+
SCHED_WARN_ON(se->sched_delayed);
13152+
13153+
if (hrtick_enabled_fair(rq))
13154+
hrtick_start_fair(rq, p);
13155+
13156+
update_misfit_status(p, rq);
13157+
sched_fair_update_stop_tick(rq, p);
13158+
}
13159+
13160+
/*
13161+
* Account for a task changing its policy or group.
13162+
*
13163+
* This routine is mostly called to set cfs_rq->curr field when a task
13164+
* migrates between groups/classes.
13165+
*/
13166+
static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first)
13167+
{
13168+
struct sched_entity *se = &p->se;
1316613169

1316713170
for_each_sched_entity(se) {
1316813171
struct cfs_rq *cfs_rq = cfs_rq_of(se);
@@ -13172,10 +13175,7 @@ static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first)
1317213175
account_cfs_rq_runtime(cfs_rq, 0);
1317313176
}
1317413177

13175-
if (!first)
13176-
return;
13177-
13178-
SCHED_WARN_ON(se->sched_delayed);
13178+
__set_next_task_fair(rq, p, first);
1317913179
}
1318013180

1318113181
void init_cfs_rq(struct cfs_rq *cfs_rq)

0 commit comments

Comments
 (0)