Skip to content

Commit 7ff15cd

Browse files
committed
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Ingo Molnar: "Three fixes: fix link failure on Alpha, fix a Sparse warning and annotate/robustify a lockless access in the NOHZ code" * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: tick/sched: Annotate lockless access to last_jiffies_update lib/vdso: Make __cvdso_clock_getres() static time/posix-stubs: Provide compat itimer supoprt for alpha
2 parents 9e79c52 + de95a99 commit 7ff15cd

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

kernel/time/posix-stubs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
151151

152152
#ifdef CONFIG_COMPAT
153153
COMPAT_SYS_NI(timer_create);
154+
#endif
155+
156+
#if defined(CONFIG_COMPAT) || defined(CONFIG_ALPHA)
154157
COMPAT_SYS_NI(getitimer);
155158
COMPAT_SYS_NI(setitimer);
156159
#endif

kernel/time/tick-sched.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ static void tick_do_update_jiffies64(ktime_t now)
5858

5959
/*
6060
* Do a quick check without holding jiffies_lock:
61+
* The READ_ONCE() pairs with two updates done later in this function.
6162
*/
62-
delta = ktime_sub(now, last_jiffies_update);
63+
delta = ktime_sub(now, READ_ONCE(last_jiffies_update));
6364
if (delta < tick_period)
6465
return;
6566

@@ -70,17 +71,20 @@ static void tick_do_update_jiffies64(ktime_t now)
7071
if (delta >= tick_period) {
7172

7273
delta = ktime_sub(delta, tick_period);
73-
last_jiffies_update = ktime_add(last_jiffies_update,
74-
tick_period);
74+
/* Pairs with the lockless read in this function. */
75+
WRITE_ONCE(last_jiffies_update,
76+
ktime_add(last_jiffies_update, tick_period));
7577

7678
/* Slow path for long timeouts */
7779
if (unlikely(delta >= tick_period)) {
7880
s64 incr = ktime_to_ns(tick_period);
7981

8082
ticks = ktime_divns(delta, incr);
8183

82-
last_jiffies_update = ktime_add_ns(last_jiffies_update,
83-
incr * ticks);
84+
/* Pairs with the lockless read in this function. */
85+
WRITE_ONCE(last_jiffies_update,
86+
ktime_add_ns(last_jiffies_update,
87+
incr * ticks));
8488
}
8589
do_timer(++ticks);
8690

lib/vdso/gettimeofday.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
221221
return 0;
222222
}
223223

224+
static __maybe_unused
224225
int __cvdso_clock_getres(clockid_t clock, struct __kernel_timespec *res)
225226
{
226227
int ret = __cvdso_clock_getres_common(clock, res);

0 commit comments

Comments
 (0)