Messages in this thread | | | Date | Sun, 30 Aug 2009 02:06:57 -0400 | From | Ashwin Chaugule <> | Subject | Re: [RFC] [PATCH 1/1] hrtimers: Cache next hrtimer |
| |
Thomas Gleixner wrote:
> Hmm. I'd really like to know why that's behaving different. > > Usually there are only timers in the CLOCK_MONOTONIC base during > boot. CLOCK_REALTIME base should be empty most of the time. If my > theory is correct then the number of reprogram events is correct as > well because base[MONOTONIC]->first is always the one which armed the > timer. > > > Okay, I think I figured this out :)
I added some debug to find out how many timers are going to expire_next.
hrtimer_reprogram()
if (expires.tv64 == expires_next->tv64)
if (timer != next_hrtimer)
timer->realtime++; (lazily reusing realtime here, coz we know its always zero otherwise ;) )
Now timer->realtime is very much non-zero :)
So, now base->first has already changed (leftmost node in the rb tree) and is pointing to this new timer node which is also going to expire_next, but hasn't changed the value of expire_next (we just returned 0).
Therefore, in remove_hrtimer()
+ 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);
timer->node is going to point to the latest timer enqueued which is going to expire_next.
With your latest patch, we will force reprogram, but the next node to arm the timer will be needless, because, its expiry is equal to expires_next.
So, by having a pointer like next_hrtimer, helps to represent all the timers that are going to expire next, and thats why timer->cache_hits was always less than timer->total_count.IOW, we avoided re-programming the device, if the next timer was going to expire at the same time as the one we just removed.
Thoughts ?
Cheers,
Ashwin
| |