The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] Use num_possible_cpus() instead of NR_CPUS for timer distribution
@ 2007-08-15 22:46 john stultz
  2007-08-15 23:04 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: john stultz @ 2007-08-15 22:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Thomas Gleixner, lkml

Andrew requested this fixup awhile back, and I just now got to it
(apologies for being slow).

To avoid lock contention, we distribute the sched_timer calls across the
cpus so they do not trigger at the same instant. However, I used
NR_CPUS, which can cause needless grouping on small smp systems
depending on your kernel config. This patch converts to using
num_possible_cpus() so we spread it as evenly as possible on every
machine.

Briefly tested w/ NR_CPUS=255 and verified reduced contention.

Signed-off-by: John Stultz <johnstul@us.ibm.com>

Index: 2.6-rt/kernel/time/tick-sched.c
===================================================================
--- 2.6-rt.orig/kernel/time/tick-sched.c
+++ 2.6-rt/kernel/time/tick-sched.c
@@ -586,7 +586,7 @@ void tick_setup_sched_timer(void)
 	/* Get the next period (per cpu) */
 	ts->sched_timer.expires = tick_init_jiffy_update();
 	offset = ktime_to_ns(tick_period) >> 1;
-	do_div(offset, NR_CPUS);
+	do_div(offset, num_possible_cpus());
 	offset *= smp_processor_id();
 	ts->sched_timer.expires = ktime_add_ns(ts->sched_timer.expires, offset);
 



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

* Re: [PATCH] Use num_possible_cpus() instead of NR_CPUS for timer distribution
  2007-08-15 22:46 [PATCH] Use num_possible_cpus() instead of NR_CPUS for timer distribution john stultz
@ 2007-08-15 23:04 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2007-08-15 23:04 UTC (permalink / raw)
  To: john stultz; +Cc: Andrew Morton, lkml

On Wed, 2007-08-15 at 15:46 -0700, john stultz wrote:
> Andrew requested this fixup awhile back, and I just now got to it
> (apologies for being slow).
> 
> To avoid lock contention, we distribute the sched_timer calls across the
> cpus so they do not trigger at the same instant. However, I used
> NR_CPUS, which can cause needless grouping on small smp systems
> depending on your kernel config. This patch converts to using
> num_possible_cpus() so we spread it as evenly as possible on every
> machine.
> 
> Briefly tested w/ NR_CPUS=255 and verified reduced contention.
>
> Signed-off-by: John Stultz <johnstul@us.ibm.com>

Doh, I missed this as well

Acked-by: Thomas Gleixner <tglx@linutronix,de>

> 
> Index: 2.6-rt/kernel/time/tick-sched.c
> ===================================================================
> --- 2.6-rt.orig/kernel/time/tick-sched.c
> +++ 2.6-rt/kernel/time/tick-sched.c
> @@ -586,7 +586,7 @@ void tick_setup_sched_timer(void)
>  	/* Get the next period (per cpu) */
>  	ts->sched_timer.expires = tick_init_jiffy_update();
>  	offset = ktime_to_ns(tick_period) >> 1;
> -	do_div(offset, NR_CPUS);
> +	do_div(offset, num_possible_cpus());
>  	offset *= smp_processor_id();
>  	ts->sched_timer.expires = ktime_add_ns(ts->sched_timer.expires, offset);



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

end of thread, other threads:[~2007-08-15 23:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-15 22:46 [PATCH] Use num_possible_cpus() instead of NR_CPUS for timer distribution john stultz
2007-08-15 23:04 ` Thomas Gleixner

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