From: Peter Zijlstra <peterz@infradead.org>
To: Arjan van de Ven <arjan@infradead.org>
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
dwmw2@infradead.org, drepper@redhat.com, mingo@elte.hu,
tglx@tglx.de, Fabio Checconi <fabio@gandalf.sssup.it>
Subject: Re: [PATCH 11/13] hrtimer: turn hrtimers into range timers
Date: Tue, 02 Sep 2008 13:08:45 +0200 [thread overview]
Message-ID: <1220353725.8609.32.camel@twins> (raw)
In-Reply-To: <1220343732.8609.19.camel@twins>
On Tue, 2008-09-02 at 10:22 +0200, Peter Zijlstra wrote:
> On Mon, 2008-09-01 at 16:08 -0700, Arjan van de Ven wrote:
>
> > @@ -847,7 +847,8 @@ static void enqueue_hrtimer(struct hrtimer *timer,
> > * We dont care about collisions. Nodes with
> > * the same expiry time stay together.
> > */
> > - if (timer->expires.tv64 < entry->expires.tv64) {
> > + if (hrtimer_get_expires_tv64(timer) <
> > + hrtimer_get_expires_tv64(entry)) {
> > link = &(*link)->rb_left;
> > } else {
> > link = &(*link)->rb_right;
>
> On Mon, 2008-09-01 at 16:13 -0700, Arjan van de Ven wrote:
>
> > +static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
> > +{
> > + timer->_softexpires = time;
> > + timer->_expires = ktime_add_safe(time, delta);
> > +}
>
> > @@ -241,10 +259,19 @@ static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
> > return timer->_expires;
> > }
> >
> > +static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
> > +{
> > + return timer->_expires;
> > +}
>
> Somehow the function is called softexpires, but returns the hard expire
> time...
>
> > static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
> > {
> > return timer->_expires.tv64;
> > }
> > +static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
> > +{
> > + return timer->_softexpires.tv64;
> > +}
> >
> > static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
> > {
>
> > @@ -1309,7 +1309,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
> >
> > timer = rb_entry(node, struct hrtimer, node);
> >
> > - if (basenow.tv64 < hrtimer_get_expires_tv64(timer)) {
> > + if (basenow.tv64 < hrtimer_get_softexpires_tv64(timer)) {
> > ktime_t expires;
> >
> > expires = ktime_sub(hrtimer_get_expires(timer),
>
> I might be missing something, but this code only looks at the leftmost
> timer, and we're indexed on the hard expire time, which might be rather
> far to the right of here.
>
> This means that esp for those timers for which we can save most we're
> least likely to do so because we'll plain not see them.
What you need is a data structure that supports stabbing queries on
overlapping intervals, such like a Priority Search Tree.
If I'm not mistaken, then the augmented Red-Black tree from the EEVDF
paper is identical to PST [*].
This data-structure adds a Heap property to each RB-node, allowing one
to search the tree on a different property.
So what you can do in this case, is index the RB-tree on the soft
expire, and index the heap on the hard expire.
Then you can find the leftmost hard expire by traversing the tree using
the heap property - and program the clock-event using that time.
And you can search for soft expired entries using the RB-tree like we do
now.
[*] Fabio implemented it on top of the linux RB-tree for their wf2q+
implementation that they used for their BFQ I/O scheduler:
http://feanor.sssup.it/~fabio/linux/wfq/
And I borrowed their implementation for my scheduler work:
http://programming.kicks-ass.net/kernel-patches/sched-eevdf/sched-eedf.patch
next prev parent reply other threads:[~2008-09-02 11:09 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-01 23:03 [PATCH 0/13] Turn hrtimers into a range capable timer Arjan van de Ven
2008-09-01 23:05 ` [PATCH 1/13] hrtimer: add abstraction functions for accessing the "expires" member Arjan van de Ven
2008-09-01 23:05 ` [PATCH 2/13] hrtimer: convert kvm to the new hrtimer apis Arjan van de Ven
2008-09-01 23:06 ` [PATCH 3/13] hrtimer: convert timerfd " Arjan van de Ven
2008-09-01 23:07 ` [PATCH 4/13] hrtimer: convert net::sched_cbq " Arjan van de Ven
2008-09-01 23:08 ` [PATCH 5/13] hrtimer: convert kernel/* " Arjan van de Ven
2008-09-01 23:09 ` [PATCH 6/13] hrtimer: convert powerpc/oprofile " Arjan van de Ven
2008-09-01 23:09 ` [PATCH 7/13] hrtimer: convert kvm-ia64 " Arjan van de Ven
2008-09-01 23:10 ` [PATCH 8/13] hrtimer: convert s390 " Arjan van de Ven
2008-09-01 23:11 ` [PATCH 9/13] hrtimer: convert sound/ " Arjan van de Ven
2008-09-01 23:12 ` [PATCH 10/13] hrtimer: rename the "expires" struct member to avoid accidental usage Arjan van de Ven
2008-09-01 23:12 ` Arjan van de Ven
2008-09-01 23:13 ` [PATCH 11/13] hrtimer: turn hrtimers into range timers Arjan van de Ven
2008-09-02 8:22 ` Peter Zijlstra
2008-09-02 11:08 ` Peter Zijlstra [this message]
2008-09-02 11:15 ` Peter Zijlstra
2008-09-02 13:06 ` Arjan van de Ven
2008-09-02 13:05 ` Arjan van de Ven
2008-09-02 13:47 ` Peter Zijlstra
2008-09-02 16:02 ` Arjan van de Ven
2008-09-01 23:14 ` [PATCH 12/13] hrtimer: create a "timer_slack" field in the task struct Arjan van de Ven
2008-09-02 10:04 ` Pavel Machek
2008-09-02 13:03 ` Arjan van de Ven
2008-09-08 13:27 ` Pavel Machek
2008-09-08 13:40 ` Arjan van de Ven
2008-09-08 14:15 ` Pavel Machek
2008-09-08 14:22 ` Arjan van de Ven
2008-09-13 16:24 ` Pavel Machek
2008-09-14 15:21 ` Ulrich Drepper
2008-09-14 15:27 ` Arjan van de Ven
2008-09-14 15:57 ` Pavel Machek
2008-09-14 16:04 ` Ulrich Drepper
2008-09-14 16:14 ` Arjan van de Ven
2008-09-17 7:42 ` Pavel Machek
2008-09-30 5:16 ` KOSAKI Motohiro
2008-09-30 8:28 ` Arjan van de Ven
2008-09-30 8:54 ` KOSAKI Motohiro
2008-09-01 23:14 ` [PATCH 13/13] hrtimer: make select() and poll() use the hrtimer range feature Arjan van de Ven
2008-09-02 8:22 ` Peter Zijlstra
2008-09-02 16:03 ` Arjan van de Ven
2008-09-06 14:56 ` [PATCH 0/13] Turn hrtimers into a range capable timer Ingo Molnar
2008-09-06 16:30 ` Arjan van de Ven
2008-09-06 16:33 ` Ingo Molnar
2008-09-12 3:39 ` Rusty Russell
2008-09-12 5:42 ` Arjan van de Ven
2008-09-12 20:24 ` 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=1220353725.8609.32.camel@twins \
--to=peterz@infradead.org \
--cc=arjan@infradead.org \
--cc=drepper@redhat.com \
--cc=dwmw2@infradead.org \
--cc=fabio@gandalf.sssup.it \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@tglx.de \
--cc=torvalds@linux-foundation.org \
/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