diff mbox

[27/38] tick-sched: remove 'regs' parameter of tick_sched_handle()

Message ID 4e9e4b7fe0a9417777ab1b7543209da5999d7414.1397492345.git.viresh.kumar@linaro.org
State New
Headers show

Commit Message

Viresh Kumar April 14, 2014, 4:23 p.m. UTC
tick_sched_handle() is called from two places and both pass 'regs' to it almost
same way. This patch removes this parameter to tick_sched_handle() and updates
tick_sched_handle() to get that by itself.

The only point of difference in the way this routine was called from its callers
was, don't call it from process context. To make sure the nohz path doesn't
suffer from an additional branch instruction, add unlikely to the if()
statement.

Though I still don't understand when will we run tick_sched_timer() from process
context. I couldn't see a single instance of that happening on my test machine
for normal boot followed by some userspace operations.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 kernel/time/tick-sched.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
diff mbox

Patch

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index bff7f97..ee0768b 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -129,8 +129,17 @@  static void tick_sched_do_timer(ktime_t now)
 		tick_do_update_jiffies64(now);
 }
 
-static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs)
+static void tick_sched_handle(struct tick_sched *ts)
 {
+	struct pt_regs *regs = get_irq_regs();
+
+	/*
+	 * Do not call, when we are not in irq context and have
+	 * no valid regs pointer
+	 */
+	if (unlikely(!regs))
+		return;
+
 #ifdef CONFIG_NO_HZ_COMMON
 	/*
 	 * When we are idle and the tick is stopped, we have to touch
@@ -942,13 +951,12 @@  static int tick_nohz_reprogram(struct tick_sched *ts, ktime_t now)
 static void tick_nohz_handler(struct clock_event_device *dev)
 {
 	struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
-	struct pt_regs *regs = get_irq_regs();
 	ktime_t now = ktime_get();
 
 	dev->next_event.tv64 = KTIME_MAX;
 
 	tick_sched_do_timer(now);
-	tick_sched_handle(ts, regs);
+	tick_sched_handle(ts);
 
 	while (tick_nohz_reprogram(ts, now)) {
 		now = ktime_get();
@@ -1065,17 +1073,10 @@  static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
 {
 	struct tick_sched *ts =
 		container_of(timer, struct tick_sched, sched_timer);
-	struct pt_regs *regs = get_irq_regs();
 	ktime_t now = ktime_get();
 
 	tick_sched_do_timer(now);
-
-	/*
-	 * Do not call, when we are not in irq context and have
-	 * no valid regs pointer
-	 */
-	if (regs)
-		tick_sched_handle(ts, regs);
+	tick_sched_handle(ts);
 
 	hrtimer_forward(timer, now, tick_period);