WSL2-Linux-Kernel/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
power [PATCH] swsusp: nuke noisy message 2006-02-15 15:32:22 -08:00
.gitignore
Kconfig.hz
Kconfig.preempt
Makefile
acct.c
audit.c
auditsc.c
capability.c
compat.c [PATCH] remove bogus asm/bug.h includes. 2006-02-07 20:56:35 -05:00
configs.c
cpu.c
cpuset.c [PATCH] cpuset: oops in exit on null cpuset fix 2006-02-15 15:32:21 -08:00
dma.c
exec_domain.c
exit.c
extable.c
fork.c [PATCH] fix kill_proc_info() vs fork() theoretical race 2006-02-15 10:21:24 -08:00
futex.c
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
kexec.c
kfifo.c
kmod.c
kprobes.c [PATCH] Kprobes: Fix deadlock in function-return probes 2006-02-03 08:32:00 -08:00
ksysfs.c
kthread.c
module.c [PATCH] module: strlen_user() race fix 2006-02-07 16:12:32 -08:00
mutex-debug.c
mutex-debug.h
mutex.c
mutex.h
panic.c [PATCH] prevent recursive panic from softlockup watchdog 2006-02-10 08:13:12 -08:00
params.c
pid.c
posix-cpu-timers.c
posix-timers.c [PATCH] kernel/posix-timers.c: remove do_posix_clock_notimer_create() 2006-02-01 08:53:13 -08:00
printk.c
profile.c
ptrace.c [PATCH] fix zap_thread's ptrace related problems 2006-02-15 11:05:43 -08:00
rcupdate.c
rcutorture.c [PATCH] rcu_torture_lock deadlock fix 2006-01-31 11:30:18 -08:00
resource.c
sched.c [PATCH] sched: revert "filter affine wakeups" 2006-02-14 16:09:34 -08:00
seccomp.c
signal.c [PATCH] do_sigaction: cleanup ->sa_mask manipulation 2006-02-09 16:17:36 -08:00
softirq.c
softlockup.c
spinlock.c
stop_machine.c
sys.c [PATCH] kernel/sys.c NULL noise removal 2006-02-07 20:57:47 -05:00
sys_ni.c
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
user.c [PATCH] "Fix uidhash_lock <-> RXU deadlock" fix 2006-01-31 16:49:43 -08:00
wait.c
workqueue.c