Skip to contentSkip to conversation

Patch "hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers)" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Feb 28, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers)

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
hrtimer-ensure-posix-compliance-relative-clock_realtime-hrtimers.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 48d0c9becc7f3c66874c100c126459a9da0fdced Mon Sep 17 00:00:00 2001

From: Anna-Maria Gleixner <[email protected]>
Date: Thu, 21 Dec 2017 11:41:35 +0100
Subject: hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers)

From: Anna-Maria Gleixner <[email protected]>

commit 48d0c9becc7f3c66874c100c126459a9da0fdced upstream.

The 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 HRTIMER_MODE_PINNED mode broke this requirement for pinned timers.

There is no user space visible impact because user space timers are not using 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.

Cc Christoph Hellwig <[email protected]>
Cc John Stultz <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Fixes 597d0275736d ("timers: Framework for identifying pinned timers")
Cc Mike Galbraith <[email protected]>
---
 kernel/time/hrtimer.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/time/hrtimer.c +6 -1
@@ -1106,7 +1106,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);

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/hrtimer-ensure-posix-compliance-relative-clock_realtime-hrtimers.patch