mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-13 23:34:05 +08:00
time: Convert x86_64 to using new update_vsyscall
Switch x86_64 to using sub-ns precise vsyscall Cc: Tony Luck <tony.luck@intel.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Paul Turner <pjt@google.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Richard Cochran <richardcochran@gmail.com> Cc: Prarit Bhargava <prarit@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
This commit is contained in:
parent
92bb1fcf57
commit
650ea02475
@ -93,7 +93,7 @@ config X86
|
||||
select GENERIC_CLOCKEVENTS
|
||||
select ARCH_CLOCKSOURCE_DATA if X86_64
|
||||
select GENERIC_CLOCKEVENTS_BROADCAST if X86_64 || (X86_32 && X86_LOCAL_APIC)
|
||||
select GENERIC_TIME_VSYSCALL_OLD if X86_64
|
||||
select GENERIC_TIME_VSYSCALL if X86_64
|
||||
select KTIME_SCALAR if X86_32
|
||||
select GENERIC_STRNCPY_FROM_USER
|
||||
select GENERIC_STRNLEN_USER
|
||||
|
@ -17,8 +17,8 @@ struct vsyscall_gtod_data {
|
||||
|
||||
/* open coded 'struct timespec' */
|
||||
time_t wall_time_sec;
|
||||
u32 wall_time_nsec;
|
||||
u32 monotonic_time_nsec;
|
||||
u64 wall_time_snsec;
|
||||
u64 monotonic_time_snsec;
|
||||
time_t monotonic_time_sec;
|
||||
|
||||
struct timezone sys_tz;
|
||||
|
@ -82,32 +82,41 @@ void update_vsyscall_tz(void)
|
||||
vsyscall_gtod_data.sys_tz = sys_tz;
|
||||
}
|
||||
|
||||
void update_vsyscall_old(struct timespec *wall_time, struct timespec *wtm,
|
||||
struct clocksource *clock, u32 mult)
|
||||
void update_vsyscall(struct timekeeper *tk)
|
||||
{
|
||||
struct timespec monotonic;
|
||||
struct vsyscall_gtod_data *vdata = &vsyscall_gtod_data;
|
||||
|
||||
write_seqcount_begin(&vsyscall_gtod_data.seq);
|
||||
write_seqcount_begin(&vdata->seq);
|
||||
|
||||
/* copy vsyscall data */
|
||||
vsyscall_gtod_data.clock.vclock_mode = clock->archdata.vclock_mode;
|
||||
vsyscall_gtod_data.clock.cycle_last = clock->cycle_last;
|
||||
vsyscall_gtod_data.clock.mask = clock->mask;
|
||||
vsyscall_gtod_data.clock.mult = mult;
|
||||
vsyscall_gtod_data.clock.shift = clock->shift;
|
||||
vdata->clock.vclock_mode = tk->clock->archdata.vclock_mode;
|
||||
vdata->clock.cycle_last = tk->clock->cycle_last;
|
||||
vdata->clock.mask = tk->clock->mask;
|
||||
vdata->clock.mult = tk->mult;
|
||||
vdata->clock.shift = tk->shift;
|
||||
|
||||
vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec;
|
||||
vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
|
||||
vdata->wall_time_sec = tk->xtime_sec;
|
||||
vdata->wall_time_snsec = tk->xtime_nsec;
|
||||
|
||||
monotonic = timespec_add(*wall_time, *wtm);
|
||||
vsyscall_gtod_data.monotonic_time_sec = monotonic.tv_sec;
|
||||
vsyscall_gtod_data.monotonic_time_nsec = monotonic.tv_nsec;
|
||||
vdata->monotonic_time_sec = tk->xtime_sec
|
||||
+ tk->wall_to_monotonic.tv_sec;
|
||||
vdata->monotonic_time_snsec = tk->xtime_nsec
|
||||
+ (tk->wall_to_monotonic.tv_nsec
|
||||
<< tk->shift);
|
||||
while (vdata->monotonic_time_snsec >=
|
||||
(((u64)NSEC_PER_SEC) << tk->shift)) {
|
||||
vdata->monotonic_time_snsec -=
|
||||
((u64)NSEC_PER_SEC) << tk->shift;
|
||||
vdata->monotonic_time_sec++;
|
||||
}
|
||||
|
||||
vsyscall_gtod_data.wall_time_coarse = __current_kernel_time();
|
||||
vsyscall_gtod_data.monotonic_time_coarse =
|
||||
timespec_add(vsyscall_gtod_data.wall_time_coarse, *wtm);
|
||||
vdata->wall_time_coarse.tv_sec = tk->xtime_sec;
|
||||
vdata->wall_time_coarse.tv_nsec = (long)(tk->xtime_nsec >> tk->shift);
|
||||
|
||||
write_seqcount_end(&vsyscall_gtod_data.seq);
|
||||
vdata->monotonic_time_coarse = timespec_add(vdata->wall_time_coarse,
|
||||
tk->wall_to_monotonic);
|
||||
|
||||
write_seqcount_end(&vdata->seq);
|
||||
}
|
||||
|
||||
static void warn_bad_vsyscall(const char *level, struct pt_regs *regs,
|
||||
|
@ -80,7 +80,7 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz)
|
||||
}
|
||||
|
||||
|
||||
notrace static inline long vgetns(void)
|
||||
notrace static inline u64 vgetsns(void)
|
||||
{
|
||||
long v;
|
||||
cycles_t cycles;
|
||||
@ -91,21 +91,24 @@ notrace static inline long vgetns(void)
|
||||
else
|
||||
return 0;
|
||||
v = (cycles - gtod->clock.cycle_last) & gtod->clock.mask;
|
||||
return (v * gtod->clock.mult) >> gtod->clock.shift;
|
||||
return v * gtod->clock.mult;
|
||||
}
|
||||
|
||||
/* Code size doesn't matter (vdso is 4k anyway) and this is faster. */
|
||||
notrace static int __always_inline do_realtime(struct timespec *ts)
|
||||
{
|
||||
unsigned long seq, ns;
|
||||
unsigned long seq;
|
||||
u64 ns;
|
||||
int mode;
|
||||
|
||||
ts->tv_nsec = 0;
|
||||
do {
|
||||
seq = read_seqcount_begin(>od->seq);
|
||||
mode = gtod->clock.vclock_mode;
|
||||
ts->tv_sec = gtod->wall_time_sec;
|
||||
ts->tv_nsec = gtod->wall_time_nsec;
|
||||
ns = vgetns();
|
||||
ns = gtod->wall_time_snsec;
|
||||
ns += vgetsns();
|
||||
ns >>= gtod->clock.shift;
|
||||
} while (unlikely(read_seqcount_retry(>od->seq, seq)));
|
||||
|
||||
timespec_add_ns(ts, ns);
|
||||
@ -114,15 +117,18 @@ notrace static int __always_inline do_realtime(struct timespec *ts)
|
||||
|
||||
notrace static int do_monotonic(struct timespec *ts)
|
||||
{
|
||||
unsigned long seq, ns;
|
||||
unsigned long seq;
|
||||
u64 ns;
|
||||
int mode;
|
||||
|
||||
ts->tv_nsec = 0;
|
||||
do {
|
||||
seq = read_seqcount_begin(>od->seq);
|
||||
mode = gtod->clock.vclock_mode;
|
||||
ts->tv_sec = gtod->monotonic_time_sec;
|
||||
ts->tv_nsec = gtod->monotonic_time_nsec;
|
||||
ns = vgetns();
|
||||
ns = gtod->monotonic_time_snsec;
|
||||
ns += vgetsns();
|
||||
ns >>= gtod->clock.shift;
|
||||
} while (unlikely(read_seqcount_retry(>od->seq, seq)));
|
||||
timespec_add_ns(ts, ns);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user