mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/rt: use for_each_cpu_wrap to iterate over rto_mask
@ 2024-11-14 22:05 Jon Kohler
  2024-11-15 10:04 ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Kohler @ 2024-11-14 22:05 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel
  Cc: Jon Kohler

When using NO_RT_PUSH_IPI, using for_each_cpu() over rto_mask may cause
many CPUs to attempt to pull load from the same CPU, causing RQ
lock contention.

Use for_each_cpu_wrap instead to spread out which RQ gets evaluated
first, similar to how _nohz_idle_balance iterates over idle_cpus_mask.
This strategy is beneficial when there are many CPUs in rto_mask and
many other CPUs going in and out of schedule() at the same time.

Signed-off-by: Jon Kohler <jon@nutanix.com>
---
 kernel/sched/rt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 172c588de542..c883ff122f5d 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2308,7 +2308,7 @@ static void pull_rt_task(struct rq *this_rq)
 	}
 #endif
 
-	for_each_cpu(cpu, this_rq->rd->rto_mask) {
+	for_each_cpu_wrap(cpu, this_rq->rd->rto_mask, this_cpu+1) {
 		if (this_cpu == cpu)
 			continue;
 
-- 
2.43.0


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

* Re: [PATCH] sched/rt: use for_each_cpu_wrap to iterate over rto_mask
  2024-11-14 22:05 [PATCH] sched/rt: use for_each_cpu_wrap to iterate over rto_mask Jon Kohler
@ 2024-11-15 10:04 ` Peter Zijlstra
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2024-11-15 10:04 UTC (permalink / raw)
  To: Jon Kohler
  Cc: Ingo Molnar, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider,
	linux-kernel

On Thu, Nov 14, 2024 at 03:05:58PM -0700, Jon Kohler wrote:
> When using NO_RT_PUSH_IPI, using for_each_cpu() over rto_mask may cause
> many CPUs to attempt to pull load from the same CPU, causing RQ
> lock contention.
> 
> Use for_each_cpu_wrap instead to spread out which RQ gets evaluated
> first, similar to how _nohz_idle_balance iterates over idle_cpus_mask.
> This strategy is beneficial when there are many CPUs in rto_mask and
> many other CPUs going in and out of schedule() at the same time.
> 
> Signed-off-by: Jon Kohler <jon@nutanix.com>
> ---
>  kernel/sched/rt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 172c588de542..c883ff122f5d 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2308,7 +2308,7 @@ static void pull_rt_task(struct rq *this_rq)
>  	}
>  #endif
>  
> -	for_each_cpu(cpu, this_rq->rd->rto_mask) {
> +	for_each_cpu_wrap(cpu, this_rq->rd->rto_mask, this_cpu+1) {
>  		if (this_cpu == cpu)
>  			continue;

Works for me I suppose, but as with that other rt patch, please do the
matching change for dl too.

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

end of thread, other threads:[~2024-11-15 10:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-14 22:05 [PATCH] sched/rt: use for_each_cpu_wrap to iterate over rto_mask Jon Kohler
2024-11-15 10:04 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®