All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/fair: Simplify continue_balancing for newidle
@ 2024-03-25 15:39 Shrikanth Hegde
  2024-03-26  8:07 ` Ingo Molnar
  2024-03-26 19:24 ` [tip: sched/core] sched/fair: Simplify the continue_balancing logic in sched_balance_newidle() tip-bot2 for Shrikanth Hegde
  0 siblings, 2 replies; 6+ messages in thread
From: Shrikanth Hegde @ 2024-03-25 15:39 UTC (permalink / raw)
  To: mingo, peterz, vincent.guittot
  Cc: sshegde, dietmar.eggemann, qyousef, linux-kernel, vschneid,
	joshdon, riel

newidle(CPU_NEWLY_IDLE) balancing doesn't stop the load balancing if the
continue_balancing flag is reset. Other two balancing (IDLE, BUSY) do
that. newidle balance stops the load balancing if rq has a task or there
is wakeup pending. The same checks are present in should_we_balance for
newidle. Hence use the return value and simplify continue_balancing
mechanism for newidle. Update the comment surrounding it as well.

No change in functionality intended.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 kernel/sched/fair.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f00cb66cc479..d80535df8f03 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12307,6 +12307,7 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
 {
 	unsigned long next_balance = jiffies + HZ;
 	int this_cpu = this_rq->cpu;
+	int continue_balancing = 1;
 	u64 t0, t1, curr_cost = 0;
 	struct sched_domain *sd;
 	int pulled_task = 0;
@@ -12321,8 +12322,9 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
 		return 0;

 	/*
-	 * We must set idle_stamp _before_ calling idle_balance(), such that we
-	 * measure the duration of idle_balance() as idle time.
+	 * We must set idle_stamp _before_ calling sched_balance_rq()
+	 * for CPU_NEWLY_IDLE, such that we measure the this duration
+	 * as idle time.
 	 */
 	this_rq->idle_stamp = rq_clock(this_rq);

@@ -12361,7 +12363,6 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)

 	rcu_read_lock();
 	for_each_domain(this_cpu, sd) {
-		int continue_balancing = 1;
 		u64 domain_cost;

 		update_next_balance(sd, &next_balance);
@@ -12387,8 +12388,7 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
 		 * Stop searching for tasks to pull if there are
 		 * now runnable tasks on this rq.
 		 */
-		if (pulled_task || this_rq->nr_running > 0 ||
-		    this_rq->ttwu_pending)
+		if (pulled_task || !continue_balancing)
 			break;
 	}
 	rcu_read_unlock();
--
2.39.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-26 19:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-25 15:39 [PATCH] sched/fair: Simplify continue_balancing for newidle Shrikanth Hegde
2024-03-26  8:07 ` Ingo Molnar
2024-03-26  9:00   ` Shrikanth Hegde
2024-03-26 15:11     ` Dietmar Eggemann
2024-03-26 19:15       ` Ingo Molnar
2024-03-26 19:24 ` [tip: sched/core] sched/fair: Simplify the continue_balancing logic in sched_balance_newidle() tip-bot2 for Shrikanth Hegde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.