Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched/fair: Simplify the continue_balancing logic in sched_balance_newidle()

newidle(CPU_NEWLY_IDLE) balancing doesn't stop the load-balancing if the
continue_balancing flag is reset, but the other two balancing (IDLE, BUSY)
cases 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>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Link: https://lore.kernel.org/r/20240325153926.274284-1-sshegde@linux.ibm.com

authored by

Shrikanth Hegde and committed by
Ingo Molnar
c829d681 d0f5d3ce

+5 -5
+5 -5
kernel/sched/fair.c
··· 12358 12358 { 12359 12359 unsigned long next_balance = jiffies + HZ; 12360 12360 int this_cpu = this_rq->cpu; 12361 + int continue_balancing = 1; 12361 12362 u64 t0, t1, curr_cost = 0; 12362 12363 struct sched_domain *sd; 12363 12364 int pulled_task = 0; ··· 12373 12372 return 0; 12374 12373 12375 12374 /* 12376 - * We must set idle_stamp _before_ calling idle_balance(), such that we 12377 - * measure the duration of idle_balance() as idle time. 12375 + * We must set idle_stamp _before_ calling sched_balance_rq() 12376 + * for CPU_NEWLY_IDLE, such that we measure the this duration 12377 + * as idle time. 12378 12378 */ 12379 12379 this_rq->idle_stamp = rq_clock(this_rq); 12380 12380 ··· 12414 12412 12415 12413 rcu_read_lock(); 12416 12414 for_each_domain(this_cpu, sd) { 12417 - int continue_balancing = 1; 12418 12415 u64 domain_cost; 12419 12416 12420 12417 update_next_balance(sd, &next_balance); ··· 12439 12438 * Stop searching for tasks to pull if there are 12440 12439 * now runnable tasks on this rq. 12441 12440 */ 12442 - if (pulled_task || this_rq->nr_running > 0 || 12443 - this_rq->ttwu_pending) 12441 + if (pulled_task || !continue_balancing) 12444 12442 break; 12445 12443 } 12446 12444 rcu_read_unlock();