mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-12 04:15:21 +02:00
sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy
[ Upstream commitfaa42d2941
] Consider the following cgroup: root | ------------------------ | | normal_cgroup idle_cgroup | | SCHED_IDLE task_A SCHED_NORMAL task_B According to the cgroup hierarchy, A should preempt B. But current check_preempt_wakeup_fair() treats cgroup se and task separately, so B will preempt A unexpectedly. Unify the wakeup logic by {c,p}se_is_idle only. This makes SCHED_IDLE of a task a relative policy that is effective only within its own cgroup, similar to the behavior of NICE. Also fix se_is_idle() definition when !CONFIG_FAIR_GROUP_SCHED. Fixes:304000390f
("sched: Cgroup SCHED_IDLE support") Signed-off-by: Tianchen Ding <dtcccc@linux.alibaba.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Josh Don <joshdon@google.com> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org> Link: https://lkml.kernel.org/r/20240626023505.1332596-1-dtcccc@linux.alibaba.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
82478cb8a2
commit
5a4f8de92d
|
@ -533,7 +533,7 @@ static int cfs_rq_is_idle(struct cfs_rq *cfs_rq)
|
||||||
|
|
||||||
static int se_is_idle(struct sched_entity *se)
|
static int se_is_idle(struct sched_entity *se)
|
||||||
{
|
{
|
||||||
return 0;
|
return task_has_idle_policy(task_of(se));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_FAIR_GROUP_SCHED */
|
#endif /* CONFIG_FAIR_GROUP_SCHED */
|
||||||
|
@ -8209,16 +8209,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
|
||||||
if (test_tsk_need_resched(curr))
|
if (test_tsk_need_resched(curr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Idle tasks are by definition preempted by non-idle tasks. */
|
if (!sched_feat(WAKEUP_PREEMPTION))
|
||||||
if (unlikely(task_has_idle_policy(curr)) &&
|
|
||||||
likely(!task_has_idle_policy(p)))
|
|
||||||
goto preempt;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Batch and idle tasks do not preempt non-idle tasks (their preemption
|
|
||||||
* is driven by the tick):
|
|
||||||
*/
|
|
||||||
if (unlikely(p->policy != SCHED_NORMAL) || !sched_feat(WAKEUP_PREEMPTION))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
find_matching_se(&se, &pse);
|
find_matching_se(&se, &pse);
|
||||||
|
@ -8228,7 +8219,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
|
||||||
pse_is_idle = se_is_idle(pse);
|
pse_is_idle = se_is_idle(pse);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Preempt an idle group in favor of a non-idle group (and don't preempt
|
* Preempt an idle entity in favor of a non-idle entity (and don't preempt
|
||||||
* in the inverse case).
|
* in the inverse case).
|
||||||
*/
|
*/
|
||||||
if (cse_is_idle && !pse_is_idle)
|
if (cse_is_idle && !pse_is_idle)
|
||||||
|
@ -8236,9 +8227,14 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
|
||||||
if (cse_is_idle != pse_is_idle)
|
if (cse_is_idle != pse_is_idle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BATCH and IDLE tasks do not preempt others.
|
||||||
|
*/
|
||||||
|
if (unlikely(p->policy != SCHED_NORMAL))
|
||||||
|
return;
|
||||||
|
|
||||||
cfs_rq = cfs_rq_of(se);
|
cfs_rq = cfs_rq_of(se);
|
||||||
update_curr(cfs_rq);
|
update_curr(cfs_rq);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX pick_eevdf(cfs_rq) != se ?
|
* XXX pick_eevdf(cfs_rq) != se ?
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user