aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/feature-removal-schedule.txt10
-rw-r--r--Documentation/kernel-parameters.txt3
-rw-r--r--arch/alpha/Kconfig4
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/avr32/Kconfig3
-rw-r--r--arch/blackfin/Kconfig3
-rw-r--r--arch/cris/Kconfig3
-rw-r--r--arch/frv/Kconfig4
-rw-r--r--arch/h8300/Kconfig4
-rw-r--r--arch/ia64/Kconfig4
-rw-r--r--arch/ia64/kernel/time.c7
-rw-r--r--arch/m32r/Kconfig3
-rw-r--r--arch/m68k/Kconfig3
-rw-r--r--arch/m68knommu/Kconfig4
-rw-r--r--arch/microblaze/Kconfig3
-rw-r--r--arch/mips/Kconfig4
-rw-r--r--arch/mn10300/Kconfig3
-rw-r--r--arch/parisc/Kconfig4
-rw-r--r--arch/powerpc/Kconfig3
-rw-r--r--arch/powerpc/kernel/time.c60
-rw-r--r--arch/s390/Kconfig3
-rw-r--r--arch/s390/kernel/time.c8
-rw-r--r--arch/score/Kconfig3
-rw-r--r--arch/sh/Kconfig3
-rw-r--r--arch/sparc/Kconfig3
-rw-r--r--arch/um/Kconfig.common4
-rw-r--r--arch/um/kernel/time.c16
-rw-r--r--arch/x86/Kconfig5
-rw-r--r--arch/x86/kernel/hpet.c13
-rw-r--r--arch/x86/kernel/tsc.c5
-rw-r--r--arch/x86/kernel/vsyscall_64.c17
-rw-r--r--arch/xtensa/Kconfig3
-rw-r--r--drivers/Makefile4
-rw-r--r--drivers/acpi/acpi_pad.c2
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/clocksource/acpi_pm.c9
-rw-r--r--drivers/misc/Kconfig4
-rw-r--r--include/linux/clocksource.h17
-rw-r--r--include/linux/time.h21
-rw-r--r--kernel/debug/kdb/kdb_main.c4
-rw-r--r--kernel/hrtimer.c9
-rw-r--r--kernel/time.c16
-rw-r--r--kernel/time/Kconfig4
-rw-r--r--kernel/time/clocksource.c33
-rw-r--r--kernel/time/timekeeping.c79
-rw-r--r--kernel/trace/Kconfig4
46 files changed, 165 insertions, 262 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 6fdb837d940b..71f0fea1058f 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -445,16 +445,6 @@ Who: Jan Kiszka <jan.kiszka@web.de>
445 445
446---------------------------- 446----------------------------
447 447
448What: xtime, wall_to_monotonic
449When: 2.6.36+
450Files: kernel/time/timekeeping.c include/linux/time.h
451Why: Cleaning up timekeeping internal values. Please use
452 existing timekeeping accessor functions to access
453 the equivalent functionality.
454Who: John Stultz <johnstul@us.ibm.com>
455
456----------------------------
457
458What: KVM paravirt mmu host support 448What: KVM paravirt mmu host support
459When: January 2011 449When: January 2011
460Why: The paravirt mmu host support is slower than non-paravirt mmu, both 450Why: The paravirt mmu host support is slower than non-paravirt mmu, both
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index cbd405930522..71d286307cae 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -73,7 +73,6 @@ parameter is applicable:
73 MTD MTD (Memory Technology Device) support is enabled. 73 MTD MTD (Memory Technology Device) support is enabled.
74 NET Appropriate network support is enabled. 74 NET Appropriate network support is enabled.
75 NUMA NUMA support is enabled. 75 NUMA NUMA support is enabled.
76 GENERIC_TIME The generic timeofday code is enabled.
77 NFS Appropriate NFS support is enabled. 76 NFS Appropriate NFS support is enabled.
78 OSS OSS sound support is enabled. 77 OSS OSS sound support is enabled.
79 PV_OPS A paravirtualized kernel is enabled. 78 PV_OPS A paravirtualized kernel is enabled.
@@ -470,7 +469,7 @@ and is between 256 and 4096 characters. It is defined in the file
470 clocksource is not available, it defaults to PIT. 469 clocksource is not available, it defaults to PIT.
471 Format: { pit | tsc | cyclone | pmtmr } 470 Format: { pit | tsc | cyclone | pmtmr }
472 471
473 clocksource= [GENERIC_TIME] Override the default clocksource 472 clocksource= Override the default clocksource
474 Format: <string> 473 Format: <string>
475 Override the default clocksource and use the clocksource 474 Override the default clocksource and use the clocksource
476 with the name specified. 475 with the name specified.
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 3e2e540a0f2a..b9647bb66d13 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -47,10 +47,6 @@ config GENERIC_CALIBRATE_DELAY
47 bool 47 bool
48 default y 48 default y
49 49
50config GENERIC_TIME
51 bool
52 default y
53
54config GENERIC_CMOS_UPDATE 50config GENERIC_CMOS_UPDATE
55 def_bool y 51 def_bool y
56 52
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e39caa8b0c93..9e10882c81d7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -43,10 +43,6 @@ config SYS_SUPPORTS_APM_EMULATION
43config GENERIC_GPIO 43config GENERIC_GPIO
44 bool 44 bool
45 45
46config GENERIC_TIME
47 bool
48 default y
49
50config ARCH_USES_GETTIMEOFFSET 46config ARCH_USES_GETTIMEOFFSET
51 bool 47 bool
52 default n 48 default n
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index f2b319333184..f51572772e21 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -45,9 +45,6 @@ config GENERIC_IRQ_PROBE
45config RWSEM_GENERIC_SPINLOCK 45config RWSEM_GENERIC_SPINLOCK
46 def_bool y 46 def_bool y
47 47
48config GENERIC_TIME
49 def_bool y
50
51config GENERIC_CLOCKEVENTS 48config GENERIC_CLOCKEVENTS
52 def_bool y 49 def_bool y
53 50
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index f66294b4f9d2..c88fd3584122 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -614,9 +614,6 @@ comment "Kernel Timer/Scheduler"
614 614
615source kernel/Kconfig.hz 615source kernel/Kconfig.hz
616 616
617config GENERIC_TIME
618 def_bool y
619
620config GENERIC_CLOCKEVENTS 617config GENERIC_CLOCKEVENTS
621 bool "Generic clock events" 618 bool "Generic clock events"
622 default y 619 default y
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index e25bf4440b51..887ef855be2a 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -20,9 +20,6 @@ config RWSEM_GENERIC_SPINLOCK
20config RWSEM_XCHGADD_ALGORITHM 20config RWSEM_XCHGADD_ALGORITHM
21 bool 21 bool
22 22
23config GENERIC_TIME
24 def_bool y
25
26config GENERIC_CMOS_UPDATE 23config GENERIC_CMOS_UPDATE
27 def_bool y 24 def_bool y
28 25
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index 4b5830bcbe2e..16399bd24993 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -40,10 +40,6 @@ config GENERIC_HARDIRQS_NO__DO_IRQ
40 bool 40 bool
41 default y 41 default y
42 42
43config GENERIC_TIME
44 bool
45 default y
46
47config TIME_LOW_RES 43config TIME_LOW_RES
48 bool 44 bool
49 default y 45 default y
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 53cc669e6d59..988b6ff34cc4 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -62,10 +62,6 @@ config GENERIC_CALIBRATE_DELAY
62 bool 62 bool
63 default y 63 default y
64 64
65config GENERIC_TIME
66 bool
67 default y
68
69config GENERIC_BUG 65config GENERIC_BUG
70 bool 66 bool
71 depends on BUG 67 depends on BUG
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 95610820041e..8711d13cd79f 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -82,10 +82,6 @@ config GENERIC_CALIBRATE_DELAY
82 bool 82 bool
83 default y 83 default y
84 84
85config GENERIC_TIME
86 bool
87 default y
88
89config GENERIC_TIME_VSYSCALL 85config GENERIC_TIME_VSYSCALL
90 bool 86 bool
91 default y 87 default y
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 653b3c46ea82..ed6f22eb5b12 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -471,7 +471,8 @@ void update_vsyscall_tz(void)
471{ 471{
472} 472}
473 473
474void update_vsyscall(struct timespec *wall, struct clocksource *c, u32 mult) 474void update_vsyscall(struct timespec *wall, struct timespec *wtm,
475 struct clocksource *c, u32 mult)
475{ 476{
476 unsigned long flags; 477 unsigned long flags;
477 478
@@ -487,9 +488,9 @@ void update_vsyscall(struct timespec *wall, struct clocksource *c, u32 mult)
487 /* copy kernel time structures */ 488 /* copy kernel time structures */
488 fsyscall_gtod_data.wall_time.tv_sec = wall->tv_sec; 489 fsyscall_gtod_data.wall_time.tv_sec = wall->tv_sec;
489 fsyscall_gtod_data.wall_time.tv_nsec = wall->tv_nsec; 490 fsyscall_gtod_data.wall_time.tv_nsec = wall->tv_nsec;
490 fsyscall_gtod_data.monotonic_time.tv_sec = wall_to_monotonic.tv_sec 491 fsyscall_gtod_data.monotonic_time.tv_sec = wtm->tv_sec
491 + wall->tv_sec; 492 + wall->tv_sec;
492 fsyscall_gtod_data.monotonic_time.tv_nsec = wall_to_monotonic.tv_nsec 493 fsyscall_gtod_data.monotonic_time.tv_nsec = wtm->tv_nsec
493 + wall->tv_nsec; 494 + wall->tv_nsec;
494 495
495 /* normalize */ 496 /* normalize */
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index 3a9319f93e89..836abbbc9c04 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -44,9 +44,6 @@ config HZ
44 int 44 int
45 default 100 45 default 100
46 46
47config GENERIC_TIME
48 def_bool y
49
50config ARCH_USES_GETTIMEOFFSET 47config ARCH_USES_GETTIMEOFFSET
51 def_bool y 48 def_bool y
52 49
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 2e3737b92ffc..8030e2481d97 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -59,9 +59,6 @@ config HZ
59 int 59 int
60 default 100 60 default 100
61 61
62config GENERIC_TIME
63 def_bool y
64
65config ARCH_USES_GETTIMEOFFSET 62config ARCH_USES_GETTIMEOFFSET
66 def_bool y 63 def_bool y
67 64
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index efeb6033fc17..2609c394e1df 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -63,10 +63,6 @@ config GENERIC_CALIBRATE_DELAY
63 bool 63 bool
64 default y 64 default y
65 65
66config GENERIC_TIME
67 bool
68 default y
69
70config GENERIC_CMOS_UPDATE 66config GENERIC_CMOS_UPDATE
71 bool 67 bool
72 default y 68 default y
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 9bd64b4b2b0c..692fdfce2a23 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -51,9 +51,6 @@ config GENERIC_IRQ_PROBE
51config GENERIC_CALIBRATE_DELAY 51config GENERIC_CALIBRATE_DELAY
52 def_bool y 52 def_bool y
53 53
54config GENERIC_TIME
55 def_bool y
56
57config GENERIC_TIME_VSYSCALL 54config GENERIC_TIME_VSYSCALL
58 def_bool n 55 def_bool n
59 56
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 36642df7d5f6..3ad59dde4852 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -758,10 +758,6 @@ config GENERIC_CLOCKEVENTS
758 bool 758 bool
759 default y 759 default y
760 760
761config GENERIC_TIME
762 bool
763 default y
764
765config GENERIC_CMOS_UPDATE 761config GENERIC_CMOS_UPDATE
766 bool 762 bool
767 default y 763 default y
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 1c4565a9102b..444b9f918fdf 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -46,9 +46,6 @@ config GENERIC_FIND_NEXT_BIT
46config GENERIC_HWEIGHT 46config GENERIC_HWEIGHT
47 def_bool y 47 def_bool y
48 48
49config GENERIC_TIME
50 def_bool y
51
52config GENERIC_BUG 49config GENERIC_BUG
53 def_bool y 50 def_bool y
54 51
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 05a366a5c4d5..907417d187e1 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -66,10 +66,6 @@ config GENERIC_CALIBRATE_DELAY
66 bool 66 bool
67 default y 67 default y
68 68
69config GENERIC_TIME
70 bool
71 default y
72
73config TIME_LOW_RES 69config TIME_LOW_RES
74 bool 70 bool
75 depends on SMP 71 depends on SMP
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e2bf40a2ce5a..631e5a0fb6ab 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -29,9 +29,6 @@ config MMU
29config GENERIC_CMOS_UPDATE 29config GENERIC_CMOS_UPDATE
30 def_bool y 30 def_bool y
31 31
32config GENERIC_TIME
33 def_bool y
34
35config GENERIC_TIME_VSYSCALL 32config GENERIC_TIME_VSYSCALL
36 def_bool y 33 def_bool y
37 34
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index ccb8759c8532..ce53dfa7130d 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -796,10 +796,30 @@ static cycle_t timebase_read(struct clocksource *cs)
796 return (cycle_t)get_tb(); 796 return (cycle_t)get_tb();
797} 797}
798 798
799static inline void update_gtod(u64 new_tb_stamp, u64 new_stamp_xsec, 799void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
800 u64 new_tb_to_xs, struct timespec *now, 800 struct clocksource *clock, u32 mult)
801 u32 frac_sec)
802{ 801{
802 u64 new_tb_to_xs, new_stamp_xsec;
803 u32 frac_sec;
804
805 if (clock != &clocksource_timebase)
806 return;
807
808 /* Make userspace gettimeofday spin until we're done. */
809 ++vdso_data->tb_update_count;
810 smp_mb();
811
812 /* XXX this assumes clock->shift == 22 */
813 /* 4611686018 ~= 2^(20+64-22) / 1e9 */
814 new_tb_to_xs = (u64) mult * 4611686018ULL;
815 new_stamp_xsec = (u64) wall_time->tv_nsec * XSEC_PER_SEC;
816 do_div(new_stamp_xsec, 1000000000);
817 new_stamp_xsec += (u64) wall_time->tv_sec * XSEC_PER_SEC;
818
819 BUG_ON(wall_time->tv_nsec >= NSEC_PER_SEC);
820 /* this is tv_nsec / 1e9 as a 0.32 fraction */
821 frac_sec = ((u64) wall_time->tv_nsec * 18446744073ULL) >> 32;
822
803 /* 823 /*
804 * tb_update_count is used to allow the userspace gettimeofday code 824 * tb_update_count is used to allow the userspace gettimeofday code
805 * to assure itself that it sees a consistent view of the tb_to_xs and 825 * to assure itself that it sees a consistent view of the tb_to_xs and
@@ -811,43 +831,17 @@ static inline void update_gtod(u64 new_tb_stamp, u64 new_stamp_xsec,
811 * We expect the caller to have done the first increment of 831 * We expect the caller to have done the first increment of
812 * vdso_data->tb_update_count already. 832 * vdso_data->tb_update_count already.
813 */ 833 */
814 vdso_data->tb_orig_stamp = new_tb_stamp; 834 vdso_data->tb_orig_stamp = clock->cycle_last;
815 vdso_data->stamp_xsec = new_stamp_xsec; 835 vdso_data->stamp_xsec = new_stamp_xsec;
816 vdso_data->tb_to_xs = new_tb_to_xs; 836 vdso_data->tb_to_xs = new_tb_to_xs;
817 vdso_data->wtom_clock_sec = wall_to_monotonic.tv_sec; 837 vdso_data->wtom_clock_sec = wtm->tv_sec;
818 vdso_data->wtom_clock_nsec = wall_to_monotonic.tv_nsec; 838 vdso_data->wtom_clock_nsec = wtm->tv_nsec;
819 vdso_data->stamp_xtime = *now; 839 vdso_data->stamp_xtime = *wall_time;
820 vdso_data->stamp_sec_fraction = frac_sec; 840 vdso_data->stamp_sec_fraction = frac_sec;
821 smp_wmb(); 841 smp_wmb();
822 ++(vdso_data->tb_update_count); 842 ++(vdso_data->tb_update_count);
823} 843}
824 844
825void update_vsyscall(struct timespec *wall_time, struct clocksource *clock,
826 u32 mult)
827{
828 u64 t2x, stamp_xsec;
829 u32 frac_sec;
830
831 if (clock != &clocksource_timebase)
832 return;
833
834 /* Make userspace gettimeofday spin until we're done. */
835 ++vdso_data->tb_update_count;
836 smp_mb();
837
838 /* XXX this assumes clock->shift == 22 */
839 /* 4611686018 ~= 2^(20+64-22) / 1e9 */
840 t2x = (u64) mult * 4611686018ULL;
841 stamp_xsec = (u64) wall_time->tv_nsec * XSEC_PER_SEC;
842 do_div(stamp_xsec, 1000000000);
843 stamp_xsec += (u64) wall_time->tv_sec * XSEC_PER_SEC;
844
845 BUG_ON(wall_time->tv_nsec >= NSEC_PER_SEC);
846 /* this is tv_nsec / 1e9 as a 0.32 fraction */
847 frac_sec = ((u64) wall_time->tv_nsec * 18446744073ULL) >> 32;
848 update_gtod(clock->cycle_last, stamp_xsec, t2x, wall_time, frac_sec);
849}
850
851void update_vsyscall_tz(void) 845void update_vsyscall_tz(void)
852{ 846{
853 /* Make userspace gettimeofday spin until we're done. */ 847 /* Make userspace gettimeofday spin until we're done. */
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index bee1c0f794cf..f0777a47e3a5 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -40,9 +40,6 @@ config ARCH_HAS_ILOG2_U64
40config GENERIC_HWEIGHT 40config GENERIC_HWEIGHT
41 def_bool y 41 def_bool y
42 42
43config GENERIC_TIME
44 def_bool y
45
46config GENERIC_TIME_VSYSCALL 43config GENERIC_TIME_VSYSCALL
47 def_bool y 44 def_bool y
48 45
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index 15a7536452d5..2896cac9c14a 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -207,8 +207,8 @@ struct clocksource * __init clocksource_default_clock(void)
207 return &clocksource_tod; 207 return &clocksource_tod;
208} 208}
209 209
210void update_vsyscall(struct timespec *wall_time, struct clocksource *clock, 210void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
211 u32 mult) 211 struct clocksource *clock, u32 mult)
212{ 212{
213 if (clock != &clocksource_tod) 213 if (clock != &clocksource_tod)
214 return; 214 return;
@@ -219,8 +219,8 @@ void update_vsyscall(struct timespec *wall_time, struct clocksource *clock,
219 vdso_data->xtime_tod_stamp = clock->cycle_last; 219 vdso_data->xtime_tod_stamp = clock->cycle_last;
220 vdso_data->xtime_clock_sec = wall_time->tv_sec; 220 vdso_data->xtime_clock_sec = wall_time->tv_sec;
221 vdso_data->xtime_clock_nsec = wall_time->tv_nsec; 221 vdso_data->xtime_clock_nsec = wall_time->tv_nsec;
222 vdso_data->wtom_clock_sec = wall_to_monotonic.tv_sec; 222 vdso_data->wtom_clock_sec = wtm->tv_sec;
223 vdso_data->wtom_clock_nsec = wall_to_monotonic.tv_nsec; 223 vdso_data->wtom_clock_nsec = wtm->tv_nsec;
224 vdso_data->ntp_mult = mult; 224 vdso_data->ntp_mult = mult;
225 smp_wmb(); 225 smp_wmb();
226 ++vdso_data->tb_update_count; 226 ++vdso_data->tb_update_count;
diff --git a/arch/score/Kconfig b/arch/score/Kconfig
index 55d413e6dcf2..be4a15584751 100644
--- a/arch/score/Kconfig
+++ b/arch/score/Kconfig
@@ -55,9 +55,6 @@ config GENERIC_CALIBRATE_DELAY
55config GENERIC_CLOCKEVENTS 55config GENERIC_CLOCKEVENTS
56 def_bool y 56 def_bool y
57 57
58config GENERIC_TIME
59 def_bool y
60
61config SCHED_NO_NO_OMIT_FRAME_POINTER 58config SCHED_NO_NO_OMIT_FRAME_POINTER
62 def_bool y 59 def_bool y
63 60
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 82868fee21fd..33990fa95af0 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -98,9 +98,6 @@ config GENERIC_CALIBRATE_DELAY
98config GENERIC_IOMAP 98config GENERIC_IOMAP
99 bool 99 bool
100 100
101config GENERIC_TIME
102 def_bool y
103
104config GENERIC_CLOCKEVENTS 101config GENERIC_CLOCKEVENTS
105 def_bool y 102 def_bool y
106 103
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index ba068c833e5d..491e9d6de191 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -67,9 +67,6 @@ config BITS
67 default 32 if SPARC32 67 default 32 if SPARC32
68 default 64 if SPARC64 68 default 64 if SPARC64
69 69
70config GENERIC_TIME
71 def_bool y
72
73config ARCH_USES_GETTIMEOFFSET 70config ARCH_USES_GETTIMEOFFSET
74 bool 71 bool
75 default y if SPARC32 72 default y if SPARC32
diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index 0d207e73a758..7c8e277f6d34 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -55,10 +55,6 @@ config GENERIC_BUG
55 default y 55 default y
56 depends on BUG 56 depends on BUG
57 57
58config GENERIC_TIME
59 bool
60 default y
61
62config GENERIC_CLOCKEVENTS 58config GENERIC_CLOCKEVENTS
63 bool 59 bool
64 default y 60 default y
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index c8b9c469fcd7..a08d9fab81f2 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -102,16 +102,16 @@ static void __init setup_itimer(void)
102 clockevents_register_device(&itimer_clockevent); 102 clockevents_register_device(&itimer_clockevent);
103} 103}
104 104
105void __init time_init(void) 105void read_persistent_clock(struct timespec *ts)
106{ 106{
107 long long nsecs; 107 long long nsecs = os_nsecs();
108
109 timer_init();
110 108
111 nsecs = os_nsecs(); 109 set_normalized_timespec(ts, nsecs / NSEC_PER_SEC,
112 set_normalized_timespec(&wall_to_monotonic, -nsecs / NSEC_PER_SEC,
113 -nsecs % NSEC_PER_SEC);
114 set_normalized_timespec(&xtime, nsecs / NSEC_PER_SEC,
115 nsecs % NSEC_PER_SEC); 110 nsecs % NSEC_PER_SEC);
111}
112
113void __init time_init(void)
114{
115 timer_init();
116 late_time_init = setup_itimer; 116 late_time_init = setup_itimer;
117} 117}
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 6f77afa6bca9..baa34e510222 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -73,9 +73,6 @@ config ARCH_DEFCONFIG
73 default "arch/x86/configs/i386_defconfig" if X86_32 73 default "arch/x86/configs/i386_defconfig" if X86_32
74 default "arch/x86/configs/x86_64_defconfig" if X86_64 74 default "arch/x86/configs/x86_64_defconfig" if X86_64
75 75
76config GENERIC_TIME
77 def_bool y
78
79config GENERIC_CMOS_UPDATE 76config GENERIC_CMOS_UPDATE
80 def_bool y 77 def_bool y
81 78
@@ -2047,7 +2044,7 @@ config SCx200
2047 2044
2048config SCx200HR_TIMER 2045config SCx200HR_TIMER
2049 tristate "NatSemi SCx200 27MHz High-Resolution Timer Support" 2046 tristate "NatSemi SCx200 27MHz High-Resolution Timer Support"
2050 depends on SCx200 && GENERIC_TIME 2047 depends on SCx200
2051 default y 2048 default y
2052 ---help--- 2049 ---help---
2053 This driver provides a clocksource built upon the on-chip 2050 This driver provides a clocksource built upon the on-chip
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index ba390d731175..33dbcc4ec5ff 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -16,7 +16,6 @@
16#include <asm/hpet.h> 16#include <asm/hpet.h>
17 17
18#define HPET_MASK CLOCKSOURCE_MASK(32) 18#define HPET_MASK CLOCKSOURCE_MASK(32)
19#define HPET_SHIFT 22
20 19
21/* FSEC = 10^-15 20/* FSEC = 10^-15
22 NSEC = 10^-9 */ 21 NSEC = 10^-9 */
@@ -787,7 +786,6 @@ static struct clocksource clocksource_hpet = {
787 .rating = 250, 786 .rating = 250,
788 .read = read_hpet, 787 .read = read_hpet,
789 .mask = HPET_MASK, 788 .mask = HPET_MASK,
790 .shift = HPET_SHIFT,
791 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 789 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
792 .resume = hpet_resume_counter, 790 .resume = hpet_resume_counter,
793#ifdef CONFIG_X86_64 791#ifdef CONFIG_X86_64
@@ -798,6 +796,7 @@ static struct clocksource clocksource_hpet = {
798static int hpet_clocksource_register(void) 796static int hpet_clocksource_register(void)
799{ 797{
800 u64 start, now; 798 u64 start, now;
799 u64 hpet_freq;
801 cycle_t t1; 800 cycle_t t1;
802 801
803 /* Start the counter */ 802 /* Start the counter */
@@ -832,9 +831,15 @@ static int hpet_clocksource_register(void)
832 * mult = (hpet_period * 2^shift)/10^6 831 * mult = (hpet_period * 2^shift)/10^6
833 * mult = (hpet_period << shift)/FSEC_PER_NSEC 832 * mult = (hpet_period << shift)/FSEC_PER_NSEC
834 */ 833 */
835 clocksource_hpet.mult = div_sc(hpet_period, FSEC_PER_NSEC, HPET_SHIFT);
836 834
837 clocksource_register(&clocksource_hpet); 835 /* Need to convert hpet_period (fsec/cyc) to cyc/sec:
836 *
837 * cyc/sec = FSEC_PER_SEC/hpet_period(fsec/cyc)
838 * cyc/sec = (FSEC_PER_NSEC * NSEC_PER_SEC)/hpet_period
839 */
840 hpet_freq = FSEC_PER_NSEC * NSEC_PER_SEC;
841 do_div(hpet_freq, hpet_period);
842 clocksource_register_hz(&clocksource_hpet, (u32)hpet_freq);
838 843
839 return 0; 844 return 0;
840} 845}
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 9faf91ae1841..ce8e50239332 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -751,7 +751,6 @@ static struct clocksource clocksource_tsc = {
751 .read = read_tsc, 751 .read = read_tsc,
752 .resume = resume_tsc, 752 .resume = resume_tsc,
753 .mask = CLOCKSOURCE_MASK(64), 753 .mask = CLOCKSOURCE_MASK(64),
754 .shift = 22,
755 .flags = CLOCK_SOURCE_IS_CONTINUOUS | 754 .flags = CLOCK_SOURCE_IS_CONTINUOUS |
756 CLOCK_SOURCE_MUST_VERIFY, 755 CLOCK_SOURCE_MUST_VERIFY,
757#ifdef CONFIG_X86_64 756#ifdef CONFIG_X86_64
@@ -845,8 +844,6 @@ __cpuinit int unsynchronized_tsc(void)
845 844
846static void __init init_tsc_clocksource(void) 845static void __init init_tsc_clocksource(void)
847{ 846{
848 clocksource_tsc.mult = clocksource_khz2mult(tsc_khz,
849 clocksource_tsc.shift);
850 if (tsc_clocksource_reliable) 847 if (tsc_clocksource_reliable)
851 clocksource_tsc.flags &= ~CLOCK_SOURCE_MUST_VERIFY; 848 clocksource_tsc.flags &= ~CLOCK_SOURCE_MUST_VERIFY;
852 /* lower the rating if we already know its unstable: */ 849 /* lower the rating if we already know its unstable: */
@@ -854,7 +851,7 @@ static void __init init_tsc_clocksource(void)
854 clocksource_tsc.rating = 0; 851 clocksource_tsc.rating = 0;
855 clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS; 852 clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS;
856 } 853 }
857 clocksource_register(&clocksource_tsc); 854 clocksource_register_khz(&clocksource_tsc, tsc_khz);
858} 855}
859 856
860#ifdef CONFIG_X86_64 857#ifdef CONFIG_X86_64
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 1c0c6ab9c60f..dcbb28c4b694 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -73,8 +73,8 @@ void update_vsyscall_tz(void)
73 write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags); 73 write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags);
74} 74}
75 75
76void update_vsyscall(struct timespec *wall_time, struct clocksource *clock, 76void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
77 u32 mult) 77 struct clocksource *clock, u32 mult)
78{ 78{
79 unsigned long flags; 79 unsigned long flags;
80 80
@@ -87,7 +87,7 @@ void update_vsyscall(struct timespec *wall_time, struct clocksource *clock,
87 vsyscall_gtod_data.clock.shift = clock->shift; 87 vsyscall_gtod_data.clock.shift = clock->shift;
88 vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec; 88 vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec;
89 vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec; 89 vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
90 vsyscall_gtod_data.wall_to_monotonic = wall_to_monotonic; 90 vsyscall_gtod_data.wall_to_monotonic = *wtm;
91 vsyscall_gtod_data.wall_time_coarse = __current_kernel_time(); 91 vsyscall_gtod_data.wall_time_coarse = __current_kernel_time();
92 write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags); 92 write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags);
93} 93}
@@ -169,13 +169,18 @@ int __vsyscall(0) vgettimeofday(struct timeval * tv, struct timezone * tz)
169 * unlikely */ 169 * unlikely */
170time_t __vsyscall(1) vtime(time_t *t) 170time_t __vsyscall(1) vtime(time_t *t)
171{ 171{
172 struct timeval tv; 172 unsigned seq;
173 time_t result; 173 time_t result;
174 if (unlikely(!__vsyscall_gtod_data.sysctl_enabled)) 174 if (unlikely(!__vsyscall_gtod_data.sysctl_enabled))
175 return time_syscall(t); 175 return time_syscall(t);
176 176
177 vgettimeofday(&tv, NULL); 177 do {
178 result = tv.tv_sec; 178 seq = read_seqbegin(&__vsyscall_gtod_data.lock);
179
180 result = __vsyscall_gtod_data.wall_time_sec;
181
182 } while (read_seqretry(&__vsyscall_gtod_data.lock, seq));
183
179 if (t) 184 if (t)
180 *t = result; 185 *t = result;
181 return result; 186 return result;
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index ebe228d02b08..0859bfd8ae93 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -48,9 +48,6 @@ config HZ
48 int 48 int
49 default 100 49 default 100
50 50
51config GENERIC_TIME
52 def_bool y
53
54source "init/Kconfig" 51source "init/Kconfig"
55source "kernel/Kconfig.freezer" 52source "kernel/Kconfig.freezer"
56 53
diff --git a/drivers/Makefile b/drivers/Makefile
index 91874e048552..ae473445ad6d 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -101,7 +101,9 @@ obj-y += firmware/
101obj-$(CONFIG_CRYPTO) += crypto/ 101obj-$(CONFIG_CRYPTO) += crypto/
102obj-$(CONFIG_SUPERH) += sh/ 102obj-$(CONFIG_SUPERH) += sh/
103obj-$(CONFIG_ARCH_SHMOBILE) += sh/ 103obj-$(CONFIG_ARCH_SHMOBILE) += sh/
104obj-$(CONFIG_GENERIC_TIME) += clocksource/ 104ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
105obj-y += clocksource/
106endif
105obj-$(CONFIG_DMA_ENGINE) += dma/ 107obj-$(CONFIG_DMA_ENGINE) += dma/
106obj-$(CONFIG_DCA) += dca/ 108obj-$(CONFIG_DCA) += dca/
107obj-$(CONFIG_HID) += hid/ 109obj-$(CONFIG_HID) += hid/
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 446aced33aff..b76848c80be3 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -77,7 +77,7 @@ static void power_saving_mwait_init(void)
77 power_saving_mwait_eax = (highest_cstate << MWAIT_SUBSTATE_SIZE) | 77 power_saving_mwait_eax = (highest_cstate << MWAIT_SUBSTATE_SIZE) |
78 (highest_subcstate - 1); 78 (highest_subcstate - 1);
79 79
80#if defined(CONFIG_GENERIC_TIME) && defined(CONFIG_X86) 80#if defined(CONFIG_X86)
81 switch (boot_cpu_data.x86_vendor) { 81 switch (boot_cpu_data.x86_vendor) {
82 case X86_VENDOR_AMD: 82 case X86_VENDOR_AMD:
83 case X86_VENDOR_INTEL: 83 case X86_VENDOR_INTEL:
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index eead3f581fb5..b4c2f3bdadeb 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -264,7 +264,7 @@ int acpi_processor_resume(struct acpi_device * device)
264 return 0; 264 return 0;
265} 265}
266 266
267#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86) 267#if defined(CONFIG_X86)
268static void tsc_check_state(int state) 268static void tsc_check_state(int state)
269{ 269{
270 switch (boot_cpu_data.x86_vendor) { 270 switch (boot_cpu_data.x86_vendor) {
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index 72a633a6ec98..cfb0f5278415 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -68,10 +68,7 @@ static struct clocksource clocksource_acpi_pm = {
68 .rating = 200, 68 .rating = 200,
69 .read = acpi_pm_read, 69 .read = acpi_pm_read,
70 .mask = (cycle_t)ACPI_PM_MASK, 70 .mask = (cycle_t)ACPI_PM_MASK,
71 .mult = 0, /*to be calculated*/
72 .shift = 22,
73 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 71 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
74
75}; 72};
76 73
77 74
@@ -190,9 +187,6 @@ static int __init init_acpi_pm_clocksource(void)
190 if (!pmtmr_ioport) 187 if (!pmtmr_ioport)
191 return -ENODEV; 188 return -ENODEV;
192 189
193 clocksource_acpi_pm.mult = clocksource_hz2mult(PMTMR_TICKS_PER_SEC,
194 clocksource_acpi_pm.shift);
195
196 /* "verify" this timing source: */ 190 /* "verify" this timing source: */
197 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) { 191 for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) {
198 udelay(100 * j); 192 udelay(100 * j);
@@ -220,7 +214,8 @@ static int __init init_acpi_pm_clocksource(void)
220 if (verify_pmtmr_rate() != 0) 214 if (verify_pmtmr_rate() != 0)
221 return -ENODEV; 215 return -ENODEV;
222 216
223 return clocksource_register(&clocksource_acpi_pm); 217 return clocksource_register_hz(&clocksource_acpi_pm,
218 PMTMR_TICKS_PER_SEC);
224} 219}
225 220
226/* We use fs_initcall because we want the PCI fixups to have run 221/* We use fs_initcall because we want the PCI fixups to have run
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 9b089dfb173e..488f25472291 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -72,7 +72,7 @@ config ATMEL_TCLIB
72 72
73config ATMEL_TCB_CLKSRC 73config ATMEL_TCB_CLKSRC
74 bool "TC Block Clocksource" 74 bool "TC Block Clocksource"
75 depends on ATMEL_TCLIB && GENERIC_TIME 75 depends on ATMEL_TCLIB
76 default y 76 default y
77 help 77 help
78 Select this to get a high precision clocksource based on a 78 Select this to get a high precision clocksource based on a
@@ -240,7 +240,7 @@ config CS5535_MFGPT_DEFAULT_IRQ
240 240
241config CS5535_CLOCK_EVENT_SRC 241config CS5535_CLOCK_EVENT_SRC
242 tristate "CS5535/CS5536 high-res timer (MFGPT) events" 242 tristate "CS5535/CS5536 high-res timer (MFGPT) events"
243 depends on GENERIC_TIME && GENERIC_CLOCKEVENTS && CS5535_MFGPT 243 depends on GENERIC_CLOCKEVENTS && CS5535_MFGPT
244 help 244 help
245 This driver provides a clock event source based on the MFGPT 245 This driver provides a clock event source based on the MFGPT
246 timer(s) in the CS5535 and CS5536 companion chips. 246 timer(s) in the CS5535 and CS5536 companion chips.
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 5ea3c60c160c..c37b21ad5a3b 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -292,6 +292,8 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 minsec);
292 */ 292 */
293extern int 293extern int
294__clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq); 294__clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq);
295extern void
296__clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32 freq);
295 297
296static inline int clocksource_register_hz(struct clocksource *cs, u32 hz) 298static inline int clocksource_register_hz(struct clocksource *cs, u32 hz)
297{ 299{
@@ -303,6 +305,15 @@ static inline int clocksource_register_khz(struct clocksource *cs, u32 khz)
303 return __clocksource_register_scale(cs, 1000, khz); 305 return __clocksource_register_scale(cs, 1000, khz);
304} 306}
305 307
308static inline void __clocksource_updatefreq_hz(struct clocksource *cs, u32 hz)
309{
310 __clocksource_updatefreq_scale(cs, 1, hz);
311}
312
313static inline void __clocksource_updatefreq_khz(struct clocksource *cs, u32 khz)
314{
315 __clocksource_updatefreq_scale(cs, 1000, khz);
316}
306 317
307static inline void 318static inline void
308clocksource_calc_mult_shift(struct clocksource *cs, u32 freq, u32 minsec) 319clocksource_calc_mult_shift(struct clocksource *cs, u32 freq, u32 minsec)
@@ -313,11 +324,13 @@ clocksource_calc_mult_shift(struct clocksource *cs, u32 freq, u32 minsec)
313 324
314#ifdef CONFIG_GENERIC_TIME_VSYSCALL 325#ifdef CONFIG_GENERIC_TIME_VSYSCALL
315extern void 326extern void
316update_vsyscall(struct timespec *ts, struct clocksource *c, u32 mult); 327update_vsyscall(struct timespec *ts, struct timespec *wtm,
328 struct clocksource *c, u32 mult);
317extern void update_vsyscall_tz(void); 329extern void update_vsyscall_tz(void);
318#else 330#else
319static inline void 331static inline void
320update_vsyscall(struct timespec *ts, struct clocksource *c, u32 mult) 332update_vsyscall(struct timespec *ts, struct timespec *wtm,
333 struct clocksource *c, u32 mult)
321{ 334{
322} 335}
323 336
diff --git a/include/linux/time.h b/include/linux/time.h
index ea3559f0b3f2..cb34e35fabac 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -76,9 +76,25 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon,
76 const unsigned int min, const unsigned int sec); 76 const unsigned int min, const unsigned int sec);
77 77
78extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); 78extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec);
79
80/*
81 * timespec_add_safe assumes both values are positive and checks
82 * for overflow. It will return TIME_T_MAX if the reutrn would be
83 * smaller then either of the arguments.
84 */
79extern struct timespec timespec_add_safe(const struct timespec lhs, 85extern struct timespec timespec_add_safe(const struct timespec lhs,
80 const struct timespec rhs); 86 const struct timespec rhs);
81 87
88
89static inline struct timespec timespec_add(struct timespec lhs,
90 struct timespec rhs)
91{
92 struct timespec ts_delta;
93 set_normalized_timespec(&ts_delta, lhs.tv_sec + rhs.tv_sec,
94 lhs.tv_nsec + rhs.tv_nsec);
95 return ts_delta;
96}
97
82/* 98/*
83 * sub = lhs - rhs, in normalized form 99 * sub = lhs - rhs, in normalized form
84 */ 100 */
@@ -97,8 +113,6 @@ static inline struct timespec timespec_sub(struct timespec lhs,
97#define timespec_valid(ts) \ 113#define timespec_valid(ts) \
98 (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC)) 114 (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC))
99 115
100extern struct timespec xtime;
101extern struct timespec wall_to_monotonic;
102extern seqlock_t xtime_lock; 116extern seqlock_t xtime_lock;
103 117
104extern void read_persistent_clock(struct timespec *ts); 118extern void read_persistent_clock(struct timespec *ts);
@@ -110,7 +124,8 @@ extern int timekeeping_suspended;
110 124
111unsigned long get_seconds(void); 125unsigned long get_seconds(void);
112struct timespec current_kernel_time(void); 126struct timespec current_kernel_time(void);
113struct timespec __current_kernel_time(void); /* does not hold xtime_lock */ 127struct timespec __current_kernel_time(void); /* does not take xtime_lock */
128struct timespec __get_wall_to_monotonic(void); /* does not take xtime_lock */
114struct timespec get_monotonic_coarse(void); 129struct timespec get_monotonic_coarse(void);
115 130
116#define CURRENT_TIME (current_kernel_time()) 131#define CURRENT_TIME (current_kernel_time())
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 8577e45a9a58..28b844118bbd 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -2548,6 +2548,7 @@ static void kdb_sysinfo(struct sysinfo *val)
2548 */ 2548 */
2549static int kdb_summary(int argc, const char **argv) 2549static int kdb_summary(int argc, const char **argv)
2550{ 2550{
2551 struct timespec now;
2551 struct kdb_tm tm; 2552 struct kdb_tm tm;
2552 struct sysinfo val; 2553 struct sysinfo val;
2553 2554
@@ -2562,7 +2563,8 @@ static int kdb_summary(int argc, const char **argv)
2562 kdb_printf("domainname %s\n", init_uts_ns.name.domainname); 2563 kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
2563 kdb_printf("ccversion %s\n", __stringify(CCVERSION)); 2564 kdb_printf("ccversion %s\n", __stringify(CCVERSION));
2564 2565
2565 kdb_gmtime(&xtime, &tm); 2566 now = __current_kernel_time();
2567 kdb_gmtime(&now, &tm);
2566 kdb_printf("date %04d-%02d-%02d %02d:%02d:%02d " 2568 kdb_printf("date %04d-%02d-%02d %02d:%02d:%02d "
2567 "tz_minuteswest %d\n", 2569 "tz_minuteswest %d\n",
2568 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday, 2570 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index e934339fbbef..ce669174f355 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -90,7 +90,7 @@ static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
90 do { 90 do {
91 seq = read_seqbegin(&xtime_lock); 91 seq = read_seqbegin(&xtime_lock);
92 xts = __current_kernel_time(); 92 xts = __current_kernel_time();
93 tom = wall_to_monotonic; 93 tom = __get_wall_to_monotonic();
94 } while (read_seqretry(&xtime_lock, seq)); 94 } while (read_seqretry(&xtime_lock, seq));
95 95
96 xtim = timespec_to_ktime(xts); 96 xtim = timespec_to_ktime(xts);
@@ -608,7 +608,7 @@ static int hrtimer_reprogram(struct hrtimer *timer,
608static void retrigger_next_event(void *arg) 608static void retrigger_next_event(void *arg)
609{ 609{
610 struct hrtimer_cpu_base *base; 610 struct hrtimer_cpu_base *base;
611 struct timespec realtime_offset; 611 struct timespec realtime_offset, wtm;
612 unsigned long seq; 612 unsigned long seq;
613 613
614 if (!hrtimer_hres_active()) 614 if (!hrtimer_hres_active())
@@ -616,10 +616,9 @@ static void retrigger_next_event(void *arg)
616 616
617 do { 617 do {
618 seq = read_seqbegin(&xtime_lock); 618 seq = read_seqbegin(&xtime_lock);
619 set_normalized_timespec(&realtime_offset, 619 wtm = __get_wall_to_monotonic();
620 -wall_to_monotonic.tv_sec,
621 -wall_to_monotonic.tv_nsec);
622 } while (read_seqretry(&xtime_lock, seq)); 620 } while (read_seqretry(&xtime_lock, seq));
621 set_normalized_timespec(&realtime_offset, -wtm.tv_sec, -wtm.tv_nsec);
623 622
624 base = &__get_cpu_var(hrtimer_bases); 623 base = &__get_cpu_var(hrtimer_bases);
625 624
diff --git a/kernel/time.c b/kernel/time.c
index 848b1c2ab09a..ba9b338d1835 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -300,22 +300,6 @@ struct timespec timespec_trunc(struct timespec t, unsigned gran)
300} 300}
301EXPORT_SYMBOL(timespec_trunc); 301EXPORT_SYMBOL(timespec_trunc);
302 302
303#ifndef CONFIG_GENERIC_TIME
304/*
305 * Simulate gettimeofday using do_gettimeofday which only allows a timeval
306 * and therefore only yields usec accuracy
307 */
308void getnstimeofday(struct timespec *tv)
309{
310 struct timeval x;
311
312 do_gettimeofday(&x);
313 tv->tv_sec = x.tv_sec;
314 tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
315}
316EXPORT_SYMBOL_GPL(getnstimeofday);
317#endif
318
319/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. 303/* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
320 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 304 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59
321 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. 305 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig
index 95ed42951e0a..f06a8a365648 100644
--- a/kernel/time/Kconfig
+++ b/kernel/time/Kconfig
@@ -6,7 +6,7 @@ config TICK_ONESHOT
6 6
7config NO_HZ 7config NO_HZ
8 bool "Tickless System (Dynamic Ticks)" 8 bool "Tickless System (Dynamic Ticks)"
9 depends on GENERIC_TIME && GENERIC_CLOCKEVENTS 9 depends on !ARCH_USES_GETTIMEOFFSET && GENERIC_CLOCKEVENTS
10 select TICK_ONESHOT 10 select TICK_ONESHOT
11 help 11 help
12 This option enables a tickless system: timer interrupts will 12 This option enables a tickless system: timer interrupts will
@@ -15,7 +15,7 @@ config NO_HZ
15 15
16config HIGH_RES_TIMERS 16config HIGH_RES_TIMERS
17 bool "High Resolution Timer Support" 17 bool "High Resolution Timer Support"
18 depends on GENERIC_TIME && GENERIC_CLOCKEVENTS 18 depends on !ARCH_USES_GETTIMEOFFSET && GENERIC_CLOCKEVENTS
19 select TICK_ONESHOT 19 select TICK_ONESHOT
20 help 20 help
21 This option enables high resolution timer support. If your 21 This option enables high resolution timer support. If your
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index f08e99c1d561..c18d7efa1b4b 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -531,7 +531,7 @@ static u64 clocksource_max_deferment(struct clocksource *cs)
531 return max_nsecs - (max_nsecs >> 5); 531 return max_nsecs - (max_nsecs >> 5);
532} 532}
533 533
534#ifdef CONFIG_GENERIC_TIME 534#ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
535 535
536/** 536/**
537 * clocksource_select - Select the best clocksource available 537 * clocksource_select - Select the best clocksource available
@@ -577,7 +577,7 @@ static void clocksource_select(void)
577 } 577 }
578} 578}
579 579
580#else /* CONFIG_GENERIC_TIME */ 580#else /* !CONFIG_ARCH_USES_GETTIMEOFFSET */
581 581
582static inline void clocksource_select(void) { } 582static inline void clocksource_select(void) { }
583 583
@@ -639,19 +639,18 @@ static void clocksource_enqueue(struct clocksource *cs)
639#define MAX_UPDATE_LENGTH 5 /* Seconds */ 639#define MAX_UPDATE_LENGTH 5 /* Seconds */
640 640
641/** 641/**
642 * __clocksource_register_scale - Used to install new clocksources 642 * __clocksource_updatefreq_scale - Used update clocksource with new freq
643 * @t: clocksource to be registered 643 * @t: clocksource to be registered
644 * @scale: Scale factor multiplied against freq to get clocksource hz 644 * @scale: Scale factor multiplied against freq to get clocksource hz
645 * @freq: clocksource frequency (cycles per second) divided by scale 645 * @freq: clocksource frequency (cycles per second) divided by scale
646 * 646 *
647 * Returns -EBUSY if registration fails, zero otherwise. 647 * This should only be called from the clocksource->enable() method.
648 * 648 *
649 * This *SHOULD NOT* be called directly! Please use the 649 * This *SHOULD NOT* be called directly! Please use the
650 * clocksource_register_hz() or clocksource_register_khz helper functions. 650 * clocksource_updatefreq_hz() or clocksource_updatefreq_khz helper functions.
651 */ 651 */
652int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) 652void __clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32 freq)
653{ 653{
654
655 /* 654 /*
656 * Ideally we want to use some of the limits used in 655 * Ideally we want to use some of the limits used in
657 * clocksource_max_deferment, to provide a more informed 656 * clocksource_max_deferment, to provide a more informed
@@ -662,7 +661,27 @@ int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
662 NSEC_PER_SEC/scale, 661 NSEC_PER_SEC/scale,
663 MAX_UPDATE_LENGTH*scale); 662 MAX_UPDATE_LENGTH*scale);
664 cs->max_idle_ns = clocksource_max_deferment(cs); 663 cs->max_idle_ns = clocksource_max_deferment(cs);
664}
665EXPORT_SYMBOL_GPL(__clocksource_updatefreq_scale);
666
667/**
668 * __clocksource_register_scale - Used to install new clocksources
669 * @t: clocksource to be registered
670 * @scale: Scale factor multiplied against freq to get clocksource hz
671 * @freq: clocksource frequency (cycles per second) divided by scale
672 *
673 * Returns -EBUSY if registration fails, zero otherwise.
674 *
675 * This *SHOULD NOT* be called directly! Please use the
676 * clocksource_register_hz() or clocksource_register_khz helper functions.
677 */
678int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq)
679{
680
681 /* Intialize mult/shift and max_idle_ns */
682 __clocksource_updatefreq_scale(cs, scale, freq);
665 683
684 /* Add clocksource to the clcoksource list */
666 mutex_lock(&clocksource_mutex); 685 mutex_lock(&clocksource_mutex);
667 clocksource_enqueue(cs); 686 clocksource_enqueue(cs);
668 clocksource_select(); 687 clocksource_select();
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index caf8d4d4f5c8..e14c839e9faa 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -153,8 +153,8 @@ __cacheline_aligned_in_smp DEFINE_SEQLOCK(xtime_lock);
153 * - wall_to_monotonic is no longer the boot time, getboottime must be 153 * - wall_to_monotonic is no longer the boot time, getboottime must be
154 * used instead. 154 * used instead.
155 */ 155 */
156struct timespec xtime __attribute__ ((aligned (16))); 156static struct timespec xtime __attribute__ ((aligned (16)));
157struct timespec wall_to_monotonic __attribute__ ((aligned (16))); 157static struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
158static struct timespec total_sleep_time; 158static struct timespec total_sleep_time;
159 159
160/* 160/*
@@ -170,11 +170,10 @@ void timekeeping_leap_insert(int leapsecond)
170{ 170{
171 xtime.tv_sec += leapsecond; 171 xtime.tv_sec += leapsecond;
172 wall_to_monotonic.tv_sec -= leapsecond; 172 wall_to_monotonic.tv_sec -= leapsecond;
173 update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult); 173 update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
174 timekeeper.mult);
174} 175}
175 176
176#ifdef CONFIG_GENERIC_TIME
177
178/** 177/**
179 * timekeeping_forward_now - update clock to the current time 178 * timekeeping_forward_now - update clock to the current time
180 * 179 *
@@ -328,7 +327,8 @@ int do_settimeofday(struct timespec *tv)
328 timekeeper.ntp_error = 0; 327 timekeeper.ntp_error = 0;
329 ntp_clear(); 328 ntp_clear();
330 329
331 update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult); 330 update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
331 timekeeper.mult);
332 332
333 write_sequnlock_irqrestore(&xtime_lock, flags); 333 write_sequnlock_irqrestore(&xtime_lock, flags);
334 334
@@ -376,52 +376,6 @@ void timekeeping_notify(struct clocksource *clock)
376 tick_clock_notify(); 376 tick_clock_notify();
377} 377}
378 378
379#else /* GENERIC_TIME */
380
381static inline void timekeeping_forward_now(void) { }
382
383/**
384 * ktime_get - get the monotonic time in ktime_t format
385 *
386 * returns the time in ktime_t format
387 */
388ktime_t ktime_get(void)
389{
390 struct timespec now;
391
392 ktime_get_ts(&now);
393
394 return timespec_to_ktime(now);
395}
396EXPORT_SYMBOL_GPL(ktime_get);
397
398/**
399 * ktime_get_ts - get the monotonic clock in timespec format
400 * @ts: pointer to timespec variable
401 *
402 * The function calculates the monotonic clock from the realtime
403 * clock and the wall_to_monotonic offset and stores the result
404 * in normalized timespec format in the variable pointed to by @ts.
405 */
406void ktime_get_ts(struct timespec *ts)
407{
408 struct timespec tomono;
409 unsigned long seq;
410
411 do {
412 seq = read_seqbegin(&xtime_lock);
413 getnstimeofday(ts);
414 tomono = wall_to_monotonic;
415
416 } while (read_seqretry(&xtime_lock, seq));
417
418 set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec,
419 ts->tv_nsec + tomono.tv_nsec);
420}
421EXPORT_SYMBOL_GPL(ktime_get_ts);
422
423#endif /* !GENERIC_TIME */
424
425/** 379/**
426 * ktime_get_real - get the real (wall-) time in ktime_t format 380 * ktime_get_real - get the real (wall-) time in ktime_t format
427 * 381 *
@@ -579,9 +533,9 @@ static int timekeeping_resume(struct sys_device *dev)
579 533
580 if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) { 534 if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) {
581 ts = timespec_sub(ts, timekeeping_suspend_time); 535 ts = timespec_sub(ts, timekeeping_suspend_time);
582 xtime = timespec_add_safe(xtime, ts); 536 xtime = timespec_add(xtime, ts);
583 wall_to_monotonic = timespec_sub(wall_to_monotonic, ts); 537 wall_to_monotonic = timespec_sub(wall_to_monotonic, ts);
584 total_sleep_time = timespec_add_safe(total_sleep_time, ts); 538 total_sleep_time = timespec_add(total_sleep_time, ts);
585 } 539 }
586 /* re-base the last cycle value */ 540 /* re-base the last cycle value */
587 timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock); 541 timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock);
@@ -784,10 +738,11 @@ void update_wall_time(void)
784 return; 738 return;
785 739
786 clock = timekeeper.clock; 740 clock = timekeeper.clock;
787#ifdef CONFIG_GENERIC_TIME 741
788 offset = (clock->read(clock) - clock->cycle_last) & clock->mask; 742#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
789#else
790 offset = timekeeper.cycle_interval; 743 offset = timekeeper.cycle_interval;
744#else
745 offset = (clock->read(clock) - clock->cycle_last) & clock->mask;
791#endif 746#endif
792 timekeeper.xtime_nsec = (s64)xtime.tv_nsec << timekeeper.shift; 747 timekeeper.xtime_nsec = (s64)xtime.tv_nsec << timekeeper.shift;
793 748
@@ -856,7 +811,8 @@ void update_wall_time(void)
856 } 811 }
857 812
858 /* check to see if there is a new clocksource to use */ 813 /* check to see if there is a new clocksource to use */
859 update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult); 814 update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
815 timekeeper.mult);
860} 816}
861 817
862/** 818/**
@@ -887,7 +843,7 @@ EXPORT_SYMBOL_GPL(getboottime);
887 */ 843 */
888void monotonic_to_bootbased(struct timespec *ts) 844void monotonic_to_bootbased(struct timespec *ts)
889{ 845{
890 *ts = timespec_add_safe(*ts, total_sleep_time); 846 *ts = timespec_add(*ts, total_sleep_time);
891} 847}
892EXPORT_SYMBOL_GPL(monotonic_to_bootbased); 848EXPORT_SYMBOL_GPL(monotonic_to_bootbased);
893 849
@@ -902,6 +858,11 @@ struct timespec __current_kernel_time(void)
902 return xtime; 858 return xtime;
903} 859}
904 860
861struct timespec __get_wall_to_monotonic(void)
862{
863 return wall_to_monotonic;
864}
865
905struct timespec current_kernel_time(void) 866struct timespec current_kernel_time(void)
906{ 867{
907 struct timespec now; 868 struct timespec now;
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index c7683fd8a03a..6eb97bbdefb1 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -153,7 +153,7 @@ config IRQSOFF_TRACER
153 bool "Interrupts-off Latency Tracer" 153 bool "Interrupts-off Latency Tracer"
154 default n 154 default n
155 depends on TRACE_IRQFLAGS_SUPPORT 155 depends on TRACE_IRQFLAGS_SUPPORT
156 depends on GENERIC_TIME 156 depends on !ARCH_USES_GETTIMEOFFSET
157 select TRACE_IRQFLAGS 157 select TRACE_IRQFLAGS
158 select GENERIC_TRACER 158 select GENERIC_TRACER
159 select TRACER_MAX_TRACE 159 select TRACER_MAX_TRACE
@@ -175,7 +175,7 @@ config IRQSOFF_TRACER
175config PREEMPT_TRACER 175config PREEMPT_TRACER
176 bool "Preemption-off Latency Tracer" 176 bool "Preemption-off Latency Tracer"
177 default n 177 default n
178 depends on GENERIC_TIME 178 depends on !ARCH_USES_GETTIMEOFFSET
179 depends on PREEMPT 179 depends on PREEMPT
180 select GENERIC_TRACER 180 select GENERIC_TRACER
181 select TRACER_MAX_TRACE 181 select TRACER_MAX_TRACE