]> git.karo-electronics.de Git - linux-beck.git/commitdiff
timer: Remove code redundancy while calling get_nohz_timer_target()
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 18 Mar 2014 10:56:07 +0000 (16:26 +0530)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 20 Mar 2014 11:35:46 +0000 (12:35 +0100)
There are only two users of get_nohz_timer_target(): timer and hrtimer. Both
call it under same circumstances, i.e.

#ifdef CONFIG_NO_HZ_COMMON
       if (!pinned && get_sysctl_timer_migration() && idle_cpu(this_cpu))
               return get_nohz_timer_target();
#endif

So, it makes more sense to get all this as part of get_nohz_timer_target()
instead of duplicating code at two places. For this another parameter is
required to be passed to this routine, pinned.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org
Cc: fweisbec@gmail.com
Cc: peterz@infradead.org
Link: http://lkml.kernel.org/r/1e1b53537217d58d48c2d7a222a9c3ac47d5b64c.1395140107.git.viresh.kumar@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/sched.h
kernel/hrtimer.c
kernel/sched/core.c
kernel/timer.c

index 68a0e84463a0eb86b273fe14b49bd9b01feab21f..6f6c56f63c6860a36e6c06a32e55a11c8440ad0f 100644 (file)
@@ -291,10 +291,14 @@ extern int runqueue_is_locked(int cpu);
 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
 extern void nohz_balance_enter_idle(int cpu);
 extern void set_cpu_sd_state_idle(void);
-extern int get_nohz_timer_target(void);
+extern int get_nohz_timer_target(int pinned);
 #else
 static inline void nohz_balance_enter_idle(int cpu) { }
 static inline void set_cpu_sd_state_idle(void) { }
+static inline int get_nohz_timer_target(int pinned)
+{
+       return smp_processor_id();
+}
 #endif
 
 /*
index 09094361dce523fec7def28599b17c34bee16bec..d55092ceee2975c204bcb90e856f9b6504d577ac 100644 (file)
@@ -168,19 +168,6 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,
        }
 }
 
-
-/*
- * Get the preferred target CPU for NOHZ
- */
-static int hrtimer_get_target(int this_cpu, int pinned)
-{
-#ifdef CONFIG_NO_HZ_COMMON
-       if (!pinned && get_sysctl_timer_migration() && idle_cpu(this_cpu))
-               return get_nohz_timer_target();
-#endif
-       return this_cpu;
-}
-
 /*
  * With HIGHRES=y we do not migrate the timer when it is expiring
  * before the next event on the target cpu because we cannot reprogram
@@ -214,7 +201,7 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
        struct hrtimer_clock_base *new_base;
        struct hrtimer_cpu_base *new_cpu_base;
        int this_cpu = smp_processor_id();
-       int cpu = hrtimer_get_target(this_cpu, pinned);
+       int cpu = get_nohz_timer_target(pinned);
        int basenum = base->index;
 
 again:
index b46131ef6aab0ac48149482a03f8354330adf188..c0339e206cc2401807fbe434bb2c9158d64f9e1e 100644 (file)
@@ -555,12 +555,15 @@ void resched_cpu(int cpu)
  * selecting an idle cpu will add more delays to the timers than intended
  * (as that cpu's timer base may not be uptodate wrt jiffies etc).
  */
-int get_nohz_timer_target(void)
+int get_nohz_timer_target(int pinned)
 {
        int cpu = smp_processor_id();
        int i;
        struct sched_domain *sd;
 
+       if (pinned || !get_sysctl_timer_migration() || !idle_cpu(cpu))
+               return cpu;
+
        rcu_read_lock();
        for_each_domain(cpu, sd) {
                for_each_cpu(i, sched_domain_span(sd)) {
index 8e503fec1fbaa59b1ec4e7ed413cafb58dfe9f58..1d35ddadc045753a2b13bc9017eaef38abc89383 100644 (file)
@@ -760,12 +760,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires,
 
        debug_activate(timer, expires);
 
-       cpu = smp_processor_id();
-
-#if defined(CONFIG_NO_HZ_COMMON) && defined(CONFIG_SMP)
-       if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu))
-               cpu = get_nohz_timer_target();
-#endif
+       cpu = get_nohz_timer_target(pinned);
        new_base = per_cpu(tvec_bases, cpu);
 
        if (base != new_base) {