public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Call get_time() only when necessary in run_hrtimer_queue
@ 2006-03-24 17:51 Dimitri Sivanich
  2006-03-24 22:28 ` Andrew Morton
  0 siblings, 1 reply; 8+ messages in thread
From: Dimitri Sivanich @ 2006-03-24 17:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, tglx, mingo, roe, steiner, Christoph Lameter

It seems that run_hrtimer_queue() is calling get_time() much more often
than it needs to.

With this patch, it only calls get_time() if there's a pending timer.

Following is from a profile done without the patch:
kernel ticks:           30841           1.02 %
      13572       44.01    44.01      time_interpolator_get_offset
        155        0.50    96.91      hrtimer_run_queues

And with the patch:
	kernel ticks:           18334           0.58 %
         74        0.40    97.81      hrtimer_run_queues
         43        0.23    98.63      time_interpolator_get_offset


Signed-off-by: Dimitri Sivanich <sivanich@sgi.com>

Index: linux-2.6.15/kernel/hrtimer.c
===================================================================
--- linux-2.6.15.orig/kernel/hrtimer.c	2006-03-23 14:37:49.032686221 -0600
+++ linux-2.6.15/kernel/hrtimer.c	2006-03-23 14:39:10.655542086 -0600
@@ -586,12 +586,17 @@ int hrtimer_get_res(const clockid_t whic
  */
 static inline void run_hrtimer_queue(struct hrtimer_base *base)
 {
-	ktime_t now = base->get_time();
-	struct rb_node *node;
+	ktime_t now;
+	struct rb_node *node = base->first;
+
+	if (!node)
+		return;
+
+	now = base->get_time();
 
 	spin_lock_irq(&base->lock);
 
-	while ((node = base->first)) {
+	while (node) {
 		struct hrtimer *timer;
 		int (*fn)(void *);
 		int restart;
@@ -620,6 +625,7 @@ static inline void run_hrtimer_queue(str
 
 		spin_lock_irq(&base->lock);
 
+		node = base->first;
 		/* Another CPU has added back the timer */
 		if (timer->state != HRTIMER_RUNNING)
 			continue;

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

end of thread, other threads:[~2006-03-28 20:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-24 17:51 [PATCH] Call get_time() only when necessary in run_hrtimer_queue Dimitri Sivanich
2006-03-24 22:28 ` Andrew Morton
2006-03-25  7:01   ` Thomas Gleixner
2006-03-28 16:51   ` Dimitri Sivanich
2006-03-28 17:39     ` Eric Dumazet
2006-03-28 17:55       ` Dimitri Sivanich
2006-03-28 19:20         ` Thomas Gleixner
2006-03-28 20:14           ` [PATCH] Call get_softirq_time() only when necessary in run_hrtimer_queue() Dimitri Sivanich

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