aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/tick.h6
-rw-r--r--kernel/softirq.c4
-rw-r--r--kernel/time/tick-broadcast.c6
-rw-r--r--kernel/time/tick-internal.h4
-rw-r--r--kernel/time/tick-sched.c39
5 files changed, 25 insertions, 34 deletions
diff --git a/include/linux/tick.h b/include/linux/tick.h
index 5128d33bbb39..a004f66a6cf0 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -104,7 +104,7 @@ extern struct cpumask *tick_get_broadcast_oneshot_mask(void);
104extern void tick_clock_notify(void); 104extern void tick_clock_notify(void);
105extern int tick_check_oneshot_change(int allow_nohz); 105extern int tick_check_oneshot_change(int allow_nohz);
106extern struct tick_sched *tick_get_tick_sched(int cpu); 106extern struct tick_sched *tick_get_tick_sched(int cpu);
107extern void tick_check_idle(int cpu); 107extern void tick_check_idle(void);
108extern int tick_oneshot_mode_active(void); 108extern int tick_oneshot_mode_active(void);
109# ifndef arch_needs_cpu 109# ifndef arch_needs_cpu
110# define arch_needs_cpu(cpu) (0) 110# define arch_needs_cpu(cpu) (0)
@@ -112,7 +112,7 @@ extern int tick_oneshot_mode_active(void);
112# else 112# else
113static inline void tick_clock_notify(void) { } 113static inline void tick_clock_notify(void) { }
114static inline int tick_check_oneshot_change(int allow_nohz) { return 0; } 114static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
115static inline void tick_check_idle(int cpu) { } 115static inline void tick_check_idle(void) { }
116static inline int tick_oneshot_mode_active(void) { return 0; } 116static inline int tick_oneshot_mode_active(void) { return 0; }
117# endif 117# endif
118 118
@@ -121,7 +121,7 @@ static inline void tick_init(void) { }
121static inline void tick_cancel_sched_timer(int cpu) { } 121static inline void tick_cancel_sched_timer(int cpu) { }
122static inline void tick_clock_notify(void) { } 122static inline void tick_clock_notify(void) { }
123static inline int tick_check_oneshot_change(int allow_nohz) { return 0; } 123static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
124static inline void tick_check_idle(int cpu) { } 124static inline void tick_check_idle(void) { }
125static inline int tick_oneshot_mode_active(void) { return 0; } 125static inline int tick_oneshot_mode_active(void) { return 0; }
126#endif /* !CONFIG_GENERIC_CLOCKEVENTS */ 126#endif /* !CONFIG_GENERIC_CLOCKEVENTS */
127 127
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 11025ccc06dd..11348de09400 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -311,8 +311,6 @@ asmlinkage void do_softirq(void)
311 */ 311 */
312void irq_enter(void) 312void irq_enter(void)
313{ 313{
314 int cpu = smp_processor_id();
315
316 rcu_irq_enter(); 314 rcu_irq_enter();
317 if (is_idle_task(current) && !in_interrupt()) { 315 if (is_idle_task(current) && !in_interrupt()) {
318 /* 316 /*
@@ -320,7 +318,7 @@ void irq_enter(void)
320 * here, as softirq will be serviced on return from interrupt. 318 * here, as softirq will be serviced on return from interrupt.
321 */ 319 */
322 local_bh_disable(); 320 local_bh_disable();
323 tick_check_idle(cpu); 321 tick_check_idle();
324 _local_bh_enable(); 322 _local_bh_enable();
325 } 323 }
326 324
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 9532690daaa9..43780ab5e279 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -538,10 +538,10 @@ int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
538 * Called from irq_enter() when idle was interrupted to reenable the 538 * Called from irq_enter() when idle was interrupted to reenable the
539 * per cpu device. 539 * per cpu device.
540 */ 540 */
541void tick_check_oneshot_broadcast(int cpu) 541void tick_check_oneshot_broadcast_this_cpu(void)
542{ 542{
543 if (cpumask_test_cpu(cpu, tick_broadcast_oneshot_mask)) { 543 if (cpumask_test_cpu(smp_processor_id(), tick_broadcast_oneshot_mask)) {
544 struct tick_device *td = &per_cpu(tick_cpu_device, cpu); 544 struct tick_device *td = &__get_cpu_var(tick_cpu_device);
545 545
546 /* 546 /*
547 * We might be in the middle of switching over from 547 * We might be in the middle of switching over from
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index 18e71f7fbc2a..e2bced59b6dd 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -51,7 +51,7 @@ extern void tick_broadcast_switch_to_oneshot(void);
51extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup); 51extern void tick_shutdown_broadcast_oneshot(unsigned int *cpup);
52extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc); 52extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc);
53extern int tick_broadcast_oneshot_active(void); 53extern int tick_broadcast_oneshot_active(void);
54extern void tick_check_oneshot_broadcast(int cpu); 54extern void tick_check_oneshot_broadcast_this_cpu(void);
55bool tick_broadcast_oneshot_available(void); 55bool tick_broadcast_oneshot_available(void);
56# else /* BROADCAST */ 56# else /* BROADCAST */
57static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) 57static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
@@ -62,7 +62,7 @@ static inline void tick_broadcast_oneshot_control(unsigned long reason) { }
62static inline void tick_broadcast_switch_to_oneshot(void) { } 62static inline void tick_broadcast_switch_to_oneshot(void) { }
63static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } 63static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { }
64static inline int tick_broadcast_oneshot_active(void) { return 0; } 64static inline int tick_broadcast_oneshot_active(void) { return 0; }
65static inline void tick_check_oneshot_broadcast(int cpu) { } 65static inline void tick_check_oneshot_broadcast_this_cpu(void) { }
66static inline bool tick_broadcast_oneshot_available(void) { return true; } 66static inline bool tick_broadcast_oneshot_available(void) { return true; }
67# endif /* !BROADCAST */ 67# endif /* !BROADCAST */
68 68
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 3612fc77f834..2afd43fca93b 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -391,11 +391,9 @@ __setup("nohz=", setup_tick_nohz);
391 */ 391 */
392static void tick_nohz_update_jiffies(ktime_t now) 392static void tick_nohz_update_jiffies(ktime_t now)
393{ 393{
394 int cpu = smp_processor_id();
395 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
396 unsigned long flags; 394 unsigned long flags;
397 395
398 ts->idle_waketime = now; 396 __this_cpu_write(tick_cpu_sched.idle_waketime, now);
399 397
400 local_irq_save(flags); 398 local_irq_save(flags);
401 tick_do_update_jiffies64(now); 399 tick_do_update_jiffies64(now);
@@ -426,17 +424,15 @@ update_ts_time_stats(int cpu, struct tick_sched *ts, ktime_t now, u64 *last_upda
426 424
427} 425}
428 426
429static void tick_nohz_stop_idle(int cpu, ktime_t now) 427static void tick_nohz_stop_idle(struct tick_sched *ts, ktime_t now)
430{ 428{
431 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); 429 update_ts_time_stats(smp_processor_id(), ts, now, NULL);
432
433 update_ts_time_stats(cpu, ts, now, NULL);
434 ts->idle_active = 0; 430 ts->idle_active = 0;
435 431
436 sched_clock_idle_wakeup_event(0); 432 sched_clock_idle_wakeup_event(0);
437} 433}
438 434
439static ktime_t tick_nohz_start_idle(int cpu, struct tick_sched *ts) 435static ktime_t tick_nohz_start_idle(struct tick_sched *ts)
440{ 436{
441 ktime_t now = ktime_get(); 437 ktime_t now = ktime_get();
442 438
@@ -752,7 +748,7 @@ static void __tick_nohz_idle_enter(struct tick_sched *ts)
752 ktime_t now, expires; 748 ktime_t now, expires;
753 int cpu = smp_processor_id(); 749 int cpu = smp_processor_id();
754 750
755 now = tick_nohz_start_idle(cpu, ts); 751 now = tick_nohz_start_idle(ts);
756 752
757 if (can_stop_idle_tick(cpu, ts)) { 753 if (can_stop_idle_tick(cpu, ts)) {
758 int was_stopped = ts->tick_stopped; 754 int was_stopped = ts->tick_stopped;
@@ -914,8 +910,7 @@ static void tick_nohz_account_idle_ticks(struct tick_sched *ts)
914 */ 910 */
915void tick_nohz_idle_exit(void) 911void tick_nohz_idle_exit(void)
916{ 912{
917 int cpu = smp_processor_id(); 913 struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
918 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
919 ktime_t now; 914 ktime_t now;
920 915
921 local_irq_disable(); 916 local_irq_disable();
@@ -928,7 +923,7 @@ void tick_nohz_idle_exit(void)
928 now = ktime_get(); 923 now = ktime_get();
929 924
930 if (ts->idle_active) 925 if (ts->idle_active)
931 tick_nohz_stop_idle(cpu, now); 926 tick_nohz_stop_idle(ts, now);
932 927
933 if (ts->tick_stopped) { 928 if (ts->tick_stopped) {
934 tick_nohz_restart_sched_tick(ts, now); 929 tick_nohz_restart_sched_tick(ts, now);
@@ -1012,12 +1007,10 @@ static void tick_nohz_switch_to_nohz(void)
1012 * timer and do not touch the other magic bits which need to be done 1007 * timer and do not touch the other magic bits which need to be done
1013 * when idle is left. 1008 * when idle is left.
1014 */ 1009 */
1015static void tick_nohz_kick_tick(int cpu, ktime_t now) 1010static void tick_nohz_kick_tick(struct tick_sched *ts, ktime_t now)
1016{ 1011{
1017#if 0 1012#if 0
1018 /* Switch back to 2.6.27 behaviour */ 1013 /* Switch back to 2.6.27 behaviour */
1019
1020 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
1021 ktime_t delta; 1014 ktime_t delta;
1022 1015
1023 /* 1016 /*
@@ -1032,36 +1025,36 @@ static void tick_nohz_kick_tick(int cpu, ktime_t now)
1032#endif 1025#endif
1033} 1026}
1034 1027
1035static inline void tick_check_nohz(int cpu) 1028static inline void tick_check_nohz_this_cpu(void)
1036{ 1029{
1037 struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); 1030 struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
1038 ktime_t now; 1031 ktime_t now;
1039 1032
1040 if (!ts->idle_active && !ts->tick_stopped) 1033 if (!ts->idle_active && !ts->tick_stopped)
1041 return; 1034 return;
1042 now = ktime_get(); 1035 now = ktime_get();
1043 if (ts->idle_active) 1036 if (ts->idle_active)
1044 tick_nohz_stop_idle(cpu, now); 1037 tick_nohz_stop_idle(ts, now);
1045 if (ts->tick_stopped) { 1038 if (ts->tick_stopped) {
1046 tick_nohz_update_jiffies(now); 1039 tick_nohz_update_jiffies(now);
1047 tick_nohz_kick_tick(cpu, now); 1040 tick_nohz_kick_tick(ts, now);
1048 } 1041 }
1049} 1042}
1050 1043
1051#else 1044#else
1052 1045
1053static inline void tick_nohz_switch_to_nohz(void) { } 1046static inline void tick_nohz_switch_to_nohz(void) { }
1054static inline void tick_check_nohz(int cpu) { } 1047static inline void tick_check_nohz_this_cpu(void) { }
1055 1048
1056#endif /* CONFIG_NO_HZ_COMMON */ 1049#endif /* CONFIG_NO_HZ_COMMON */
1057 1050
1058/* 1051/*
1059 * Called from irq_enter to notify about the possible interruption of idle() 1052 * Called from irq_enter to notify about the possible interruption of idle()
1060 */ 1053 */
1061void tick_check_idle(int cpu) 1054void tick_check_idle(void)
1062{ 1055{
1063 tick_check_oneshot_broadcast(cpu); 1056 tick_check_oneshot_broadcast_this_cpu();
1064 tick_check_nohz(cpu); 1057 tick_check_nohz_this_cpu();
1065} 1058}
1066 1059
1067/* 1060/*