[PATCH V2 21/36] hrtimer: create base_on_this_cpu()
From: Viresh Kumar
Date: Fri Apr 04 2014 - 02:42:05 EST
We had this code at two places to find if a clock base belongs to current CPU:
base->cpu_base == &__get_cpu_var(hrtimer_bases)
Better to get a inlined routine for that.
Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
---
kernel/hrtimer.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 458b952..2d5bb9d 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -107,6 +107,10 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id)
return hrtimer_clock_to_base_table[clock_id];
}
+static inline bool base_on_this_cpu(struct hrtimer_clock_base *base)
+{
+ return base->cpu_base == &__get_cpu_var(hrtimer_bases);
+}
/*
* Get the coarse grained time at the softirq based on xtime and
@@ -933,8 +937,7 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base)
* move the timer base in switch_hrtimer_base.
*/
state = timer->state & HRTIMER_STATE_CALLBACK;
- __remove_hrtimer(timer, base, state,
- base->cpu_base == &__get_cpu_var(hrtimer_bases));
+ __remove_hrtimer(timer, base, state, base_on_this_cpu(base));
return 1;
}
@@ -980,7 +983,7 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
*
* XXX send_remote_softirq() ?
*/
- if (leftmost && new_base->cpu_base == &__get_cpu_var(hrtimer_bases)
+ if (leftmost && base_on_this_cpu(new_base)
&& hrtimer_enqueue_reprogram(timer, new_base)) {
if (wakeup) {
/*
--
1.7.12.rc2.18.g61b472e
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/