sched: don't check rq after newidle_balance return positive
PATCH 1/1 sched: don't check rq after newidle_balance return positive
From: Chen Xiaoguang <[email protected]>
In pick_next_task_fair, if CPU is going to idle newidle_balance is called first trying to pull some tasks.
When newidle_balance returns positive which means it does pulls tasks or some tasks enqueued then there is no need to check sched_fair_runnable again.
--- kernel/sched/fair.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/sched/fair.c +1 -2
@@ -7004,10 +7004,9 @@ struct task_struct *struct task_struct *p;int new_tasks; -again:if (!sched_fair_runnable (rq)) goto idle; - +again:#ifdef CONFIG_FAIR_GROUP_SCHED if (!prev || prev->sched_class != &fair_sched_class) goto simple;
Signature · 1 line
1.8.3.1
Peter Zijlstra
maintainerQuoted 7 lines · On Tue, Dec 15, 2020 at 02:48:50PM +0800, [email protected] wrote:
From: Chen Xiaoguang <[email protected]>
In
pick_next_task_fair, if CPU is going to idlenewidle_balanceis called first trying to pull some tasks.
Whennewidle_balancereturns positive which means it does pulls tasks or some tasks enqueued then there is no need to checksched_fair_runnableagain.
No, I think it actually does need to, because while it counts the number of tasks it pulled, it doesn't verify it still has them after it re-acquires rq->lock. That is, someone could've come along and stolen them right from under our noses.
Quoted 3 lines
Signed-off-by He Chen <[email protected]>Signed-off-by Xiaoguang Chen <[email protected]>
This SoB chain is broken. The first SoB should be the author, but From does not match.
答复: [PATCH] sched: don't check rq after newidle_balance return positive(Internet mail)
-----邮件原件-----
发件人: Peter Zijlstra <[email protected]>
发送时间: 2020年12月15日 16:33
收件人: [email protected]
抄送: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; heddchen(陈贺) <[email protected]>; xiaoggchen(陈小光) <[email protected]> 主题: Re: [PATCH] sched: don't check rq after newidle_balance return positive(Internet mail)
Quoted 10 lines · On Tue, Dec 15, 2020 at 02:48:50PM +0800, [email protected] wrote:
Quoted 7 lines
From: Chen Xiaoguang <[email protected]>
In
pick_next_task_fair, if CPU is going to idlenewidle_balanceis called first trying to pull some tasks.
Whennewidle_balancereturns positive which means it does pulls tasks or some tasks enqueued then there is no need to checksched_fair_runnableagain.No, I think it actually does need to, because while it counts the number of tasks it pulled, it doesn't verify it still has them after it re-acquires
rq->lock. That is, someone could've come along and stolen them right from under our noses.
Ah, yes, our change only make sense when pulling nothing in load_balance but some tasks enqueued this rq during the lock of this rq is released.
Thanks.
Quoted 5 lines
Quoted 3 lines
Signed-off-by He Chen <[email protected]>Signed-off-by Xiaoguang Chen <[email protected]>This SoB chain is broken. The first SoB should be the author, but From does not match.
We will fix this next time.