diff options
-rw-r--r-- | include/linux/sched.h | 6 | ||||
-rw-r--r-- | kernel/hrtimer.c | 15 | ||||
-rw-r--r-- | kernel/sched/core.c | 5 | ||||
-rw-r--r-- | kernel/timer.c | 7 |
4 files changed, 11 insertions, 22 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 68a0e84463a0..6f6c56f63c68 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -291,10 +291,14 @@ extern int runqueue_is_locked(int cpu); | |||
291 | #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) | 291 | #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) |
292 | extern void nohz_balance_enter_idle(int cpu); | 292 | extern void nohz_balance_enter_idle(int cpu); |
293 | extern void set_cpu_sd_state_idle(void); | 293 | extern void set_cpu_sd_state_idle(void); |
294 | extern int get_nohz_timer_target(void); | 294 | extern int get_nohz_timer_target(int pinned); |
295 | #else | 295 | #else |
296 | static inline void nohz_balance_enter_idle(int cpu) { } | 296 | static inline void nohz_balance_enter_idle(int cpu) { } |
297 | static inline void set_cpu_sd_state_idle(void) { } | 297 | static inline void set_cpu_sd_state_idle(void) { } |
298 | static inline int get_nohz_timer_target(int pinned) | ||
299 | { | ||
300 | return smp_processor_id(); | ||
301 | } | ||
298 | #endif | 302 | #endif |
299 | 303 | ||
300 | /* | 304 | /* |
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 09094361dce5..d55092ceee29 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -168,19 +168,6 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer, | |||
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | |||
172 | /* | ||
173 | * Get the preferred target CPU for NOHZ | ||
174 | */ | ||
175 | static int hrtimer_get_target(int this_cpu, int pinned) | ||
176 | { | ||
177 | #ifdef CONFIG_NO_HZ_COMMON | ||
178 | if (!pinned && get_sysctl_timer_migration() && idle_cpu(this_cpu)) | ||
179 | return get_nohz_timer_target(); | ||
180 | #endif | ||
181 | return this_cpu; | ||
182 | } | ||
183 | |||
184 | /* | 171 | /* |
185 | * With HIGHRES=y we do not migrate the timer when it is expiring | 172 | * With HIGHRES=y we do not migrate the timer when it is expiring |
186 | * before the next event on the target cpu because we cannot reprogram | 173 | * 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, | |||
214 | struct hrtimer_clock_base *new_base; | 201 | struct hrtimer_clock_base *new_base; |
215 | struct hrtimer_cpu_base *new_cpu_base; | 202 | struct hrtimer_cpu_base *new_cpu_base; |
216 | int this_cpu = smp_processor_id(); | 203 | int this_cpu = smp_processor_id(); |
217 | int cpu = hrtimer_get_target(this_cpu, pinned); | 204 | int cpu = get_nohz_timer_target(pinned); |
218 | int basenum = base->index; | 205 | int basenum = base->index; |
219 | 206 | ||
220 | again: | 207 | again: |
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b46131ef6aab..c0339e206cc2 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -555,12 +555,15 @@ void resched_cpu(int cpu) | |||
555 | * selecting an idle cpu will add more delays to the timers than intended | 555 | * selecting an idle cpu will add more delays to the timers than intended |
556 | * (as that cpu's timer base may not be uptodate wrt jiffies etc). | 556 | * (as that cpu's timer base may not be uptodate wrt jiffies etc). |
557 | */ | 557 | */ |
558 | int get_nohz_timer_target(void) | 558 | int get_nohz_timer_target(int pinned) |
559 | { | 559 | { |
560 | int cpu = smp_processor_id(); | 560 | int cpu = smp_processor_id(); |
561 | int i; | 561 | int i; |
562 | struct sched_domain *sd; | 562 | struct sched_domain *sd; |
563 | 563 | ||
564 | if (pinned || !get_sysctl_timer_migration() || !idle_cpu(cpu)) | ||
565 | return cpu; | ||
566 | |||
564 | rcu_read_lock(); | 567 | rcu_read_lock(); |
565 | for_each_domain(cpu, sd) { | 568 | for_each_domain(cpu, sd) { |
566 | for_each_cpu(i, sched_domain_span(sd)) { | 569 | for_each_cpu(i, sched_domain_span(sd)) { |
diff --git a/kernel/timer.c b/kernel/timer.c index 8e503fec1fba..1d35ddadc045 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -760,12 +760,7 @@ __mod_timer(struct timer_list *timer, unsigned long expires, | |||
760 | 760 | ||
761 | debug_activate(timer, expires); | 761 | debug_activate(timer, expires); |
762 | 762 | ||
763 | cpu = smp_processor_id(); | 763 | cpu = get_nohz_timer_target(pinned); |
764 | |||
765 | #if defined(CONFIG_NO_HZ_COMMON) && defined(CONFIG_SMP) | ||
766 | if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) | ||
767 | cpu = get_nohz_timer_target(); | ||
768 | #endif | ||
769 | new_base = per_cpu(tvec_bases, cpu); | 764 | new_base = per_cpu(tvec_bases, cpu); |
770 | 765 | ||
771 | if (base != new_base) { | 766 | if (base != new_base) { |