diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-12 09:17:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-12 09:17:48 -0400 |
commit | 03d3602a833715f83ea53b9feb078b9c4c5f6c1a (patch) | |
tree | 7b63ec6753dd65e61392017e1aba2ee1e6b4bcd1 /arch/x86 | |
parent | 0588f1f934791b79d0a1e9b327be9b6eb361d2b8 (diff) | |
parent | 5b3900cd409466c0070b234d941650685ad0c791 (diff) |
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer core update from Thomas Gleixner:
- Bug fixes (one for a longstanding dead loop issue)
- Rework of time related vsyscalls
- Alarm timer updates
- Jiffies updates to remove compile time dependencies
* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
timekeeping: Cast raw_interval to u64 to avoid shift overflow
timers: Fix endless looping between cascade() and internal_add_timer()
time/jiffies: bring back unconditional LATCH definition
time: Convert x86_64 to using new update_vsyscall
time: Only do nanosecond rounding on GENERIC_TIME_VSYSCALL_OLD systems
time: Introduce new GENERIC_TIME_VSYSCALL
time: Convert CONFIG_GENERIC_TIME_VSYSCALL to CONFIG_GENERIC_TIME_VSYSCALL_OLD
time: Move update_vsyscall definitions to timekeeper_internal.h
time: Move timekeeper structure to timekeeper_internal.h for vsyscall changes
jiffies: Remove compile time assumptions about CLOCK_TICK_RATE
jiffies: Kill unused TICK_USEC_TO_NSEC
alarmtimer: Rename alarmtimer_remove to alarmtimer_dequeue
alarmtimer: Remove unused helpers & defines
alarmtimer: Use hrtimer per-alarm instead of per-base
alarmtimer: Implement minimum alarm interval for allowing suspend
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/vgtod.h | 4 | ||||
-rw-r--r-- | arch/x86/kernel/setup.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/vsyscall_64.c | 49 | ||||
-rw-r--r-- | arch/x86/vdso/vclock_gettime.c | 22 |
4 files changed, 48 insertions, 30 deletions
diff --git a/arch/x86/include/asm/vgtod.h b/arch/x86/include/asm/vgtod.h index 8b38be2de9e..46e24d36b7d 100644 --- a/arch/x86/include/asm/vgtod.h +++ b/arch/x86/include/asm/vgtod.h | |||
@@ -17,8 +17,8 @@ struct vsyscall_gtod_data { | |||
17 | 17 | ||
18 | /* open coded 'struct timespec' */ | 18 | /* open coded 'struct timespec' */ |
19 | time_t wall_time_sec; | 19 | time_t wall_time_sec; |
20 | u32 wall_time_nsec; | 20 | u64 wall_time_snsec; |
21 | u32 monotonic_time_nsec; | 21 | u64 monotonic_time_snsec; |
22 | time_t monotonic_time_sec; | 22 | time_t monotonic_time_sec; |
23 | 23 | ||
24 | struct timezone sys_tz; | 24 | struct timezone sys_tz; |
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index d609be046b5..a2bb18e0283 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -68,6 +68,7 @@ | |||
68 | #include <linux/percpu.h> | 68 | #include <linux/percpu.h> |
69 | #include <linux/crash_dump.h> | 69 | #include <linux/crash_dump.h> |
70 | #include <linux/tboot.h> | 70 | #include <linux/tboot.h> |
71 | #include <linux/jiffies.h> | ||
71 | 72 | ||
72 | #include <video/edid.h> | 73 | #include <video/edid.h> |
73 | 74 | ||
@@ -1032,6 +1033,8 @@ void __init setup_arch(char **cmdline_p) | |||
1032 | mcheck_init(); | 1033 | mcheck_init(); |
1033 | 1034 | ||
1034 | arch_init_ideal_nops(); | 1035 | arch_init_ideal_nops(); |
1036 | |||
1037 | register_refined_jiffies(CLOCK_TICK_RATE); | ||
1035 | } | 1038 | } |
1036 | 1039 | ||
1037 | #ifdef CONFIG_X86_32 | 1040 | #ifdef CONFIG_X86_32 |
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c index 8d141b30904..3a3e8c9e280 100644 --- a/arch/x86/kernel/vsyscall_64.c +++ b/arch/x86/kernel/vsyscall_64.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/jiffies.h> | 28 | #include <linux/jiffies.h> |
29 | #include <linux/sysctl.h> | 29 | #include <linux/sysctl.h> |
30 | #include <linux/topology.h> | 30 | #include <linux/topology.h> |
31 | #include <linux/clocksource.h> | 31 | #include <linux/timekeeper_internal.h> |
32 | #include <linux/getcpu.h> | 32 | #include <linux/getcpu.h> |
33 | #include <linux/cpu.h> | 33 | #include <linux/cpu.h> |
34 | #include <linux/smp.h> | 34 | #include <linux/smp.h> |
@@ -82,32 +82,41 @@ void update_vsyscall_tz(void) | |||
82 | vsyscall_gtod_data.sys_tz = sys_tz; | 82 | vsyscall_gtod_data.sys_tz = sys_tz; |
83 | } | 83 | } |
84 | 84 | ||
85 | void update_vsyscall(struct timespec *wall_time, struct timespec *wtm, | 85 | void update_vsyscall(struct timekeeper *tk) |
86 | struct clocksource *clock, u32 mult) | ||
87 | { | 86 | { |
88 | struct timespec monotonic; | 87 | struct vsyscall_gtod_data *vdata = &vsyscall_gtod_data; |
89 | 88 | ||
90 | write_seqcount_begin(&vsyscall_gtod_data.seq); | 89 | write_seqcount_begin(&vdata->seq); |
91 | 90 | ||
92 | /* copy vsyscall data */ | 91 | /* copy vsyscall data */ |
93 | vsyscall_gtod_data.clock.vclock_mode = clock->archdata.vclock_mode; | 92 | vdata->clock.vclock_mode = tk->clock->archdata.vclock_mode; |
94 | vsyscall_gtod_data.clock.cycle_last = clock->cycle_last; | 93 | vdata->clock.cycle_last = tk->clock->cycle_last; |
95 | vsyscall_gtod_data.clock.mask = clock->mask; | 94 | vdata->clock.mask = tk->clock->mask; |
96 | vsyscall_gtod_data.clock.mult = mult; | 95 | vdata->clock.mult = tk->mult; |
97 | vsyscall_gtod_data.clock.shift = clock->shift; | 96 | vdata->clock.shift = tk->shift; |
98 | 97 | ||
99 | vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec; | 98 | vdata->wall_time_sec = tk->xtime_sec; |
100 | vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec; | 99 | vdata->wall_time_snsec = tk->xtime_nsec; |
100 | |||
101 | vdata->monotonic_time_sec = tk->xtime_sec | ||
102 | + tk->wall_to_monotonic.tv_sec; | ||
103 | vdata->monotonic_time_snsec = tk->xtime_nsec | ||
104 | + (tk->wall_to_monotonic.tv_nsec | ||
105 | << tk->shift); | ||
106 | while (vdata->monotonic_time_snsec >= | ||
107 | (((u64)NSEC_PER_SEC) << tk->shift)) { | ||
108 | vdata->monotonic_time_snsec -= | ||
109 | ((u64)NSEC_PER_SEC) << tk->shift; | ||
110 | vdata->monotonic_time_sec++; | ||
111 | } | ||
101 | 112 | ||
102 | monotonic = timespec_add(*wall_time, *wtm); | 113 | vdata->wall_time_coarse.tv_sec = tk->xtime_sec; |
103 | vsyscall_gtod_data.monotonic_time_sec = monotonic.tv_sec; | 114 | vdata->wall_time_coarse.tv_nsec = (long)(tk->xtime_nsec >> tk->shift); |
104 | vsyscall_gtod_data.monotonic_time_nsec = monotonic.tv_nsec; | ||
105 | 115 | ||
106 | vsyscall_gtod_data.wall_time_coarse = __current_kernel_time(); | 116 | vdata->monotonic_time_coarse = timespec_add(vdata->wall_time_coarse, |
107 | vsyscall_gtod_data.monotonic_time_coarse = | 117 | tk->wall_to_monotonic); |
108 | timespec_add(vsyscall_gtod_data.wall_time_coarse, *wtm); | ||
109 | 118 | ||
110 | write_seqcount_end(&vsyscall_gtod_data.seq); | 119 | write_seqcount_end(&vdata->seq); |
111 | } | 120 | } |
112 | 121 | ||
113 | static void warn_bad_vsyscall(const char *level, struct pt_regs *regs, | 122 | static void warn_bad_vsyscall(const char *level, struct pt_regs *regs, |
diff --git a/arch/x86/vdso/vclock_gettime.c b/arch/x86/vdso/vclock_gettime.c index 885eff49d6a..4df6c373421 100644 --- a/arch/x86/vdso/vclock_gettime.c +++ b/arch/x86/vdso/vclock_gettime.c | |||
@@ -80,7 +80,7 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | notrace static inline long vgetns(void) | 83 | notrace static inline u64 vgetsns(void) |
84 | { | 84 | { |
85 | long v; | 85 | long v; |
86 | cycles_t cycles; | 86 | cycles_t cycles; |
@@ -91,21 +91,24 @@ notrace static inline long vgetns(void) | |||
91 | else | 91 | else |
92 | return 0; | 92 | return 0; |
93 | v = (cycles - gtod->clock.cycle_last) & gtod->clock.mask; | 93 | v = (cycles - gtod->clock.cycle_last) & gtod->clock.mask; |
94 | return (v * gtod->clock.mult) >> gtod->clock.shift; | 94 | return v * gtod->clock.mult; |
95 | } | 95 | } |
96 | 96 | ||
97 | /* Code size doesn't matter (vdso is 4k anyway) and this is faster. */ | 97 | /* Code size doesn't matter (vdso is 4k anyway) and this is faster. */ |
98 | notrace static int __always_inline do_realtime(struct timespec *ts) | 98 | notrace static int __always_inline do_realtime(struct timespec *ts) |
99 | { | 99 | { |
100 | unsigned long seq, ns; | 100 | unsigned long seq; |
101 | u64 ns; | ||
101 | int mode; | 102 | int mode; |
102 | 103 | ||
104 | ts->tv_nsec = 0; | ||
103 | do { | 105 | do { |
104 | seq = read_seqcount_begin(>od->seq); | 106 | seq = read_seqcount_begin(>od->seq); |
105 | mode = gtod->clock.vclock_mode; | 107 | mode = gtod->clock.vclock_mode; |
106 | ts->tv_sec = gtod->wall_time_sec; | 108 | ts->tv_sec = gtod->wall_time_sec; |
107 | ts->tv_nsec = gtod->wall_time_nsec; | 109 | ns = gtod->wall_time_snsec; |
108 | ns = vgetns(); | 110 | ns += vgetsns(); |
111 | ns >>= gtod->clock.shift; | ||
109 | } while (unlikely(read_seqcount_retry(>od->seq, seq))); | 112 | } while (unlikely(read_seqcount_retry(>od->seq, seq))); |
110 | 113 | ||
111 | timespec_add_ns(ts, ns); | 114 | timespec_add_ns(ts, ns); |
@@ -114,15 +117,18 @@ notrace static int __always_inline do_realtime(struct timespec *ts) | |||
114 | 117 | ||
115 | notrace static int do_monotonic(struct timespec *ts) | 118 | notrace static int do_monotonic(struct timespec *ts) |
116 | { | 119 | { |
117 | unsigned long seq, ns; | 120 | unsigned long seq; |
121 | u64 ns; | ||
118 | int mode; | 122 | int mode; |
119 | 123 | ||
124 | ts->tv_nsec = 0; | ||
120 | do { | 125 | do { |
121 | seq = read_seqcount_begin(>od->seq); | 126 | seq = read_seqcount_begin(>od->seq); |
122 | mode = gtod->clock.vclock_mode; | 127 | mode = gtod->clock.vclock_mode; |
123 | ts->tv_sec = gtod->monotonic_time_sec; | 128 | ts->tv_sec = gtod->monotonic_time_sec; |
124 | ts->tv_nsec = gtod->monotonic_time_nsec; | 129 | ns = gtod->monotonic_time_snsec; |
125 | ns = vgetns(); | 130 | ns += vgetsns(); |
131 | ns >>= gtod->clock.shift; | ||
126 | } while (unlikely(read_seqcount_retry(>od->seq, seq))); | 132 | } while (unlikely(read_seqcount_retry(>od->seq, seq))); |
127 | timespec_add_ns(ts, ns); | 133 | timespec_add_ns(ts, ns); |
128 | 134 | ||