mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
sched/fair: Add newidle balance to pick_task_fair()
With commit 50653216e4 ("sched: Add support to pick functions to
take rf") removing the balance callback, the pick_task() callback is
in charge of newidle balancing.
This means pick_task_fair() should do so too. This hasn't been a
problem in practise because pick_next_task_fair() is used. However,
since we'll be removing that one shortly, make sure pick_next_task()
is up to scratch.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://patch.msgid.link/20260511120627.944705718@infradead.org
This commit is contained in:
parent
e05777c44e
commit
b3a2dfa8b4
|
|
@ -9863,16 +9863,18 @@ static void wakeup_preempt_fair(struct rq *rq, struct task_struct *p, int wake_f
|
|||
}
|
||||
|
||||
static struct task_struct *pick_task_fair(struct rq *rq, struct rq_flags *rf)
|
||||
__must_hold(__rq_lockp(rq))
|
||||
{
|
||||
struct sched_entity *se;
|
||||
struct cfs_rq *cfs_rq;
|
||||
struct task_struct *p;
|
||||
bool throttled;
|
||||
int new_tasks;
|
||||
|
||||
again:
|
||||
cfs_rq = &rq->cfs;
|
||||
if (!cfs_rq->nr_queued)
|
||||
return NULL;
|
||||
goto idle;
|
||||
|
||||
throttled = false;
|
||||
|
||||
|
|
@ -9893,6 +9895,14 @@ static struct task_struct *pick_task_fair(struct rq *rq, struct rq_flags *rf)
|
|||
if (unlikely(throttled))
|
||||
task_throttle_setup_work(p);
|
||||
return p;
|
||||
|
||||
idle:
|
||||
new_tasks = sched_balance_newidle(rq, rf);
|
||||
if (new_tasks < 0)
|
||||
return RETRY_TASK;
|
||||
if (new_tasks > 0)
|
||||
goto again;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void __set_next_task_fair(struct rq *rq, struct task_struct *p, bool first);
|
||||
|
|
@ -9904,12 +9914,12 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
|
|||
{
|
||||
struct sched_entity *se;
|
||||
struct task_struct *p;
|
||||
int new_tasks;
|
||||
|
||||
again:
|
||||
p = pick_task_fair(rq, rf);
|
||||
if (unlikely(p == RETRY_TASK))
|
||||
return p;
|
||||
if (!p)
|
||||
goto idle;
|
||||
return p;
|
||||
se = &p->se;
|
||||
|
||||
#ifdef CONFIG_FAIR_GROUP_SCHED
|
||||
|
|
@ -9959,29 +9969,11 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
|
|||
#endif /* CONFIG_FAIR_GROUP_SCHED */
|
||||
put_prev_set_next_task(rq, prev, p);
|
||||
return p;
|
||||
|
||||
idle:
|
||||
if (rf) {
|
||||
new_tasks = sched_balance_newidle(rq, rf);
|
||||
|
||||
/*
|
||||
* Because sched_balance_newidle() releases (and re-acquires)
|
||||
* rq->lock, it is possible for any higher priority task to
|
||||
* appear. In that case we must re-start the pick_next_entity()
|
||||
* loop.
|
||||
*/
|
||||
if (new_tasks < 0)
|
||||
return RETRY_TASK;
|
||||
|
||||
if (new_tasks > 0)
|
||||
goto again;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct task_struct *
|
||||
fair_server_pick_task(struct sched_dl_entity *dl_se, struct rq_flags *rf)
|
||||
__must_hold(__rq_lockp(dl_se->rq))
|
||||
{
|
||||
return pick_task_fair(dl_se->rq, rf);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user