From: Thomas Gleixner <tglx@linutronix.de>
To: Ashwin Chaugule <ashwinc@codeaurora.org>
Cc: linux-kernel@vger.kernel.org, mingo@redhat.com
Subject: Re: [RFC] [PATCH 1/1] hrtimers: Cache next hrtimer
Date: Fri, 28 Aug 2009 13:17:07 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.0908281308380.2888@localhost.localdomain> (raw)
In-Reply-To: <4A9771AA.2090004@codeaurora.org>
On Fri, 28 Aug 2009, Ashwin Chaugule wrote:
> Thomas Gleixner wrote:
> Just didn't know the following could have the same effect. (base->offset is
> confusing)
It's simple. We have CLOCK_MONOTONIC and CLOCK_REALTIME. The internal
time base is CLOCK_MONOTONIC. So we use base->offset to convert
CLOCK_REALTIME to CLOCK_MONOTONIC. In case the timer is
CLOCK_MONOTONIC we so the substraction as well, but it simply
subtracts 0 :)
> + /*
> + * Remove the timer from the rbtree and replace the first
> + * entry pointer if necessary.
> + */
> + rb_erase(&timer->node, &base->active);
> +
> + if (base->first != &timer->node)
> + goto out;
> +
> + base->first = rb_next(&timer->node);
Gah. Looking at the patch with an awake brain makes me feel
stupid. Working version below.
Thanks,
tglx
---
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 49da79a..380682b 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -906,19 +906,28 @@ static void __remove_hrtimer(struct hrtimer *timer,
struct hrtimer_clock_base *base,
unsigned long newstate, int reprogram)
{
- if (timer->state & HRTIMER_STATE_ENQUEUED) {
- /*
- * Remove the timer from the rbtree and replace the
- * first entry pointer if necessary.
- */
- if (base->first == &timer->node) {
- base->first = rb_next(&timer->node);
- /* Reprogram the clock event device. if enabled */
- if (reprogram && hrtimer_hres_active())
+ ktime_t expires;
+
+ if (!(timer->state & HRTIMER_STATE_ENQUEUED))
+ goto out;
+
+ /*
+ * Remove the timer from the rbtree and replace the first
+ * entry pointer if necessary.
+ */
+ if (base->first == &timer->node) {
+ base->first = rb_next(&timer->node);
+ /* Reprogram the clock event device. if enabled */
+ if (reprogram && hrtimer_hres_active()) {
+ expires = ktime_sub(hrtimer_get_expires(timer),
+ base->offset);
+ if (base->cpu_base->expires_next.tv64 == expires.tv64)
hrtimer_force_reprogram(base->cpu_base);
}
- rb_erase(&timer->node, &base->active);
}
+
+ rb_erase(&timer->node, &base->active);
+out:
timer->state = newstate;
}
next prev parent reply other threads:[~2009-08-28 11:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-27 21:51 [RFC] [PATCH 1/1] hrtimers: Cache next hrtimer Ashwin Chaugule
2009-08-27 21:56 ` Ashwin Chaugule
2009-08-27 22:51 ` Thomas Gleixner
2009-08-27 23:09 ` Ashwin Chaugule
2009-08-27 23:16 ` Thomas Gleixner
2009-08-28 5:56 ` Ashwin Chaugule
2009-08-28 11:17 ` Thomas Gleixner [this message]
2009-08-28 16:34 ` Ashwin Chaugule
2009-08-28 18:19 ` Thomas Gleixner
2009-08-28 20:27 ` Ashwin Chaugule
2009-08-30 6:06 ` Ashwin Chaugule
2009-08-30 8:36 ` Thomas Gleixner
2009-08-31 4:17 ` Ashwin Chaugule
2009-08-31 7:08 ` Thomas Gleixner
2009-09-01 3:13 ` Ashwin Chaugule
2009-09-03 17:48 ` Ashwin Chaugule
2009-09-15 9:09 ` [tip:timers/core] hrtimer: Eliminate needless reprogramming of clock events device tip-bot for Ashwin Chaugule
2009-09-15 15:19 ` tip-bot for Ashwin Chaugule
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=alpine.LFD.2.00.0908281308380.2888@localhost.localdomain \
--to=tglx@linutronix.de \
--cc=ashwinc@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
/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