42 lines
1.6 KiB
Diff
42 lines
1.6 KiB
Diff
From: Anna-Maria Gleixner <anna-maria@linutronix.de>
|
|
Date: Wed, 20 Dec 2017 17:12:55 +0100
|
|
Subject: [PATCH 06/29] hrtimer: Ensure POSIX compliance (relative
|
|
CLOCK_REALTIME hrtimers)
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz
|
|
|
|
POSIX specification defines, that relative CLOCK_REALTIME timers are not
|
|
affected by clock modifications. Those timers have to use CLOCK_MONOTONIC
|
|
to ensure POSIX compliance.
|
|
|
|
The introduction of the additional mode HRTIMER_MODE_PINNED broke this
|
|
requirement for pinned timers. There is no user space visible impact
|
|
because user space timers are not using the pinned mode, but for
|
|
consistency reasons this needs to be fixed.
|
|
|
|
Check whether the mode has the HRTIMER_MODE_REL bit set instead of
|
|
comparing with HRTIMER_MODE_ABS.
|
|
|
|
Fixes: 597d0275736d ("timers: Framework for identifying pinned timers")
|
|
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
---
|
|
kernel/time/hrtimer.c | 7 ++++++-
|
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
--- a/kernel/time/hrtimer.c
|
|
+++ b/kernel/time/hrtimer.c
|
|
@@ -1097,7 +1097,12 @@ static void __hrtimer_init(struct hrtime
|
|
|
|
cpu_base = raw_cpu_ptr(&hrtimer_bases);
|
|
|
|
- if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS)
|
|
+ /*
|
|
+ * Posix magic: Relative CLOCK_REALTIME timers are not affected by
|
|
+ * clock modifications, so they needs to become CLOCK_MONOTONIC to
|
|
+ * ensure Posix compliance.
|
|
+ */
|
|
+ if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL)
|
|
clock_id = CLOCK_MONOTONIC;
|
|
|
|
base = hrtimer_clockid_to_base(clock_id);
|