From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751591AbeAPDqB (ORCPT + 1 other); Mon, 15 Jan 2018 22:46:01 -0500 Received: from terminus.zytor.com ([65.50.211.136]:44427 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751414AbeAPDp6 (ORCPT ); Mon, 15 Jan 2018 22:45:58 -0500 Date: Mon, 15 Jan 2018 19:42:36 -0800 From: tip-bot for Anna-Maria Gleixner Message-ID: Cc: hpa@zytor.com, anna-maria@linutronix.de, torvalds@linux-foundation.org, peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, john.stultz@linaro.org, hch@lst.de, tglx@linutronix.de Reply-To: mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, hch@lst.de, john.stultz@linaro.org, anna-maria@linutronix.de, torvalds@linux-foundation.org, peterz@infradead.org, hpa@zytor.com In-Reply-To: <20171221104205.7269-7-anna-maria@linutronix.de> References: <20171221104205.7269-7-anna-maria@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/core] hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers) Git-Commit-ID: 48d0c9becc7f3c66874c100c126459a9da0fdced X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Commit-ID: 48d0c9becc7f3c66874c100c126459a9da0fdced Gitweb: https://git.kernel.org/tip/48d0c9becc7f3c66874c100c126459a9da0fdced Author: Anna-Maria Gleixner AuthorDate: Thu, 21 Dec 2017 11:41:35 +0100 Committer: Ingo Molnar CommitDate: Tue, 16 Jan 2018 02:35:45 +0100 hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers) 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. Signed-off-by: Anna-Maria Gleixner Cc: Christoph Hellwig Cc: John Stultz Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: keescook@chromium.org Fixes: 597d0275736d ("timers: Framework for identifying pinned timers") Link: http://lkml.kernel.org/r/20171221104205.7269-7-anna-maria@linutronix.de Signed-off-by: Ingo Molnar --- 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 fd08729..60faade 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);