sched/fair: remove next_buddy_marked
PATCH 1/1 sched/fair: remove next_buddy_marked
Remove unused next_buddy_marked in check_preempt_wakeup_fair
--- kernel/sched/fair.c | 2 -- 1 file changed, 2 deletions(-)
kernel/sched/fair.c +0 -2
@@ -8210,7 +8210,6 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, intstruct task_struct *curr = rq->curr;struct sched_entity *se = &curr->se, *pse = &p->se;struct cfs_rq *cfs_rq =task_cfs_rq (curr); -int next_buddy_marked =0 ;int cse_is_idle, pse_is_idle;if (unlikely (se == pse))
@@ -8227,7 +8226,6 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, intif (sched_feat (NEXT_BUDDY ) && !(wake_flags &WF_FORK )) {set_next_buddy (pse); - next_buddy_marked =1 ; }/*
Signature · 1 line
2.40.0
Quoted 3 lines · Wang Jinchao
Remove unused
next_buddy_markedincheck_preempt_wakeup_fair
Quoted 1 line
Signed-off-by Wang Jinchao <[email protected]>
Quoted 27 lines
--- kernel/sched/fair.c | 2 -- 1 file changed, 2 deletions(-)kernel/sched/fair.c +0
-3@@ -8210,7 +8210,6 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, intstruct task_struct *curr = rq->curr;struct sched_entity *se = &curr->se, *pse = &p->se;struct cfs_rq *cfs_rq =task_cfs_rq (curr); -int next_buddy_marked =0 ;int cse_is_idle, pse_is_idle;if (unlikely (se == pse))@@ -8227,7 +8226,6 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, intif (sched_feat (NEXT_BUDDY ) && !(wake_flags &WF_FORK )) {set_next_buddy (pse); - next_buddy_marked =1 ; }/* -- 2.40.0
On 12/14/23 4:18 PM, Vincent Guittot Wrote:
Quoted 6 lines · Wang Jinchao
Quoted 3 lines
Remove unused
next_buddy_markedincheck_preempt_wakeup_fairFixes 5e963f2bd465 ("sched/fair: Commit to EEVDF")
After this commit @pse preempts curr without being the NEXT_BUDDY, but IMHO it should be, so how about this?
@@ -8259,8 +8259,11 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
/*
* XXX pick_eevdf(cfs_rq) != se ?
*/
- if (pick_eevdf(cfs_rq) == pse)
+ if (pick_eevdf(cfs_rq) == pse) {
+ if (!next_buddy_marked)
+ set_next_buddy(pse);
goto preempt;+ }
return;
which will align with before.
Quoted 24 lines · Abel Wu
On 12/14/23 4:18 PM, Vincent Guittot Wrote:
Quoted 6 lines · Wang Jinchao
Quoted 3 lines
Remove unused
next_buddy_markedincheck_preempt_wakeup_fairFixes 5e963f2bd465 ("sched/fair: Commit to EEVDF")After this commit @pse preempts curr without being the
NEXT_BUDDY, but IMHO it should be, so how about this?(quoted diff) +4
-1@@ -8259,8 +8259,11 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int /* * XXX pick_eevdf(cfs_rq) != se ? */ - if (pick_eevdf(cfs_rq) == pse) + if (pick_eevdf(cfs_rq) == pse) { + if (!next_buddy_marked) + set_next_buddy(pse); goto preempt; + } return;
Quoted 1 line
which will align with before.
Seizing this opportunity to inquire about a question:
What does "buddy" mean in the context of the scheduler?
Is the effect the same between
preempting after pick_evfd(cfs_rq) == pse
and
preempting after set_next_buddy(pse) followed by pick_evfd(cfs_rq) == pse?Would both scenarios result in pse becoming the next scheduled se?"
On 12/14/23 9:02 PM, Wang Jinchao Wrote:
Quoted 23 lines · Abel Wu
Quoted 22 lines
On 12/14/23 4:18 PM, Vincent Guittot Wrote:
Quoted 6 lines · Wang Jinchao
Quoted 3 lines
Remove unused
next_buddy_markedincheck_preempt_wakeup_fairFixes 5e963f2bd465 ("sched/fair: Commit to EEVDF")After this commit @pse preempts curr without being the
NEXT_BUDDY, but IMHO it should be, so how about this?(quoted diff) +4
-1@@ -8259,8 +8259,11 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int /* * XXX pick_eevdf(cfs_rq) != se ? */ - if (pick_eevdf(cfs_rq) == pse) + if (pick_eevdf(cfs_rq) == pse) { + if (!next_buddy_marked) + set_next_buddy(pse); goto preempt; + }
Quoted 5 lines
Quoted 3 lines
(quoted diff) +0
-0return;which will align with before.
Seizing this opportunity to inquire about a question:
What does "buddy" mean in the context of the scheduler?
struct sched_entity
Quoted 6 lines
Is the effect the same between
preempting after pick_evfd(cfs_rq) == pse and preempting after set_next_buddy(pse) followed by pick_evfd(cfs_rq) == pse?Would both scenarios result in pse becoming the next scheduled se?"
Probably, since pse is the one preempts curr, pick_next_entity() could return pse directly without walking the rbtree. So the difference is in performance.
Vincent Guittot
maintainerQuoted 13 lines · Abel Wu
On 12/14/23 4:18 PM, Vincent Guittot Wrote:
Quoted 6 lines · Wang Jinchao
Quoted 3 lines
Remove unused
next_buddy_markedincheck_preempt_wakeup_fairFixes 5e963f2bd465 ("sched/fair: Commit to EEVDF")After this commit @pse preempts curr without being the
NEXT_BUDDY, but IMHO it should be, so how about this?
Review static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int · line 8264
Quoted 7 lines
(quoted diff) +3
-1@@ -8259,8 +8259,11 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int /* * XXX pick_eevdf(cfs_rq) != se ? */ - if (pick_eevdf(cfs_rq) == pse) + if (pick_eevdf(cfs_rq) == pse) { + if (!next_buddy_marked) + set_next_buddy(pse);
I don't think this is needed because :
- NEXT_BUDDY is false by default so pick_next_entity() will not take care of this
- pick_next_entity() will call pick_eevdf() which should return pse unless another se that want to run 1st, wakes up in the meantime and we should probably not take into account next buddy in this case
Quoted 6 lines
(quoted diff) +1
-0goto preempt; + } return;which will align with before.
[tip: sched/core] sched/fair: Remove unused 'next_buddy_marked' local variable in check_preempt_wakeup_fair()
In reply to Wang JinchaoThe following commit has been merged into the sched/core branch of tip:
The following commit has been merged into the sched/core branch of tip:
Commit-ID: fbb66ce0b1d670c72def736a13ac9176b860df4e Gitweb: https://git.kernel.org/tip/fbb66ce0b1d670c72def736a13ac9176b860df4e Author: Wang Jinchao <[email protected]> AuthorDate: Thu, 14 Dec 2023 13:20:29 +08:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Sat, 23 Dec 2023 16:12:21 +01:00
sched/fair: Remove unused 'next_buddy_marked' local variable in check_preempt_wakeup_fair()
This variable became unused in:
5e963f2bd465 ("sched/fair: Commit to EEVDF")--- kernel/sched/fair.c | 2 -- 1 file changed, 2 deletions(-)
kernel/sched/fair.c +0 -2
@@ -8221,7 +8221,6 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, intstruct task_struct *curr = rq->curr;struct sched_entity *se = &curr->se, *pse = &p->se;struct cfs_rq *cfs_rq =task_cfs_rq (curr); -int next_buddy_marked =0 ;int cse_is_idle, pse_is_idle;if (unlikely (se == pse))
@@ -8238,7 +8237,6 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, intif (sched_feat (NEXT_BUDDY ) && !(wake_flags &WF_FORK )) {set_next_buddy (pse); - next_buddy_marked =1 ; }/*