Received: by 10.223.185.116 with SMTP id b49csp8515196wrg; Fri, 2 Mar 2018 03:15:09 -0800 (PST) X-Google-Smtp-Source: AG47ELs8JHVldqVEShAxIls73ovoxeo8xSXf4REci4kkcNvREtrRBkkahwDRSBq28PAOAP56/l1F X-Received: by 10.101.70.133 with SMTP id h5mr4354099pgr.166.1519989309823; Fri, 02 Mar 2018 03:15:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519989309; cv=none; d=google.com; s=arc-20160816; b=PEloRFotic9PaSvo98PBhqjeXXsqXCFgiS5y3p0XMU7ROQTvHf+HxuTLw4zXj7J6rt 8wDfgDzypJGAtM5JvHPC1AXLhzdI3bh1R4CZEKdeVXzFB4v5BKl5+j1MwWkQkY/+2BHB rhzAwpyif3sCVEDTLUm9IBM+hFQc3DRAEZyMojq1sVi3z5xIAUqUGKSt1mBvluTAWrr+ U7v4GW25Mx3tC+zAXSY1B2Jm4erfZ3vTHQ4PdOxF7xQKilu0NzOpxTz20bI533YJi0Gx 727WhvQ2lnqq+K9tiV6rSyHH/TxvK/qoblf0NVEEAP32IR3grkUF8+hN4k6ROKOOGCwk oQvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EX8RGO8lLjyApK9KzUrhJv/TrniGcT/BQSZFl8qu5t8=; b=qVmKEkY5rxySYU/hX74HzMoQEwHKeF8YWdbgU8XuE822m6S4pWXZZxCeEXDfCAHd79 93ItCq1+w1JDIOIO6L2ccK4eEq9iVjIs9S1DsZB+gd5N7v+5IVBCTQWjqBjSPkskNoOM t2P9D+2wdfax1h8mcupRCG9W23OYwGTeNmdrOcPy5QZDZWNMbzB9Fj6EJWeuAmplF0Vv x84VKLDQ1oUvfWDQHbl3AR6+Sn1qODjMQI7Q9Pj9nVQA/gdkFEwcvb7BDTA7rqSRzTp8 Zj9ez8RfB81A2+UJ2Z28Dw3TFOjZYxesKTUEDpIhR/kWvH+FzhvB1G0I7MCilYKG5dS+ nTPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6si4681953pfi.123.2018.03.02.03.14.55; Fri, 02 Mar 2018 03:15:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423448AbeCBIyJ (ORCPT + 99 others); Fri, 2 Mar 2018 03:54:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50308 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423387AbeCBIyF (ORCPT ); Fri, 2 Mar 2018 03:54:05 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 820C2120A; Fri, 2 Mar 2018 08:54:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anna-Maria Gleixner , Christoph Hellwig , John Stultz , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , keescook@chromium.org, Ingo Molnar , Mike Galbraith Subject: [PATCH 4.4 01/34] hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers) Date: Fri, 2 Mar 2018 09:50:57 +0100 Message-Id: <20180302084436.004061183@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180302084435.842679610@linuxfoundation.org> References: <20180302084435.842679610@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anna-Maria Gleixner 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. 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 Cc: Mike Galbraith Signed-off-by: Greg Kroah-Hartman --- kernel/time/hrtimer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1139,7 +1139,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);