Re: [PATCH] Call get_time() only when necessary in run_hrtimer_queue

From: Dimitri Sivanich
Date: Tue Mar 28 2006 - 11:48:52 EST


On Fri, Mar 24, 2006 at 02:28:49PM -0800, Andrew Morton wrote:
> This code has been extensively redone in -mm and I am planning on sending
> all that to Linus within a week.
>
> The hrtimer rework in -mm might fix this performance problem, although from
> a quick peek, perhaps not.
>
> So could you please verify that the problem still needs fixing in
> 2.6.16-mm1 and if so, raise a patch against that?
>

The hrtimer work in -mm does improve on the situation, although there
appears to be some occasional cache line contention for xtime. The
following patch (which is similiar to my previously submitted patch)
is applicable to 2.6.16-mm1 and does take care of at least a good
portion of that.

Signed-off-by: Dimitri Sivanich <sivanich@xxxxxxx>

Index: linux/kernel/hrtimer.c
===================================================================
--- linux.orig/kernel/hrtimer.c 2006-03-27 09:43:40.000000000 -0600
+++ linux/kernel/hrtimer.c 2006-03-27 12:35:47.416054373 -0600
@@ -604,14 +604,17 @@ int hrtimer_get_res(const clockid_t whic
*/
static inline void run_hrtimer_queue(struct hrtimer_base *base)
{
- struct rb_node *node;
+ struct rb_node *node = base->first;
+
+ if (!node)
+ return;

if (base->get_softirq_time)
base->softirq_time = base->get_softirq_time();

spin_lock_irq(&base->lock);

- while ((node = base->first)) {
+ while (node) {
struct hrtimer *timer;
int (*fn)(struct hrtimer *);
int restart;
@@ -633,6 +636,7 @@ static inline void run_hrtimer_queue(str
BUG_ON(hrtimer_active(timer));
enqueue_hrtimer(timer, base);
}
+ node = base->first;
}
set_curr_timer(base, NULL);
spin_unlock_irq(&base->lock);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/