aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/tick-sched.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2013-08-07 16:28:01 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2013-12-02 14:39:30 -0500
commite8fcaa5c54e3b0371230e5d43a6f650c667da9c5 (patch)
tree966d06c71bc79809ca34675b023602aefc8e578d /kernel/time/tick-sched.c
parentdc1ccc48159d63eca5089e507c82c7d22ef60839 (diff)
nohz: Convert a few places to use local per cpu accesses
A few functions use remote per CPU access APIs when they deal with local values. Just do the right conversion to improve performance, code readability and debug checks. While at it, lets extend some of these function names with *_this_cpu() suffix in order to display their purpose more clearly. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/time/tick-sched.c')
-rw-r--r--kernel/time/tick-sched.c39
1 files changed, 16 insertions, 23 deletions
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/*