linux/kernel
Paul Mackerras 726c14bf49 [PATCH] Provide an interface for getting the current tick length
This provides an interface for arch code to find out how many
nanoseconds are going to be added on to xtime by the next call to
do_timer.  The value returned is a fixed-point number in 52.12 format
in nanoseconds.  The reason for this format is that it gives the
full precision that the timekeeping code is using internally.

The motivation for this is to fix a problem that has arisen on 32-bit
powerpc in that the value returned by do_gettimeofday drifts apart
from xtime if NTP is being used.  PowerPC is now using a lockless
do_gettimeofday based on reading the timebase register and performing
some simple arithmetic.  (This method of getting the time is also
exported to userspace via the VDSO.)  However, the factor and offset
it uses were calculated based on the nominal tick length and weren't
being adjusted when NTP varied the tick length.

Note that 64-bit powerpc has had the lockless do_gettimeofday for a
long time now.  It also had an extremely hairy routine that got called
from the 32-bit compat routine for adjtimex, which adjusted the
factor and offset according to what it thought the timekeeping code
was going to do.  Not only was this only called if a 32-bit task did
adjtimex (i.e. not if a 64-bit task did adjtimex), it was also
duplicating computations from kernel/timer.c and it wasn't clear that
it was (still) correct.

The simple solution is to ask the timekeeping code how long the
current jiffy will be on each timer interrupt, after calling
do_timer.  If this jiffy will be a different length from the last one,
we then need to compute new values for the factor and offset used in
the lockless do_gettimeofday.  In this way we can keep xtime and
do_gettimeofday in sync, even when NTP is varying the tick length.

Note that when adjtimex varies the tick length, it almost always
introduces the variation from the next tick on.  The only case I could
see where adjtimex would vary the length of the current tick is when
an old-style adjtime adjustment is being cancelled.  (It's not clear
to me why the adjustment has to be cancelled immediately rather than
from the next tick on.)  Thus I don't see any real need for a hook in
adjtimex; the rare case of an old-style adjustment being cancelled can
be fixed up at the next tick.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: john stultz <johnstul@us.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-02-17 08:24:29 -08:00
..
irq [PATCH] kernel/: small cleanups 2006-01-08 20:13:48 -08:00
power [PATCH] swsusp: nuke noisy message 2006-02-15 15:32:22 -08:00
.gitignore gitignore: ignore more generated files 2006-01-03 11:35:26 +01:00
Kconfig.hz [PATCH] i386: Selectable Frequency of the Timer Interrupt 2005-06-23 09:45:10 -07:00
Kconfig.preempt [PATCH] sched: voluntary kernel preemption 2005-06-25 16:24:45 -07:00
Makefile [PATCH] build kernel/intermodule.c only when required 2006-01-16 23:15:26 -08:00
acct.c [PATCH] move capable() to capability.h 2006-01-11 18:42:13 -08:00
audit.c [PATCH] EDAC: atomic scrub operations 2006-01-18 19:20:30 -08:00
auditsc.c [PATCH] EDAC: atomic scrub operations 2006-01-18 19:20:30 -08:00
capability.c [PATCH] move capable() to capability.h 2006-01-11 18:42:13 -08:00
compat.c [PATCH] remove bogus asm/bug.h includes. 2006-02-07 20:56:35 -05:00
configs.c update the email address of Randy Dunlap 2006-01-03 13:37:51 +01:00
cpu.c [PATCH] clean up lock_cpu_hotplug() in cpufreq 2005-11-28 14:42:23 -08:00
cpuset.c [PATCH] cpuset: oops in exit on null cpuset fix 2006-02-15 15:32:21 -08:00
dma.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
exec_domain.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
exit.c [PATCH] Unlinline a bunch of other functions 2006-01-14 18:27:06 -08:00
extable.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
fork.c [PATCH] fix kill_proc_info() vs fork() theoretical race 2006-02-15 10:21:24 -08:00
futex.c [PATCH] FRV: Make futex code compilable on nommu [try #2] 2006-01-06 08:33:33 -08:00
hrtimer.c [PATCH] hrtimer: round up relative start time on low-res arches 2006-02-14 16:09:35 -08:00
intermodule.c [PATCH] missing license tag in intermodule 2006-02-05 11:06:52 -08:00
itimer.c [PATCH] hrtimers: fix oldvalue return in setitimer 2006-02-01 08:53:12 -08:00
kallsyms.c [PATCH] fix missing includes 2005-10-30 17:37:32 -08:00
kexec.c [PATCH] move capable() to capability.h 2006-01-11 18:42:13 -08:00
kfifo.c [PATCH] gfp flags annotations - part 1 2005-10-08 15:00:57 -07:00
kmod.c [PATCH] Keys: Get rid of warning in kmod.c if keys disabled 2005-10-30 17:37:23 -08:00
kprobes.c [PATCH] Kprobes: Fix deadlock in function-return probes 2006-02-03 08:32:00 -08:00
ksysfs.c [PATCH] kdump: export per cpu crash notes pointer through sysfs 2006-01-10 08:01:26 -08:00
kthread.c [PATCH] Add kthread_stop_sem() 2005-10-30 17:37:17 -08:00
module.c [PATCH] module: strlen_user() race fix 2006-02-07 16:12:32 -08:00
mutex-debug.c [PATCH] fix/simplify mutex debugging code 2006-01-11 08:14:16 -08:00
mutex-debug.h [PATCH] mutex subsystem, debugging code 2006-01-09 15:59:20 -08:00
mutex.c [PATCH] mutex: trivial whitespace cleanups 2006-01-10 14:27:59 -08:00
mutex.h [PATCH] mutex subsystem, core 2006-01-09 15:59:19 -08:00
panic.c [PATCH] prevent recursive panic from softlockup watchdog 2006-02-10 08:13:12 -08:00
params.c [PATCH] kernel/params.c: fix sysfs access with CONFIG_MODULES=n 2005-12-20 10:31:33 -08:00
pid.c [PATCH] RCU signal handling 2006-01-08 20:13:40 -08:00
posix-cpu-timers.c [PATCH] hrtimer: switch clock_nanosleep to hrtimer nanosleep API 2006-01-10 08:01:38 -08:00
posix-timers.c [PATCH] kernel/posix-timers.c: remove do_posix_clock_notimer_create() 2006-02-01 08:53:13 -08:00
printk.c correct email address of Manfred Spraul 2006-01-15 02:43:54 +01:00
profile.c [PATCH] mostly_read data section 2005-07-07 18:23:46 -07:00
ptrace.c [PATCH] fix zap_thread's ptrace related problems 2006-02-15 11:05:43 -08:00
rcupdate.c [PATCH] rcu: fix hotplug-cpu ->donelist leak 2006-01-10 08:49:47 -08:00
rcutorture.c [PATCH] rcu_torture_lock deadlock fix 2006-01-31 11:30:18 -08:00
resource.c [PATCH] kernel/resource.c: __check_region(): remove pointless __deprecated 2006-01-10 08:02:02 -08:00
sched.c [PATCH] sched: revert "filter affine wakeups" 2006-02-14 16:09:34 -08:00
seccomp.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
signal.c [PATCH] do_sigaction: cleanup ->sa_mask manipulation 2006-02-09 16:17:36 -08:00
softirq.c [PATCH] cpu hoptlug: avoid usage of smp_processor_id() in preemptible code 2005-11-07 07:53:29 -08:00
softlockup.c [PATCH] quieten softlockup at boot 2005-11-09 07:55:50 -08:00
spinlock.c [PATCH] spinlock consolidation 2005-09-10 10:06:21 -07:00
stop_machine.c [PATCH] Remove set_fs() in stop_machine() 2006-01-10 08:01:25 -08:00
sys.c [PATCH] kernel/sys.c NULL noise removal 2006-02-07 20:57:47 -05:00
sys_ni.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc-merge 2006-01-09 10:03:44 -08:00
sysctl.c [PATCH] x86_64: Add boot option to disable randomized mappings and cleanup 2006-02-17 08:00:40 -08:00
time.c [PATCH] Normalize timespec for negative values in ns_to_timespec 2006-02-03 08:32:06 -08:00
timer.c [PATCH] Provide an interface for getting the current tick length 2006-02-17 08:24:29 -08:00
uid16.c [PATCH] move capable() to capability.h 2006-01-11 18:42:13 -08:00
user.c [PATCH] "Fix uidhash_lock <-> RXU deadlock" fix 2006-01-31 16:49:43 -08:00
wait.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
workqueue.c [PATCH] Unlinline a bunch of other functions 2006-01-14 18:27:06 -08:00