diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-05 20:46:42 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-05 20:46:42 -0400 |
| commit | e7fda6c4c3c1a7d6996dd75fd84670fa0b5d448f (patch) | |
| tree | daa51c16462c318b890acf7f01fba5827275dd74 /kernel/time | |
| parent | 08d69a25714429850cf9ef71f22d8cdc9189d93f (diff) | |
| parent | 953dec21aed4038464fec02f96a2f1b8701a5bce (diff) | |
Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer and time updates from Thomas Gleixner:
"A rather large update of timers, timekeeping & co
- Core timekeeping code is year-2038 safe now for 32bit machines.
Now we just need to fix all in kernel users and the gazillion of
user space interfaces which rely on timespec/timeval :)
- Better cache layout for the timekeeping internal data structures.
- Proper nanosecond based interfaces for in kernel users.
- Tree wide cleanup of code which wants nanoseconds but does hoops
and loops to convert back and forth from timespecs. Some of it
definitely belongs into the ugly code museum.
- Consolidation of the timekeeping interface zoo.
- A fast NMI safe accessor to clock monotonic for tracing. This is a
long standing request to support correlated user/kernel space
traces. With proper NTP frequency correction it's also suitable
for correlation of traces accross separate machines.
- Checkpoint/restart support for timerfd.
- A few NOHZ[_FULL] improvements in the [hr]timer code.
- Code move from kernel to kernel/time of all time* related code.
- New clocksource/event drivers from the ARM universe. I'm really
impressed that despite an architected timer in the newer chips SoC
manufacturers insist on inventing new and differently broken SoC
specific timers.
[ Ed. "Impressed"? I don't think that word means what you think it means ]
- Another round of code move from arch to drivers. Looks like most
of the legacy mess in ARM regarding timers is sorted out except for
a few obnoxious strongholds.
- The usual updates and fixlets all over the place"
* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (114 commits)
timekeeping: Fixup typo in update_vsyscall_old definition
clocksource: document some basic timekeeping concepts
timekeeping: Use cached ntp_tick_length when accumulating error
timekeeping: Rework frequency adjustments to work better w/ nohz
timekeeping: Minor fixup for timespec64->timespec assignment
ftrace: Provide trace clocks monotonic
timekeeping: Provide fast and NMI safe access to CLOCK_MONOTONIC
seqcount: Add raw_write_seqcount_latch()
seqcount: Provide raw_read_seqcount()
timekeeping: Use tk_read_base as argument for timekeeping_get_ns()
timekeeping: Create struct tk_read_base and use it in struct timekeeper
timekeeping: Restructure the timekeeper some more
clocksource: Get rid of cycle_last
clocksource: Move cycle_last validation to core code
clocksource: Make delta calculation a function
wireless: ath9k: Get rid of timespec conversions
drm: vmwgfx: Use nsec based interfaces
drm: i915: Use nsec based interfaces
timekeeping: Provide ktime_get_raw()
hangcheck-timer: Use ktime_get_ns()
...
Diffstat (limited to 'kernel/time')
| -rw-r--r-- | kernel/time/Kconfig | 9 | ||||
| -rw-r--r-- | kernel/time/Makefile | 19 | ||||
| -rw-r--r-- | kernel/time/clocksource.c | 12 | ||||
| -rw-r--r-- | kernel/time/hrtimer.c | 1866 | ||||
| -rw-r--r-- | kernel/time/itimer.c | 301 | ||||
| -rw-r--r-- | kernel/time/ntp.c | 15 | ||||
| -rw-r--r-- | kernel/time/ntp_internal.h | 2 | ||||
| -rw-r--r-- | kernel/time/posix-cpu-timers.c | 1490 | ||||
| -rw-r--r-- | kernel/time/posix-timers.c | 1123 | ||||
| -rw-r--r-- | kernel/time/tick-internal.h | 2 | ||||
| -rw-r--r-- | kernel/time/time.c | 778 | ||||
| -rw-r--r-- | kernel/time/timeconst.bc | 108 | ||||
| -rw-r--r-- | kernel/time/timekeeping.c | 1147 | ||||
| -rw-r--r-- | kernel/time/timekeeping.h | 20 | ||||
| -rw-r--r-- | kernel/time/timekeeping_debug.c | 2 | ||||
| -rw-r--r-- | kernel/time/timekeeping_internal.h | 17 | ||||
| -rw-r--r-- | kernel/time/timer.c | 1736 | ||||
| -rw-r--r-- | kernel/time/udelay_test.c | 168 |
18 files changed, 8260 insertions, 555 deletions
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index f448513a45ed..d626dc98e8df 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig | |||
| @@ -12,6 +12,11 @@ config CLOCKSOURCE_WATCHDOG | |||
| 12 | config ARCH_CLOCKSOURCE_DATA | 12 | config ARCH_CLOCKSOURCE_DATA |
| 13 | bool | 13 | bool |
| 14 | 14 | ||
| 15 | # Clocksources require validation of the clocksource against the last | ||
| 16 | # cycle update - x86/TSC misfeature | ||
| 17 | config CLOCKSOURCE_VALIDATE_LAST_CYCLE | ||
| 18 | bool | ||
| 19 | |||
| 15 | # Timekeeping vsyscall support | 20 | # Timekeeping vsyscall support |
| 16 | config GENERIC_TIME_VSYSCALL | 21 | config GENERIC_TIME_VSYSCALL |
| 17 | bool | 22 | bool |
| @@ -20,10 +25,6 @@ config GENERIC_TIME_VSYSCALL | |||
| 20 | config GENERIC_TIME_VSYSCALL_OLD | 25 | config GENERIC_TIME_VSYSCALL_OLD |
| 21 | bool | 26 | bool |
| 22 | 27 | ||
| 23 | # ktime_t scalar 64bit nsec representation | ||
| 24 | config KTIME_SCALAR | ||
| 25 | bool | ||
| 26 | |||
| 27 | # Old style timekeeping | 28 | # Old style timekeeping |
| 28 | config ARCH_USES_GETTIMEOFFSET | 29 | config ARCH_USES_GETTIMEOFFSET |
| 29 | bool | 30 | bool |
diff --git a/kernel/time/Makefile b/kernel/time/Makefile index 57a413fd0ebf..7347426fa68d 100644 --- a/kernel/time/Makefile +++ b/kernel/time/Makefile | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | obj-y += time.o timer.o hrtimer.o itimer.o posix-timers.o posix-cpu-timers.o | ||
| 1 | obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o | 2 | obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o |
| 2 | obj-y += timeconv.o posix-clock.o alarmtimer.o | 3 | obj-y += timeconv.o posix-clock.o alarmtimer.o |
| 3 | 4 | ||
| @@ -12,3 +13,21 @@ obj-$(CONFIG_TICK_ONESHOT) += tick-oneshot.o | |||
| 12 | obj-$(CONFIG_TICK_ONESHOT) += tick-sched.o | 13 | obj-$(CONFIG_TICK_ONESHOT) += tick-sched.o |
| 13 | obj-$(CONFIG_TIMER_STATS) += timer_stats.o | 14 | obj-$(CONFIG_TIMER_STATS) += timer_stats.o |
| 14 | obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o | 15 | obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o |
| 16 | obj-$(CONFIG_TEST_UDELAY) += udelay_test.o | ||
| 17 | |||
| 18 | $(obj)/time.o: $(obj)/timeconst.h | ||
| 19 | |||
| 20 | quiet_cmd_hzfile = HZFILE $@ | ||
| 21 | cmd_hzfile = echo "hz=$(CONFIG_HZ)" > $@ | ||
| 22 | |||
| 23 | targets += hz.bc | ||
| 24 | $(obj)/hz.bc: $(objtree)/include/config/hz.h FORCE | ||
| 25 | $(call if_changed,hzfile) | ||
| 26 | |||
| 27 | quiet_cmd_bc = BC $@ | ||
| 28 | cmd_bc = bc -q $(filter-out FORCE,$^) > $@ | ||
| 29 | |||
| 30 | targets += timeconst.h | ||
| 31 | $(obj)/timeconst.h: $(obj)/hz.bc $(src)/timeconst.bc FORCE | ||
| 32 | $(call if_changed,bc) | ||
| 33 | |||
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index ba3e502c955a..2e949cc9c9f1 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include <linux/kthread.h> | 32 | #include <linux/kthread.h> |
| 33 | 33 | ||
| 34 | #include "tick-internal.h" | 34 | #include "tick-internal.h" |
| 35 | #include "timekeeping_internal.h" | ||
| 35 | 36 | ||
| 36 | void timecounter_init(struct timecounter *tc, | 37 | void timecounter_init(struct timecounter *tc, |
| 37 | const struct cyclecounter *cc, | 38 | const struct cyclecounter *cc, |
| @@ -249,7 +250,7 @@ void clocksource_mark_unstable(struct clocksource *cs) | |||
| 249 | static void clocksource_watchdog(unsigned long data) | 250 | static void clocksource_watchdog(unsigned long data) |
| 250 | { | 251 | { |
| 251 | struct clocksource *cs; | 252 | struct clocksource *cs; |
| 252 | cycle_t csnow, wdnow; | 253 | cycle_t csnow, wdnow, delta; |
| 253 | int64_t wd_nsec, cs_nsec; | 254 | int64_t wd_nsec, cs_nsec; |
| 254 | int next_cpu, reset_pending; | 255 | int next_cpu, reset_pending; |
| 255 | 256 | ||
| @@ -282,11 +283,12 @@ static void clocksource_watchdog(unsigned long data) | |||
| 282 | continue; | 283 | continue; |
| 283 | } | 284 | } |
| 284 | 285 | ||
| 285 | wd_nsec = clocksource_cyc2ns((wdnow - cs->wd_last) & watchdog->mask, | 286 | delta = clocksource_delta(wdnow, cs->wd_last, watchdog->mask); |
| 286 | watchdog->mult, watchdog->shift); | 287 | wd_nsec = clocksource_cyc2ns(delta, watchdog->mult, |
| 288 | watchdog->shift); | ||
| 287 | 289 | ||
| 288 | cs_nsec = clocksource_cyc2ns((csnow - cs->cs_last) & | 290 | delta = clocksource_delta(csnow, cs->cs_last, cs->mask); |
| 289 | cs->mask, cs->mult, cs->shift); | 291 | cs_nsec = clocksource_cyc2ns(delta, cs->mult, cs->shift); |
| 290 | cs->cs_last = csnow; | 292 | cs->cs_last = csnow; |
| 291 | cs->wd_last = wdnow; | 293 | cs->wd_last = wdnow; |
| 292 | 294 | ||
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c new file mode 100644 index 000000000000..1c2fe7de2842 --- /dev/null +++ b/kernel/time/hrtimer.c | |||
| @@ -0,0 +1,1866 @@ | |||
| 1 | /* | ||
| 2 | * linux/kernel/hrtimer.c | ||
| 3 | * | ||
| 4 | * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> | ||
| 5 | * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar | ||
| 6 | * Copyright(C) 2006-2007 Timesys Corp., Thomas Gleixner | ||
| 7 | * | ||
| 8 | * High-resolution kernel timers | ||
| 9 | * | ||
| 10 | * In contrast to the low-resolution timeout API implemented in | ||
| 11 | * kernel/timer.c, hrtimers provide finer resolution and accuracy | ||
| 12 | * depending on system configuration and capabilities. | ||
| 13 | * | ||
| 14 | * These timers are currently used for: | ||
| 15 | * - itimers | ||
| 16 | * - POSIX timers | ||
| 17 | * - nanosleep | ||
| 18 | * - precise in-kernel timing | ||
| 19 | * | ||
| 20 | * Started by: Thomas Gleixner and Ingo Molnar | ||
| 21 | * | ||
| 22 | * Credits: | ||
| 23 | * based on kernel/timer.c | ||
| 24 | * | ||
| 25 | * Help, testing, suggestions, bugfixes, improvements were | ||
| 26 | * provided by: | ||
| 27 | * | ||
| 28 | * George Anzinger, Andrew Morton, Steven Rostedt, Roman Zippel | ||
| 29 | * et. al. | ||
| 30 | * | ||
| 31 | * For licencing details see kernel-base/COPYING | ||
| 32 | */ | ||
| 33 | |||
| 34 | #include <linux/cpu.h> | ||
| 35 | #include <linux/export.h> | ||
| 36 | #include <linux/percpu.h> | ||
| 37 | #include <linux/hrtimer.h> | ||
| 38 | #include <linux/notifier.h> | ||
| 39 | #include <linux/syscalls.h> | ||
| 40 | #include <linux/kallsyms.h> | ||
| 41 | #include <linux/interrupt.h> | ||
| 42 | #include <linux/tick.h> | ||
| 43 | #include <linux/seq_file.h> | ||
| 44 | #include <linux/err.h> | ||
| 45 | #include <linux/debugobjects.h> | ||
| 46 | #include <linux/sched.h> | ||
| 47 | #include <linux/sched/sysctl.h> | ||
| 48 | #include <linux/sched/rt.h> | ||
| 49 | #include <linux/sched/deadline.h> | ||
| 50 | #include <linux/timer.h> | ||
| 51 | #include <linux/freezer.h> | ||
| 52 | |||
| 53 | #include <asm/uaccess.h> | ||
| 54 | |||
| 55 | #include <trace/events/timer.h> | ||
| 56 | |||
| 57 | #include "timekeeping.h" | ||
| 58 | |||
| 59 | /* | ||
| 60 | * The timer bases: | ||
| 61 | * | ||
| 62 | * There are more clockids then hrtimer bases. Thus, we index | ||
| 63 | * into the timer bases by the hrtimer_base_type enum. When trying | ||
| 64 | * to reach a base using a clockid, hrtimer_clockid_to_base() | ||
| 65 | * is used to convert from clockid to the proper hrtimer_base_type. | ||
| 66 | */ | ||
| 67 | DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) = | ||
| 68 | { | ||
| 69 | |||
| 70 | .lock = __RAW_SPIN_LOCK_UNLOCKED(hrtimer_bases.lock), | ||
| 71 | .clock_base = | ||
| 72 | { | ||
