diff options
author | Anna-Maria Gleixner <anna-maria@linutronix.de> | 2016-07-04 05:50:39 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-07-07 04:35:12 -0400 |
commit | ffdf047728f8f93df896b58049c7513856027141 (patch) | |
tree | 67797a07e54f5015e4b9d41637eac0fad401861b | |
parent | 4e85876a9d2a977b4a07389da8c07edf76d10825 (diff) |
timers: Split out index calculation
For further optimizations we need to seperate index calculation
from queueing. No functional change.
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Chris Mason <clm@fb.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: George Spelvin <linux@sciencehorizons.net>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160704094342.691159619@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | kernel/time/timer.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 8d830f1f6a6a..8d7c23e55c85 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c | |||
@@ -471,12 +471,9 @@ static inline unsigned calc_index(unsigned expires, unsigned lvl) | |||
471 | return LVL_OFFS(lvl) + (expires & LVL_MASK); | 471 | return LVL_OFFS(lvl) + (expires & LVL_MASK); |
472 | } | 472 | } |
473 | 473 | ||
474 | static void | 474 | static int calc_wheel_index(unsigned long expires, unsigned long clk) |
475 | __internal_add_timer(struct timer_base *base, struct timer_list *timer) | ||
476 | { | 475 | { |
477 | unsigned long expires = timer->expires; | 476 | unsigned long delta = expires - clk; |
478 | unsigned long delta = expires - base->clk; | ||
479 | struct hlist_head *vec; | ||
480 | unsigned int idx; | 477 | unsigned int idx; |
481 | 478 | ||
482 | if (delta < LVL_START(1)) { | 479 | if (delta < LVL_START(1)) { |
@@ -496,7 +493,7 @@ __internal_add_timer(struct timer_base *base, struct timer_list *timer) | |||
496 | } else if (LVL_DEPTH > 8 && delta < LVL_START(8)) { | 493 | } else if (LVL_DEPTH > 8 && delta < LVL_START(8)) { |
497 | idx = calc_index(expires, 7); | 494 | idx = calc_index(expires, 7); |
498 | } else if ((long) delta < 0) { | 495 | } else if ((long) delta < 0) { |
499 | idx = base->clk & LVL_MASK; | 496 | idx = clk & LVL_MASK; |
500 | } else { | 497 | } else { |
501 | /* | 498 | /* |
502 | * Force expire obscene large timeouts to expire at the | 499 | * Force expire obscene large timeouts to expire at the |
@@ -507,20 +504,33 @@ __internal_add_timer(struct timer_base *base, struct timer_list *timer) | |||
507 | 504 | ||
508 | idx = calc_index(expires, LVL_DEPTH - 1); | 505 | idx = calc_index(expires, LVL_DEPTH - 1); |
509 | } | 506 | } |
510 | /* | 507 | return idx; |
511 | * Enqueue the timer into the array bucket, mark it pending in | 508 | } |
512 | * the bitmap and store the index in the timer flags. | 509 | |
513 | */ | 510 | /* |
514 | vec = base->vectors + idx; | 511 | * Enqueue the timer into the hash bucket, mark it pending in |
515 | hlist_add_head(&timer->entry, vec); | 512 | * the bitmap and store the index in the timer flags. |
513 | */ | ||
514 | static void enqueue_timer(struct timer_base *base, struct timer_list *timer, | ||
515 | unsigned int idx) | ||
516 | { | ||
517 | hlist_add_head(&timer->entry, base->vectors + idx); | ||
516 | __set_bit(idx, base->pending_map); | 518 | __set_bit(idx, base->pending_map); |
517 | timer_set_idx(timer, idx); | 519 | timer_set_idx(timer, idx); |
518 | } | 520 | } |
519 | 521 | ||
520 | static void internal_add_timer(struct timer_base *base, struct timer_list *timer) | 522 | static void |
523 | __internal_add_timer(struct timer_base *base, struct timer_list *timer) | ||
521 | { | 524 | { |
522 | __internal_add_timer(base, timer); | 525 | unsigned int idx; |
526 | |||
527 | idx = calc_wheel_index(timer->expires, base->clk); | ||
528 | enqueue_timer(base, timer, idx); | ||
529 | } | ||
523 | 530 | ||
531 | static void | ||
532 | trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer) | ||
533 | { | ||
524 | if (!IS_ENABLED(CONFIG_NO_HZ_COMMON) || !base->nohz_active) | 534 | if (!IS_ENABLED(CONFIG_NO_HZ_COMMON) || !base->nohz_active) |
525 | return; | 535 | return; |
526 | 536 | ||
@@ -551,7 +561,14 @@ static void internal_add_timer(struct timer_base *base, struct timer_list *timer | |||
551 | * wheel: | 561 | * wheel: |
552 | */ | 562 | */ |
553 | base->next_expiry = timer->expires; | 563 | base->next_expiry = timer->expires; |
554 | wake_up_nohz_cpu(base->cpu); | 564 | wake_up_nohz_cpu(base->cpu); |
565 | } | ||
566 | |||
567 | static void | ||
568 | internal_add_timer(struct timer_base *base, struct timer_list *timer) | ||
569 | { | ||
570 | __internal_add_timer(base, timer); | ||
571 | trigger_dyntick_cpu(base, timer); | ||
555 | } | 572 | } |
556 | 573 | ||
557 | #ifdef CONFIG_TIMER_STATS | 574 | #ifdef CONFIG_TIMER_STATS |