[PATCH 08/10] sched/fair: Do not check avg_idle to prematurely exit newly idle when LB_PROMOTE

Xin Zhao <[email protected]>
Newsgroups org.kernel.vger.linux-kernel
Message-ID <[email protected]>
When LB_PROMOTE is on, there are high real-time requirements, we should
avoid prematurely exiting in sched_balance_newidle() due to a short
avg_idle. This is because after any newly idle state, if no tasks are
found to run, there may be a long-term lack of new incoming tasks to wake
up on that CPU. Meanwhile, there may be tasks waiting to run on other
cores, leading to unreasonable CPU idleness. The definition of
unreasonable CPU idleness can be found in the commit-log of the previous
patch that introduced the LB_PROMOTE feature.

Signed-off-by: Xin Zhao <[email protected]>
---
 kernel/sched/fair.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d2b538abdf3e..8a1d2763a923 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -14694,7 +14694,7 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
 		goto out;
 
 	if (!get_rd_overloaded(this_rq->rd) ||
-	    this_rq->avg_idle < sd->max_newidle_lb_cost) {
+	    (!sched_feat(LB_PROMOTE) && this_rq->avg_idle < sd->max_newidle_lb_cost)) {
 
 		update_next_balance(sd, &next_balance);
 		goto out;
@@ -14716,7 +14716,8 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
 
 		update_next_balance(sd, &next_balance);
 
-		if (this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost)
+		if (!sched_feat(LB_PROMOTE) &&
+		    this_rq->avg_idle < curr_cost + sd->max_newidle_lb_cost)
 			break;
 
 		if (sd->flags & SD_BALANCE_NEWIDLE) {
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.