timers/timekeeping for 2.6.32
Subsystems (11)
Linus,
Please pull the latest timers-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git timers-for-linus
The changes in arch/arm, m68knommu, mips, powerpc, s390, sh, x86 and xtensa are fixups due to API changes in the core code.
Thanks,
tglx
------------------>
Hiroshi Shimamoto (1):
timekeeping: Fix invalid getboottime() value
John Stultz (2):
timekeeping: Introduce timekeeping_leap_insert
time: Introduce CLOCK_REALTIME_COARSE
Martin Schwidefsky (19):
timekeeping: optimized ktime_get[_ts] for GENERIC_TIME=y
timers: Cache __next_timer_interrupt result
timekeeping: Remove clocksource inline functions
timekeeping: Move reset of cycle_last for tsc clocksource to tsc
clocksource: Cleanup clocksource selection
clocksource: Delay clocksource watchdog highres enablement
clocksource: Simplify clocksource watchdog resume logic
clocksource: Refactor clocksource watchdog
clocksource: Move watchdog downgrade to a work queue thread
timekeeping: Introduce struct timekeeper
timekeeping: Add xtime_shift and ntp_error_shift to struct timekeeper
timekeeping: Move NTP adjusted clock multiplier to struct timekeeper
timekeeping: Add timekeeper read_clock helper functions
timekeeping: Update clocksource with stop_machine
timekeeping: Increase granularity of read_persistent_clock()
timekeeping: Introduce read_boot_clock
clocksource: Avoid clocksource watchdog circular locking dependency
timekeeping: Increase granularity of read_persistent_clock(), build fix
clocksource: Resolve cpu hotplug dead lock with TSC unstable, fix crash
Paul Mundt (1):
timekeeping: Fix up read_persistent_clock() breakage on sh
Peter Zijlstra (1):
hrtimer: Remove cb_entry from struct hrtimer
Randy Dunlap (2):
timer.c: Fix S/390 comments
timers: Drop a function prototype
Thomas Gleixner (8):
timekeeping: Move ktime_get() functions to timekeeping.c
clocksource: Call clocksource_change_rating() outside of watchdog_lock
clocksource: Protect the watchdog rating changes with clocksource_mutex
x86: Do not unregister PIT clocksource on PIT oneshot setup/shutdown
clocksource: Resolve cpu hotplug dead lock with TSC unstable
clocksource: clocksource_select must be called with mutex locked
clocksource: Delay clocksource down rating to late boot
time: Prevent 32 bit overflow with set_normalized_timespec()
arch/arm/plat-omap/common.c | 7 +- arch/m68knommu/kernel/time.c | 5 +- arch/mips/dec/time.c | 5 +- arch/mips/lasat/ds1603.c | 5 +- arch/mips/lasat/sysctl.c | 8 +- arch/mips/lemote/lm2e/setup.c | 5 +- arch/mips/mti-malta/malta-time.c | 5 +- arch/mips/pmc-sierra/yosemite/setup.c | 5 +- arch/mips/sibyte/swarm/setup.c | 15 +- arch/mips/sni/time.c | 5 +- arch/powerpc/kernel/time.c | 19 +- arch/s390/kernel/time.c | 38 +-- arch/sh/kernel/time.c | 6 +- arch/x86/include/asm/vgtod.h | 1 + arch/x86/kernel/i8253.c | 19 -- arch/x86/kernel/rtc.c | 5 +- arch/x86/kernel/tsc.c | 14 +- arch/x86/kernel/vsyscall_64.c | 1 + arch/x86/vdso/vclock_gettime.c | 39 +++- arch/xtensa/kernel/time.c | 5 +- include/linux/clocksource.h | 122 +------- include/linux/hrtimer.h | 2 - include/linux/time.h | 10 +- include/linux/timer.h | 5 - kernel/hrtimer.c | 57 ---- kernel/posix-timers.c | 35 +++ kernel/time.c | 9 +- kernel/time/clocksource.c | 529 +++++++++++++++++++-------------- kernel/time/jiffies.c | 6 +- kernel/time/ntp.c | 7 +- kernel/time/timekeeping.c | 535 ++++++++++++++++++++++++-------- kernel/timer.c | 28 ++- 32 files changed, 917 insertions(+), 640 deletions(-)
arch/arm/plat-omap/common.c +2 -5
@@ -253,11 +253,8 @@ static struct clocksource clocksource_32k = {*/ unsigned long long sched_clock (void ) { -unsigned long long ret; - - ret = (unsigned long long )clocksource_32k.read (&clocksource_32k); - ret = (ret * clocksource_32k.mult_orig) >> clocksource_32k.shift; -return ret; +return clocksource_cyc2ns (clocksource_32k.read (&clocksource_32k), + clocksource_32k.mult, clocksource_32k.shift); }static int __init omap_init_clocksource_32k (void )
arch/m68knommu/kernel/time.c +3 -2
@@ -72,9 +72,10 @@ static unsigned long read_rtc_mmss(void)return mktime (year, mon, day, hour, min, sec);; } -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) { -return read_rtc_mmss (); + ts->tv_sec =read_rtc_mmss (); + ts->tv_nsec =0 ; }int update_persistent_clock (struct timespec now)
arch/mips/dec/time.c +3 -2
@@ -18,7 +18,7 @@#include <asm/dec/ioasic.h> #include <asm/dec/machtype.h> -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) {unsigned int year, mon, day, hour, min, sec, real_year;unsigned long flags;
@@ -53,7 +53,8 @@ unsigned long read_persistent_clock(void) year += real_year -72 +2000 ; -return mktime (year, mon, day, hour, min, sec); + ts->tv_sec =mktime (year, mon, day, hour, min, sec); + ts->tv_nsec =0 ; }/*
arch/mips/lasat/ds1603.c +3 -2
@@ -135,7 +135,7 @@ static void rtc_end_op(void)lasat_ndelay (1000 ); } -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) {unsigned long word;unsigned long flags;
@@ -147,7 +147,8 @@ unsigned long read_persistent_clock(void)rtc_end_op ();spin_unlock_irqrestore (&rtc_lock, flags); -return word; + ts->tv_sec = word; + ts->tv_nsec =0 ; }int rtc_mips_set_mmss (unsigned long time)
arch/mips/lasat/sysctl.c +6 -2
@@ -92,10 +92,12 @@ static int rtctmp;int proc_dolasatrtc (ctl_table *table,int write,struct file *filp,void *buffer,size_t *lenp,loff_t *ppos) { +struct timespec ts;int r;if (!write) { - rtctmp =read_persistent_clock (); +read_persistent_clock (&ts); + rtctmp = ts.tv_sec;/* check for time < 0 and set to 0 */ if (rtctmp <0 ) rtctmp =0 ;
@@ -134,9 +136,11 @@ int sysctl_lasat_rtc(ctl_table *table, void *oldval, size_t *oldlenp, void *newval, size_t newlen) { + struct timespec ts;int r; - rtctmp =read_persistent_clock (); +read_persistent_clock (&ts); + rtctmp = ts.tv_sec;if (rtctmp <0 ) rtctmp =0 ; r =sysctl_intvec (table, oldval, oldlenp, newval, newlen);
arch/mips/lemote/lm2e/setup.c +3 -2
@@ -54,9 +54,10 @@ void __init plat_time_init(void) mips_hpt_frequency = cpu_clock_freq /2 ; } -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) { -return mc146818_get_cmos_time (); + ts->tv_sec =mc146818_get_cmos_time (); + ts->tv_nsec =0 ; }void (*__wbflush)(void );
arch/mips/mti-malta/malta-time.c +3 -2
@@ -100,9 +100,10 @@ static unsigned int __init estimate_cpu_frequency(void)return count; } -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) { -return mc146818_get_cmos_time (); + ts->tv_sec =mc146818_get_cmos_time (); + ts->tv_nsec =0 ; }static void __init plat_perf_setup (void )
arch/mips/pmc-sierra/yosemite/setup.c +3 -2
@@ -70,7 +70,7 @@ void __init bus_error_init(void) } -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) {unsigned int year, month, day, hour, min, sec;unsigned long flags;
@@ -92,7 +92,8 @@ unsigned long read_persistent_clock(void) m48t37_base->control =0x00 ;spin_unlock_irqrestore (&rtc_lock, flags); -return mktime (year, month, day, hour, min, sec); + ts->tv_sec =mktime (year, month, day, hour, min, sec); + ts->tv_nsec =0 ; }int rtc_mips_set_time (unsigned long tim)
arch/mips/sibyte/swarm/setup.c +11 -4
@@ -87,19 +87,26 @@ enum swarm_rtc_type {enum swarm_rtc_type swarm_rtc_type; -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) { +unsigned long sec; +switch (swarm_rtc_type) {case RTC_XICOR : -return xicor_get_time (); + sec =xicor_get_time (); +break ;case RTC_M4LT81 : -return m41t81_get_time (); + sec =m41t81_get_time (); +break ;case RTC_NONE :default : -return mktime (2000 ,1 ,1 ,0 ,0 ,0 ); + sec =mktime (2000 ,1 ,1 ,0 ,0 ,0 ); +break ; } + ts->tv_sec = sec; + tv->tv_nsec =0 ; }int rtc_mips_set_time (unsigned long sec)
arch/mips/sni/time.c +3 -2
@@ -182,7 +182,8 @@ void __init plat_time_init(void)setup_pit_timer (); } -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) { -return -1 ; + ts->tv_sec =-1 ; + ts->tv_nsec =0 ; }
arch/powerpc/kernel/time.c +12 -7
@@ -769,11 +769,12 @@ int update_persistent_clock(struct timespec now)return ppc_md.set_rtc_time (&tm); } -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) {struct rtc_time tm;static int first =1 ; + ts->tv_nsec =0 ;/* XXX this is a litle fragile but will work okay in the short term */ if (first) { first =0 ;
@@ -781,14 +782,18 @@ unsigned long read_persistent_clock(void) timezone_offset = ppc_md.time_init ();/* get_boot_time() isn't guaranteed to be safe to call late */ -if (ppc_md.get_boot_time) -return ppc_md.get_boot_time () -timezone_offset; +if (ppc_md.get_boot_time) { + ts->tv_sec = ppc_md.get_boot_time () - timezone_offset; +return ; + } + } +if (!ppc_md.get_rtc_time) { + ts->tv_sec =0 ; +return ; } -if (!ppc_md.get_rtc_time) -return 0 ; ppc_md.get_rtc_time (&tm); -return mktime (tm.tm_year+1900 , tm.tm_mon+1 , tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); + ts->tv_sec =mktime (tm.tm_year+1900 , tm.tm_mon+1 , tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); }/* clocksource code */
arch/s390/kernel/time.c +10 -28
@@ -182,12 +182,14 @@ static void timing_alert_interrupt(__u16 code)static void etr_reset (void );static void stp_reset (void ); -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) { -struct timespec ts; +tod_to_timeval (get_clock () -TOD_UNIX_EPOCH , ts); +} -tod_to_timeval (get_clock () -TOD_UNIX_EPOCH , &ts); -return ts.tv_sec; +void read_boot_clock (struct timespec *ts) +{ +tod_to_timeval (sched_clock_base_cc -TOD_UNIX_EPOCH , ts); }static cycle_t read_tod_clock (struct clocksource *cs)
@@ -205,6 +207,10 @@ static struct clocksource clocksource_tod = { .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; +struct clocksource *__init clocksource_default_clock (void ) +{ +return &clocksource_tod; +}void update_vsyscall (struct timespec *wall_time,struct clocksource *clock) {
@@ -242,10 +248,6 @@ void update_vsyscall_tz(void)*/ void __init time_init (void ) { -struct timespec ts; -unsigned long flags; -cycle_t now; -/* Reset time synchronization interfaces. */ etr_reset ();stp_reset ();
@@ -261,26 +263,6 @@ void __init time_init(void)if (clocksource_register (&clocksource_tod) !=0 )panic ("Could not register TOD clock source" ); -/* -* The TOD clock is an accurate clock. The xtime should be -* initialized in a way that the difference between TOD and -* xtime is reasonably small. Too bad that timekeeping_init -* sets xtime.tv_nsec to zero. In addition the clock source -* change from the jiffies clock source to the TOD clock -* source add another error of up to 1/HZ second. The same -* function sets wall_to_monotonic to a value that is too -* small for /proc/uptime to be accurate. -* Reset xtime and wall_to_monotonic to sane values. -*/ -write_seqlock_irqsave (&xtime_lock, flags); - now =get_clock (); -tod_to_timeval (now -TOD_UNIX_EPOCH , &xtime); - clocksource_tod.cycle_last = now; - clocksource_tod.raw_time = xtime; -tod_to_timeval (sched_clock_base_cc -TOD_UNIX_EPOCH , &ts); -set_normalized_timespec (&wall_to_monotonic, -ts.tv_sec, -ts.tv_nsec); -write_sequnlock_irqrestore (&xtime_lock, flags); -/* Enable TOD clock interrupts on the boot cpu. */ init_cpu_timer ();
arch/sh/kernel/time.c +2 -4
@@ -39,11 +39,9 @@ void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time;int (*rtc_sh_set_time)(const time_t ) = null_rtc_set_time;#ifdef CONFIG_GENERIC_CMOS_UPDATE -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) { -struct timespec tv; -rtc_sh_get_time (&tv); -return tv.tv_sec; +rtc_sh_get_time (ts); }int update_persistent_clock (struct timespec now)
arch/x86/include/asm/vgtod.h +1 -0
@@ -21,6 +21,7 @@ struct vsyscall_gtod_data {u32 shift; } clock;struct timespec wall_to_monotonic; +struct timespec wall_time_coarse; }; extern struct vsyscall_gtod_data __vsyscall_gtod_data __section_vsyscall_gtod_data;
arch/x86/kernel/i8253.c +0 -19
@@ -19,12 +19,6 @@DEFINE_SPINLOCK (i8253_lock);EXPORT_SYMBOL (i8253_lock); -#ifdef CONFIG_X86_32 -static void pit_disable_clocksource (void ); -#else -static inline void pit_disable_clocksource (void ) { } -#endif -/* * HPET replaces the PIT, when enabled. So we need to know, which of * the two timers is used
@@ -57,12 +51,10 @@ static void init_pit_timer(enum clock_event_mode mode,outb_pit (0 ,PIT_CH0 );outb_pit (0 ,PIT_CH0 ); } -pit_disable_clocksource ();break ;case CLOCK_EVT_MODE_ONESHOT :/* One shot setup */ -pit_disable_clocksource ();outb_pit (0x38 ,PIT_MODE );break ;
@@ -200,17 +192,6 @@ static struct clocksource pit_cs = { .shift = 20, }; -static void pit_disable_clocksource (void ) -{ -/* -* Use mult to check whether it is registered or not -*/ -if (pit_cs.mult) { -clocksource_unregister (&pit_cs); - pit_cs.mult =0 ; - } -} -static int __init init_pit_clocksource (void ) {/*
arch/x86/kernel/rtc.c +3 -2
@@ -178,7 +178,7 @@ static int set_rtc_mmss(unsigned long nowtime) }/* not static: needed by APM */ -unsigned long read_persistent_clock (void ) +void read_persistent_clock (struct timespec *ts) {unsigned long retval, flags;
@@ -186,7 +186,8 @@ unsigned long read_persistent_clock(void) retval =get_wallclock ();spin_unlock_irqrestore (&rtc_lock, flags); -return retval; + ts->tv_sec = retval; + ts->tv_nsec =0 ; }int update_persistent_clock (struct timespec now)
arch/x86/kernel/tsc.c +11 -3
@@ -744,10 +744,16 @@ static cycle_t __vsyscall_fn vread_tsc(void) }#endif +static void resume_tsc (void ) +{ + clocksource_tsc.cycle_last =0 ; +} +static struct clocksource clocksource_tsc = { .name ="tsc" , .rating =300 , .read = read_tsc, + .resume = resume_tsc, .mask =CLOCKSOURCE_MASK (64 ), .shift =22 , .flags = CLOCK_SOURCE_IS_CONTINUOUS |
@@ -761,12 +767,14 @@ void mark_tsc_unstable(char *reason) {if (!tsc_unstable) { tsc_unstable =1 ; -printk ("Marking TSC unstable due to %s\n" , reason); +printk (KERN_INFO "Marking TSC unstable due to %s\n" , reason);/* Change only the rating, when not registered */ if (clocksource_tsc.mult) -clocksource_change_rating (&clocksource_tsc,0 ); -else +clocksource_mark_unstable (&clocksource_tsc); +else { + clocksource_tsc.flags |=CLOCK_SOURCE_UNSTABLE ; clocksource_tsc.rating =0 ; + } } }
arch/x86/kernel/vsyscall_64.c +1 -0
@@ -87,6 +87,7 @@ void update_vsyscall(struct timespec *wall_time, struct clocksource *clock) vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec; vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec; vsyscall_gtod_data.wall_to_monotonic = wall_to_monotonic; + vsyscall_gtod_data.wall_time_coarse =__current_kernel_time ();write_sequnlock_irqrestore (&vsyscall_gtod_data.lock, flags); }
arch/x86/vdso/vclock_gettime.c +36 -3
@@ -86,14 +86,47 @@ notrace static noinline int do_monotonic(struct timespec *ts)return 0 ; } +notrace static noinline int do_realtime_coarse(struct timespec *ts) +{ +unsigned long seq; +do { + seq =read_seqbegin (>od->lock); + ts->tv_sec = gtod->wall_time_coarse.tv_sec; + ts->tv_nsec = gtod->wall_time_coarse.tv_nsec; + }while (unlikely (read_seqretry (>od->lock, seq))); +return 0 ; +} + +notrace static noinline int do_monotonic_coarse(struct timespec *ts) +{ +unsigned long seq, ns, secs; +do { + seq =read_seqbegin (>od->lock); + secs = gtod->wall_time_coarse.tv_sec; + ns = gtod->wall_time_coarse.tv_nsec; + secs += gtod->wall_to_monotonic.tv_sec; + ns += gtod->wall_to_monotonic.tv_nsec; + }while (unlikely (read_seqretry (>od->lock, seq))); +vset_normalized_timespec (ts, secs, ns); +return 0 ; +} + notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts) { -if (likely (gtod->sysctl_enabled && gtod->clock.vread)) +if (likely (gtod->sysctl_enabled))switch (clock) {case CLOCK_REALTIME : -return do_realtime (ts); +if (likely (gtod->clock.vread)) +return do_realtime (ts); +break ;case CLOCK_MONOTONIC : -return do_monotonic (ts); +if (likely (gtod->clock.vread)) +return do_monotonic (ts); +break ; +case CLOCK_REALTIME_COARSE : +return do_realtime_coarse (ts); +case CLOCK_MONOTONIC_COARSE : +return do_monotonic_coarse (ts); }return vdso_fallback_gettime (clock, ts); }
arch/xtensa/kernel/time.c +2 -3
@@ -59,9 +59,8 @@ static struct irqaction timer_irqaction = {void __init time_init (void ) { - xtime.tv_nsec =0 ; - xtime.tv_sec =read_persistent_clock (); - +/* FIXME: xtime&wall_to_monotonic are set in timekeeping_init. */ +read_persistent_clock (&xtime);set_normalized_timespec (&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
include/linux/clocksource.h +11 -111
189 lines not on this page · raw message
include/linux/hrtimer.h +0 -2
@@ -91,7 +91,6 @@ enum hrtimer_restart {* @function: timer expiry callback function * @base: pointer to the timer base (per cpu and per clock) * @state: state information (See bit values above) -* @cb_entry: list head to enqueue an expired timer into the callback list * @start_site: timer statistics field to store the site where the timer * was started * @start_comm: timer statistics field to store the name of the process which
@@ -108,7 +107,6 @@ struct hrtimer {enum hrtimer_restart (*function)(struct hrtimer *);struct hrtimer_clock_base *base;unsigned long state; -struct list_head cb_entry;#ifdef CONFIG_TIMER_STATS int start_pid;void *start_site;
include/linux/time.h +8 -2
@@ -75,7 +75,7 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon, const unsigned int day, const unsigned int hour, const unsigned int min, const unsigned int sec); -extern void set_normalized_timespec (struct timespec *ts,time_t sec,long nsec); +extern void set_normalized_timespec (struct timespec *ts,time_t sec,s64 nsec);extern struct timespec timespec_add_safe (const struct timespec lhs,const struct timespec rhs);
@@ -101,7 +101,8 @@ extern struct timespec xtime;extern struct timespec wall_to_monotonic;extern seqlock_t xtime_lock; -extern unsigned long read_persistent_clock (void ); +extern void read_persistent_clock (struct timespec *ts); +extern void read_boot_clock (struct timespec *ts);extern int update_persistent_clock (struct timespec now);extern int no_sync_cmos_clock__read_mostly ;void timekeeping_init (void );
@@ -109,6 +110,8 @@ extern int timekeeping_suspended;unsigned long get_seconds (void );struct timespec current_kernel_time (void ); +struct timespec __current_kernel_time (void );/* does not hold xtime_lock */ +struct timespec get_monotonic_coarse (void );#define CURRENT_TIME (current_kernel_time())#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 })
@@ -147,6 +150,7 @@ extern struct timespec timespec_trunc(struct timespec t, unsigned gran);extern int timekeeping_valid_for_hres (void );extern void update_wall_time (void );extern void update_xtime_cache (u64 nsec); +extern void timekeeping_leap_insert (int leapsecond);struct tms ;extern void do_sys_times (struct tms *);
@@ -241,6 +245,8 @@ struct itimerval {#define CLOCK_PROCESS_CPUTIME_ID 2#define CLOCK_THREAD_CPUTIME_ID 3#define CLOCK_MONOTONIC_RAW 4 +#define CLOCK_REALTIME_COARSE 5 +#define CLOCK_MONOTONIC_COARSE 6/* * The IDs of various hardware clocks:
include/linux/timer.h +0 -5
@@ -175,11 +175,6 @@ extern int mod_timer_pinned(struct timer_list *timer, unsigned long expires);/* * Return when the next timer-wheel timeout occurs (in absolute jiffies), -* locks the timer base: -*/ -extern unsigned long next_timer_interrupt (void ); -/* -* Return when the next timer-wheel timeout occurs (in absolute jiffies), * locks the timer base and does the comparison against the given * jiffie. */
kernel/hrtimer.c +0 -57
75 lines not on this page · raw message
kernel/posix-timers.c +35 -0
@@ -242,6 +242,25 @@ static int posix_get_monotonic_raw(clockid_t which_clock, struct timespec *tp)return 0 ; } + +static int posix_get_realtime_coarse (clockid_t which_clock,struct timespec *tp) +{ + *tp =current_kernel_time (); +return 0 ; +} + +static int posix_get_monotonic_coarse (clockid_t which_clock, +struct timespec *tp) +{ + *tp =get_monotonic_coarse (); +return 0 ; +} + +int posix_get_coarse_res (const clockid_t which_clock,struct timespec *tp) +{ + *tp =ktime_to_timespec (KTIME_LOW_RES ); +return 0 ; +}/* * Initialize everything, well, just everything in Posix clocks/timers ;) */
@@ -262,10 +281,26 @@ static __init int init_posix_timers(void) .timer_create = no_timer_create, .nsleep = no_nsleep, }; +struct k_clock clock_realtime_coarse = { + .clock_getres = posix_get_coarse_res, + .clock_get = posix_get_realtime_coarse, + .clock_set = do_posix_clock_nosettime, + .timer_create = no_timer_create, + .nsleep = no_nsleep, + }; +struct k_clock clock_monotonic_coarse = { + .clock_getres = posix_get_coarse_res, + .clock_get = posix_get_monotonic_coarse, + .clock_set = do_posix_clock_nosettime, + .timer_create = no_timer_create, + .nsleep = no_nsleep, + };register_posix_clock (CLOCK_REALTIME , &clock_realtime);register_posix_clock (CLOCK_MONOTONIC , &clock_monotonic);register_posix_clock (CLOCK_MONOTONIC_RAW , &clock_monotonic_raw); +register_posix_clock (CLOCK_REALTIME_COARSE , &clock_realtime_coarse); +register_posix_clock (CLOCK_MONOTONIC_COARSE , &clock_monotonic_coarse); posix_timers_cache = kmem_cache_create("posix_timers_cache", sizeof (struct k_itimer), 0, SLAB_PANIC,
kernel/time.c +8 -1
@@ -370,13 +370,20 @@ EXPORT_SYMBOL(mktime);* 0 <= tv_nsec < NSEC_PER_SEC * For negative values only the tv_sec field is negative ! */ -void set_normalized_timespec (struct timespec *ts,time_t sec,long nsec) +void set_normalized_timespec (struct timespec *ts,time_t sec,s64 nsec) {while (nsec >=NSEC_PER_SEC ) { +/* +* The following asm() prevents the compiler from +* optimising this loop into a modulo operation. See +* also __iter_div_u64_rem() in include/linux/time.h +*/ + asm("" :"+rm" (nsec)); nsec -=NSEC_PER_SEC ; ++sec; }while (nsec <0 ) { + asm("" :"+rm" (nsec)); nsec +=NSEC_PER_SEC ; --sec; }
kernel/time/clocksource.c +304 -225
734 lines not on this page · raw message
kernel/time/jiffies.c +5 -1
@@ -61,7 +61,6 @@ struct clocksource clocksource_jiffies = { .read = jiffies_read, .mask = 0xffffffff, /*32bits*/ .mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */ - .mult_orig = NSEC_PER_JIFFY << JIFFIES_SHIFT, .shift = JIFFIES_SHIFT, };
@@ -71,3 +70,8 @@ static int __init init_jiffies_clocksource(void) }core_initcall (init_jiffies_clocksource); + +struct clocksource *__init __weak clocksource_default_clock (void ) +{ +return &clocksource_jiffies; +}
kernel/time/ntp.c +2 -5
@@ -194,8 +194,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)case TIME_OK :break ;case TIME_INS : - xtime.tv_sec--; - wall_to_monotonic.tv_sec++; +timekeeping_leap_insert (-1 ); time_state =TIME_OOP ;printk (KERN_NOTICE "Clock: inserting leap second 23:59:60 UTC\n" );
@@ -203,9 +202,8 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer) res =HRTIMER_RESTART ;break ;case TIME_DEL : - xtime.tv_sec++; +timekeeping_leap_insert (1 ); time_tai--; - wall_to_monotonic.tv_sec--; time_state =TIME_WAIT ;printk (KERN_NOTICE "Clock: deleting leap second 23:59:59 UTC\n" );
@@ -219,7 +217,6 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer) time_state =TIME_OK ;break ; } -update_vsyscall (&xtime, clock);write_sequnlock (&xtime_lock);
kernel/time/timekeeping.c +401 -134
804 lines not on this page · raw message
kernel/timer.c +25 -3
@@ -72,6 +72,7 @@ struct tvec_base {spinlock_t lock;struct timer_list *running_timer;unsigned long timer_jiffies; +unsigned long next_timer;struct tvec_root tv1;struct tvec tv2;struct tvec tv3;
@@ -622,6 +623,9 @@ __mod_timer(struct timer_list *timer, unsigned long expires,if (timer_pending (timer)) {detach_timer (timer,0 ); +if (timer->expires == base->next_timer && + !tbase_get_deferrable (timer->base)) + base->next_timer = base->timer_jiffies; ret =1 ; }else {if (pending_only)
@@ -663,6 +667,9 @@ __mod_timer(struct timer_list *timer, unsigned long expires, } timer->expires = expires; +if (time_before (timer->expires, base->next_timer) && + !tbase_get_deferrable (timer->base)) + base->next_timer = timer->expires;internal_add_timer (base, timer); out_unlock:
@@ -781,6 +788,9 @@ void add_timer_on(struct timer_list *timer, int cpu)spin_lock_irqsave (&base->lock, flags);timer_set_base (timer, base);debug_timer_activate (timer); +if (time_before (timer->expires, base->next_timer) && + !tbase_get_deferrable (timer->base)) + base->next_timer = timer->expires;internal_add_timer (base, timer);/* * Check whether the other CPU is idle and needs to be
@@ -817,6 +827,9 @@ int del_timer(struct timer_list *timer) base =lock_timer_base (timer, &flags);if (timer_pending (timer)) {detach_timer (timer,1 ); +if (timer->expires == base->next_timer && + !tbase_get_deferrable (timer->base)) + base->next_timer = base->timer_jiffies; ret =1 ; }spin_unlock_irqrestore (&base->lock, flags);
@@ -850,6 +863,9 @@ int try_to_del_timer_sync(struct timer_list *timer) ret =0 ;if (timer_pending (timer)) {detach_timer (timer,1 ); +if (timer->expires == base->next_timer && + !tbase_get_deferrable (timer->base)) + base->next_timer = base->timer_jiffies; ret =1 ; } out:
@@ -1007,8 +1023,8 @@ static inline void __run_timers(struct tvec_base *base)#ifdef CONFIG_NO_HZ /* * Find out when the next timer event is due to happen. This -* is used on S/390 to stop all activity when a cpus is idle. -* This functions needs to be called disabled. +* is used on S/390 to stop all activity when a CPU is idle. +* This function needs to be called with interrupts disabled. */ static unsigned long __next_timer_interrupt (struct tvec_base *base) {
@@ -1134,7 +1150,9 @@ unsigned long get_next_timer_interrupt(unsigned long now)unsigned long expires;spin_lock (&base->lock); - expires =__next_timer_interrupt (base); +if (time_before_eq (base->next_timer, base->timer_jiffies)) + base->next_timer =__next_timer_interrupt (base); + expires = base->next_timer;spin_unlock (&base->lock);if (time_before_eq (expires, now))
@@ -1523,6 +1541,7 @@ static int __cpuinit init_timers_cpu(int cpu)INIT_LIST_HEAD (base->tv1.vec + j); base->timer_jiffies = jiffies; + base->next_timer = base->timer_jiffies;return 0 ; }
@@ -1535,6 +1554,9 @@ static void migrate_timer_list(struct tvec_base *new_base, struct list_head *hea timer = list_first_entry(head, struct timer_list, entry);detach_timer (timer,0 );timer_set_base (timer, new_base); +if (time_before (timer->expires, new_base->next_timer) && + !tbase_get_deferrable (timer->base)) + new_base->next_timer = timer->expires;internal_add_timer (new_base, timer); } }
Quoted 8 lines · Thomas Gleixner
Linus,
Please pull the latest timers-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.gittimers-for-linusThe changes in
arch/arm, m68knommu, mips, powerpc, s390, sh, x86 and xtensa are fixups due to API changes in the core code.
Linus,
When pulling this you did a merge resolution to arch/mips/loongson/common/time.c in commit a03fdb761, but it looks suspicious:
void read_persistent_clock(struct timespec *ts)
{
ts->tv_sec = return mc146818_get_cmos_time();
ts->tv_nsec = 0;}
that 'return' looks stray, so shouldnt we do the fix below?
Ingo
arch/mips/loongson/common/time.c +1 -1
@@ -23,6 +23,6 @@ void __init plat_time_init(void)void read_persistent_clock (struct timespec *ts) { - ts->tv_sec = return mc146818_get_cmos_time(); + ts->tv_sec =mc146818_get_cmos_time (); ts->tv_nsec =0 ; }
Quoted 5 lines · Ingo Molnar
When pulling this you did a merge resolution to
arch/mips/loongson/common/time.cin commita03fdb761, but it looks suspicious:
Quoted 7 lines
void
read_persistent_clock(struct timespec *ts){ ts->tv_sec = return mc146818_get_cmos_time(); ts->tv_nsec = 0;}
that 'return' looks stray, so shouldnt we do the fix below?
Duh. Too much mousing around to cut-and-paste crap.
Linus