mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 09:41:44 +00:00
x86: vdso: Use seqcount instead of seqlock
The update of the vdso data happens under xtime_lock, so adding a nested lock is pointless. Just use a seqcount to sync the readers. Reviewed-by: Andy Lutomirski <luto@amacapital.net> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
This commit is contained in:
parent
6c260d5863
commit
2ab516575f
@ -5,7 +5,7 @@
|
|||||||
#include <linux/clocksource.h>
|
#include <linux/clocksource.h>
|
||||||
|
|
||||||
struct vsyscall_gtod_data {
|
struct vsyscall_gtod_data {
|
||||||
seqlock_t lock;
|
seqcount_t seq;
|
||||||
|
|
||||||
/* open coded 'struct timespec' */
|
/* open coded 'struct timespec' */
|
||||||
time_t wall_time_sec;
|
time_t wall_time_sec;
|
||||||
|
@ -52,10 +52,7 @@
|
|||||||
#include "vsyscall_trace.h"
|
#include "vsyscall_trace.h"
|
||||||
|
|
||||||
DEFINE_VVAR(int, vgetcpu_mode);
|
DEFINE_VVAR(int, vgetcpu_mode);
|
||||||
DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data) =
|
DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
|
||||||
{
|
|
||||||
.lock = __SEQLOCK_UNLOCKED(__vsyscall_gtod_data.lock),
|
|
||||||
};
|
|
||||||
|
|
||||||
static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
|
static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
|
||||||
|
|
||||||
@ -86,9 +83,7 @@ void update_vsyscall_tz(void)
|
|||||||
void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
|
void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
|
||||||
struct clocksource *clock, u32 mult)
|
struct clocksource *clock, u32 mult)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
write_seqcount_begin(&vsyscall_gtod_data.seq);
|
||||||
|
|
||||||
write_seqlock_irqsave(&vsyscall_gtod_data.lock, flags);
|
|
||||||
|
|
||||||
/* copy vsyscall data */
|
/* copy vsyscall data */
|
||||||
vsyscall_gtod_data.clock.vclock_mode = clock->archdata.vclock_mode;
|
vsyscall_gtod_data.clock.vclock_mode = clock->archdata.vclock_mode;
|
||||||
@ -101,7 +96,7 @@ void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
|
|||||||
vsyscall_gtod_data.wall_to_monotonic = *wtm;
|
vsyscall_gtod_data.wall_to_monotonic = *wtm;
|
||||||
vsyscall_gtod_data.wall_time_coarse = __current_kernel_time();
|
vsyscall_gtod_data.wall_time_coarse = __current_kernel_time();
|
||||||
|
|
||||||
write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags);
|
write_seqcount_end(&vsyscall_gtod_data.seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void warn_bad_vsyscall(const char *level, struct pt_regs *regs,
|
static void warn_bad_vsyscall(const char *level, struct pt_regs *regs,
|
||||||
|
@ -100,12 +100,12 @@ notrace static noinline int do_realtime(struct timespec *ts)
|
|||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
seq = read_seqbegin(>od->lock);
|
seq = read_seqcount_begin(>od->seq);
|
||||||
mode = gtod->clock.vclock_mode;
|
mode = gtod->clock.vclock_mode;
|
||||||
ts->tv_sec = gtod->wall_time_sec;
|
ts->tv_sec = gtod->wall_time_sec;
|
||||||
ts->tv_nsec = gtod->wall_time_nsec;
|
ts->tv_nsec = gtod->wall_time_nsec;
|
||||||
ns = vgetns();
|
ns = vgetns();
|
||||||
} while (unlikely(read_seqretry(>od->lock, seq)));
|
} while (unlikely(read_seqcount_retry(>od->seq, seq)));
|
||||||
|
|
||||||
timespec_add_ns(ts, ns);
|
timespec_add_ns(ts, ns);
|
||||||
return mode;
|
return mode;
|
||||||
@ -117,13 +117,13 @@ notrace static noinline int do_monotonic(struct timespec *ts)
|
|||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
seq = read_seqbegin(>od->lock);
|
seq = read_seqcount_begin(>od->seq);
|
||||||
mode = gtod->clock.vclock_mode;
|
mode = gtod->clock.vclock_mode;
|
||||||
secs = gtod->wall_time_sec;
|
secs = gtod->wall_time_sec;
|
||||||
ns = gtod->wall_time_nsec + vgetns();
|
ns = gtod->wall_time_nsec + vgetns();
|
||||||
secs += gtod->wall_to_monotonic.tv_sec;
|
secs += gtod->wall_to_monotonic.tv_sec;
|
||||||
ns += gtod->wall_to_monotonic.tv_nsec;
|
ns += gtod->wall_to_monotonic.tv_nsec;
|
||||||
} while (unlikely(read_seqretry(>od->lock, seq)));
|
} while (unlikely(read_seqcount_retry(>od->seq, seq)));
|
||||||
|
|
||||||
/* wall_time_nsec, vgetns(), and wall_to_monotonic.tv_nsec
|
/* wall_time_nsec, vgetns(), and wall_to_monotonic.tv_nsec
|
||||||
* are all guaranteed to be nonnegative.
|
* are all guaranteed to be nonnegative.
|
||||||
@ -142,10 +142,10 @@ notrace static noinline int do_realtime_coarse(struct timespec *ts)
|
|||||||
{
|
{
|
||||||
unsigned long seq;
|
unsigned long seq;
|
||||||
do {
|
do {
|
||||||
seq = read_seqbegin(>od->lock);
|
seq = read_seqcount_begin(>od->seq);
|
||||||
ts->tv_sec = gtod->wall_time_coarse.tv_sec;
|
ts->tv_sec = gtod->wall_time_coarse.tv_sec;
|
||||||
ts->tv_nsec = gtod->wall_time_coarse.tv_nsec;
|
ts->tv_nsec = gtod->wall_time_coarse.tv_nsec;
|
||||||
} while (unlikely(read_seqretry(>od->lock, seq)));
|
} while (unlikely(read_seqcount_retry(>od->seq, seq)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,12 +153,12 @@ notrace static noinline int do_monotonic_coarse(struct timespec *ts)
|
|||||||
{
|
{
|
||||||
unsigned long seq, ns, secs;
|
unsigned long seq, ns, secs;
|
||||||
do {
|
do {
|
||||||
seq = read_seqbegin(>od->lock);
|
seq = read_seqcount_begin(>od->seq);
|
||||||
secs = gtod->wall_time_coarse.tv_sec;
|
secs = gtod->wall_time_coarse.tv_sec;
|
||||||
ns = gtod->wall_time_coarse.tv_nsec;
|
ns = gtod->wall_time_coarse.tv_nsec;
|
||||||
secs += gtod->wall_to_monotonic.tv_sec;
|
secs += gtod->wall_to_monotonic.tv_sec;
|
||||||
ns += gtod->wall_to_monotonic.tv_nsec;
|
ns += gtod->wall_to_monotonic.tv_nsec;
|
||||||
} while (unlikely(read_seqretry(>od->lock, seq)));
|
} while (unlikely(read_seqcount_retry(>od->seq, seq)));
|
||||||
|
|
||||||
/* wall_time_nsec and wall_to_monotonic.tv_nsec are
|
/* wall_time_nsec and wall_to_monotonic.tv_nsec are
|
||||||
* guaranteed to be between 0 and NSEC_PER_SEC.
|
* guaranteed to be between 0 and NSEC_PER_SEC.
|
||||||
|
Loading…
Reference in New Issue
Block a user