Skip to content

Commit 9a2b764

Browse files
Frederic WeisbeckerKAGA-KOKO
authored andcommitted
timers: Move trigger_dyntick_cpu() to enqueue_timer()
Consolidate the code by calling trigger_dyntick_cpu() from enqueue_timer() instead of calling it from all its callers. Signed-off-by: Frederic Weisbecker <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Juri Lelli <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 1f32cab commit 9a2b764

File tree

1 file changed

+25
-36
lines changed

1 file changed

+25
-36
lines changed

kernel/time/timer.c

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -533,30 +533,6 @@ static int calc_wheel_index(unsigned long expires, unsigned long clk,
533533
return idx;
534534
}
535535

536-
/*
537-
* Enqueue the timer into the hash bucket, mark it pending in
538-
* the bitmap and store the index in the timer flags.
539-
*/
540-
static void enqueue_timer(struct timer_base *base, struct timer_list *timer,
541-
unsigned int idx)
542-
{
543-
hlist_add_head(&timer->entry, base->vectors + idx);
544-
__set_bit(idx, base->pending_map);
545-
timer_set_idx(timer, idx);
546-
547-
trace_timer_start(timer, timer->expires, timer->flags);
548-
}
549-
550-
static void
551-
__internal_add_timer(struct timer_base *base, struct timer_list *timer,
552-
unsigned long *bucket_expiry)
553-
{
554-
unsigned int idx;
555-
556-
idx = calc_wheel_index(timer->expires, base->clk, bucket_expiry);
557-
enqueue_timer(base, timer, idx);
558-
}
559-
560536
static void
561537
trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer,
562538
unsigned long bucket_expiry)
@@ -598,15 +574,31 @@ trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer,
598574
wake_up_nohz_cpu(base->cpu);
599575
}
600576

601-
static void
602-
internal_add_timer(struct timer_base *base, struct timer_list *timer)
577+
/*
578+
* Enqueue the timer into the hash bucket, mark it pending in
579+
* the bitmap, store the index in the timer flags then wake up
580+
* the target CPU if needed.
581+
*/
582+
static void enqueue_timer(struct timer_base *base, struct timer_list *timer,
583+
unsigned int idx, unsigned long bucket_expiry)
603584
{
604-
unsigned long bucket_expiry;
585+
hlist_add_head(&timer->entry, base->vectors + idx);
586+
__set_bit(idx, base->pending_map);
587+
timer_set_idx(timer, idx);
605588

606-
__internal_add_timer(base, timer, &bucket_expiry);
589+
trace_timer_start(timer, timer->expires, timer->flags);
607590
trigger_dyntick_cpu(base, timer, bucket_expiry);
608591
}
609592

593+
static void internal_add_timer(struct timer_base *base, struct timer_list *timer)
594+
{
595+
unsigned long bucket_expiry;
596+
unsigned int idx;
597+
598+
idx = calc_wheel_index(timer->expires, base->clk, &bucket_expiry);
599+
enqueue_timer(base, timer, idx, bucket_expiry);
600+
}
601+
610602
#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
611603

612604
static struct debug_obj_descr timer_debug_descr;
@@ -1057,16 +1049,13 @@ __mod_timer(struct timer_list *timer, unsigned long expires, unsigned int option
10571049
/*
10581050
* If 'idx' was calculated above and the base time did not advance
10591051
* between calculating 'idx' and possibly switching the base, only
1060-
* enqueue_timer() and trigger_dyntick_cpu() is required. Otherwise
1061-
* we need to (re)calculate the wheel index via
1062-
* internal_add_timer().
1052+
* enqueue_timer() is required. Otherwise we need to (re)calculate
1053+
* the wheel index via internal_add_timer().
10631054
*/
1064-
if (idx != UINT_MAX && clk == base->clk) {
1065-
enqueue_timer(base, timer, idx);
1066-
trigger_dyntick_cpu(base, timer, bucket_expiry);
1067-
} else {
1055+
if (idx != UINT_MAX && clk == base->clk)
1056+
enqueue_timer(base, timer, idx, bucket_expiry);
1057+
else
10681058
internal_add_timer(base, timer);
1069-
}
10701059

10711060
out_unlock:
10721061
raw_spin_unlock_irqrestore(&base->lock, flags);

0 commit comments

Comments
 (0)