The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] Use num_possible_cpus() instead of NR_CPUS for timer distribution
Date: Wed, 15 Aug 2007 15:46:17 -0700	[thread overview]
Message-ID: <1187217977.6062.23.camel@localhost.localdomain> (raw)

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);
 



             reply	other threads:[~2007-08-15 22:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-15 22:46 john stultz [this message]
2007-08-15 23:04 ` [PATCH] Use num_possible_cpus() instead of NR_CPUS for timer distribution Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1187217977.6062.23.camel@localhost.localdomain \
    --to=johnstul@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox