Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1625438 > unrolled thread
| Started by | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| First post | 2017-04-18 18:50 +0200 |
| Last post | 2017-04-21 17:30 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[patch V2 03/10] timers: Rework idle logic Thomas Gleixner <tglx@linutronix.de> - 2017-04-18 18:50 +0200
Re: [patch V2 03/10] timers: Rework idle logic Peter Zijlstra <peterz@infradead.org> - 2017-04-19 09:00 +0200
Re: [patch V2 03/10] timers: Rework idle logic Frederic Weisbecker <fweisbec@gmail.com> - 2017-04-21 17:30 +0200
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2017-04-18 18:50 +0200 |
| Subject | [patch V2 03/10] timers: Rework idle logic |
| Message-ID | <txEue-8r4-3@gated-at.bofh.it> |
Storing next event and determining whether the base is idle can be done in
__next_timer_interrupt().
Preparatory patch for new call sites which need this information as well.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/time/timer.c | 43 ++++++++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 19 deletions(-)
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1358,8 +1358,11 @@ static int next_pending_bucket(struct ti
/*
* Search the first expiring timer in the various clock levels. Caller must
* hold base->lock.
+ *
+ * Stores the next expiry time in base. The return value indicates whether
+ * the base is empty or not.
*/
-static unsigned long __next_timer_interrupt(struct timer_base *base)
+static bool __next_timer_interrupt(struct timer_base *base)
{
unsigned long clk, next, adj;
unsigned lvl, offset = 0;
@@ -1416,7 +1419,10 @@ static unsigned long __next_timer_interr
clk >>= LVL_CLK_SHIFT;
clk += adj;
}
- return next;
+ /* Store the next event in the base */
+ base->next_expiry = next;
+ /* Return whether the base is empty or not */
+ return next == base->clk + NEXT_TIMER_MAX_DELTA;
}
/*
@@ -1465,7 +1471,7 @@ u64 get_next_timer_interrupt(unsigned lo
struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);
u64 expires = KTIME_MAX;
unsigned long nextevt;
- bool is_max_delta;
+ bool is_empty;
/*
* Pretend that there is no timer pending if the cpu is offline.
@@ -1475,9 +1481,8 @@ u64 get_next_timer_interrupt(unsigned lo
return expires;
spin_lock(&base->lock);
- nextevt = __next_timer_interrupt(base);
- is_max_delta = (nextevt == base->clk + NEXT_TIMER_MAX_DELTA);
- base->next_expiry = nextevt;
+ is_empty = __next_timer_interrupt(base);
+ nextevt = base->next_expiry;
/*
* We have a fresh next event. Check whether we can forward the
* base. We can only do that when @basej is past base->clk
@@ -1490,20 +1495,17 @@ u64 get_next_timer_interrupt(unsigned lo
base->clk = nextevt;
}
- if (time_before_eq(nextevt, basej)) {
- expires = basem;
- base->is_idle = false;
- } else {
- if (!is_max_delta)
- expires = basem + (nextevt - basej) * TICK_NSEC;
- /*
- * If we expect to sleep more than a tick, mark the base idle:
- */
- if ((expires - basem) > TICK_NSEC)
- base->is_idle = true;
- }
+ /* Base is idle if the next event is more than a tick away. */
+ base->is_idle = time_after(nextevt, basej + 1);
spin_unlock(&base->lock);
+ if (!is_empty) {
+ /* If we missed a tick already, force 0 delta */
+ if (time_before_eq(nextevt, basej))
+ nextevt = basej;
+ expires = basem + (nextevt - basej) * TICK_NSEC;
+ }
+
return cmp_next_hrtimer_event(basem, expires);
}
@@ -1534,7 +1536,10 @@ static int collect_expired_timers(struct
* the next expiring timer.
*/
if ((long)(jiffies - base->clk) > 2) {
- unsigned long next = __next_timer_interrupt(base);
+ unsigned long next;
+
+ __next_timer_interrupt(base);
+ next = base->next_expiry;
/*
* If the next timer is ahead of time forward to current
[toc] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2017-04-19 09:00 +0200 |
| Message-ID | <txRKO-8uq-17@gated-at.bofh.it> |
| In reply to | #1625438 |
On Tue, Apr 18, 2017 at 01:11:05PM +0200, Thomas Gleixner wrote: > Storing next event and determining whether the base is idle can be done in > __next_timer_interrupt(). > > Preparatory patch for new call sites which need this information as well. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > --- > kernel/time/timer.c | 43 ++++++++++++++++++++++++------------------- > 1 file changed, 24 insertions(+), 19 deletions(-) > > --- a/kernel/time/timer.c > +++ b/kernel/time/timer.c > @@ -1358,8 +1358,11 @@ static int next_pending_bucket(struct ti > /* > * Search the first expiring timer in the various clock levels. Caller must > * hold base->lock. > + * > + * Stores the next expiry time in base. The return value indicates whether > + * the base is empty or not. > */ > -static unsigned long __next_timer_interrupt(struct timer_base *base) > +static bool __next_timer_interrupt(struct timer_base *base) Can't say I'm a fan of this.. I sort of see where this is going, but the fact remains that __next_timer_interrupt(), as a function, makes me expect a return value of time/timer quantity.
[toc] | [prev] | [next] | [standalone]
| From | Frederic Weisbecker <fweisbec@gmail.com> |
|---|---|
| Date | 2017-04-21 17:30 +0200 |
| Message-ID | <tyIFs-7rg-5@gated-at.bofh.it> |
| In reply to | #1625860 |
On Wed, Apr 19, 2017 at 08:50:39AM +0200, Peter Zijlstra wrote: > On Tue, Apr 18, 2017 at 01:11:05PM +0200, Thomas Gleixner wrote: > > Storing next event and determining whether the base is idle can be done in > > __next_timer_interrupt(). > > > > Preparatory patch for new call sites which need this information as well. > > > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > > --- > > kernel/time/timer.c | 43 ++++++++++++++++++++++++------------------- > > 1 file changed, 24 insertions(+), 19 deletions(-) > > > > --- a/kernel/time/timer.c > > +++ b/kernel/time/timer.c > > @@ -1358,8 +1358,11 @@ static int next_pending_bucket(struct ti > > /* > > * Search the first expiring timer in the various clock levels. Caller must > > * hold base->lock. > > + * > > + * Stores the next expiry time in base. The return value indicates whether > > + * the base is empty or not. > > */ > > -static unsigned long __next_timer_interrupt(struct timer_base *base) > > +static bool __next_timer_interrupt(struct timer_base *base) > > Can't say I'm a fan of this.. I sort of see where this is going, but the > fact remains that __next_timer_interrupt(), as a function, makes me > expect a return value of time/timer quantity. Maybe we can just do a rename like fetch_next_timer_interrupt() or update_next_timer_interrupt()?
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web