From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933435AbdK2Pop (ORCPT ); Wed, 29 Nov 2017 10:44:45 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:39740 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933046AbdK2PcE (ORCPT ); Wed, 29 Nov 2017 10:32:04 -0500 From: Anna-Maria Gleixner To: LKML Cc: Thomas Gleixner , Peter Zijlstra , Ingo Molnar , keescook@chromium.org, Christoph Hellwig , John Stultz , Anna-Maria Gleixner Subject: [PATCH v3 06/36] hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers) Date: Wed, 29 Nov 2017 16:30:31 +0100 Message-Id: <20171129153101.27297-7-anna-maria@linutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171129153101.27297-1-anna-maria@linutronix.de> References: <20171129153101.27297-1-anna-maria@linutronix.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- kernel/time/hrtimer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index ae7b29c4e03e..9945ea6b0e5c 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1095,7 +1095,12 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, 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); -- 2.11.0