Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13477690ybl; Sun, 29 Dec 2019 12:51:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzJ4ZPHBIPUyfQlqvXcWkvPtVabFZti4i9Re9IZlTb3MT0LsCHlXSe0nG4Z9C9TkP8XUbUZ X-Received: by 2002:a05:6830:1487:: with SMTP id s7mr47942316otq.269.1577652706401; Sun, 29 Dec 2019 12:51:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652706; cv=none; d=google.com; s=arc-20160816; b=Z6+o4A/dzkUXV3W3MtTogTfbRUF8O0pY3T24vxVgcPFU4tUHIMNe9Lw0nXjnzNWk7Q wnF2taCjM8NzpXdwMr2d4FgUTmJsMrI0Vr8S6fQ+l+S4grLXIinUXMScpllJXZqv9CyC y9IqQH9OXK36m32d+3wUnIksNXURjR9Ji7OWSdcQud9AIkf0qLTXHosxjC/d/Ho8xIDe FH5xO8i4AhEWYKbR+QeMYFtC5ZG4fkkq18Aa0R4z1Hy02NUCwJK7ENTBG1iCUJBsoK8F fdVrcd5oHQUyBFA5s8B7USQPVGzRjeYdSGia5RUWpS6qBePqah5XdzyUueJgItoLX6z0 5UrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GKGGlDNrMpia51bvisTXzZ51qtF0+WJcR8EuqAoQMy0=; b=dChIxyJrFYD5rjLhGpYlr74Z/wqsr8cjdAHDQvO0sP2kEwwgT7TupmgWYq8C3ZTnRI LjFMW9SD+k7ucjDywlR02W8LLK0RTzOEqppLohfUFvEJ/zD1tU5qrRArM80qZ2ORVuyP VbV48SUD2rYeISGnkKmVyuwATJ9H3JNVt9JQdo+zzmDhPCkIIiaEM2aw86jpsDiBpqQr DbumxgnI/4L4vcSjJ1L2Ly0Dtale6iKf4HHV6yUttvNLquFAt14zZMHfoTXLphoXlAyK UEVcbmp7/G3HLVIIw1JljlVPtKftziKMdnxgnjhhX2D+MB4GUfKChfogmi3Y96WHc1L+ a5Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xiWFZ15D; 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 l7si22631186oth.11.2019.12.29.12.51.35; Sun, 29 Dec 2019 12:51:46 -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; dkim=pass header.i=@kernel.org header.s=default header.b=xiWFZ15D; 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 S1732860AbfL2SQk (ORCPT + 99 others); Sun, 29 Dec 2019 13:16:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:42364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727141AbfL2RYE (ORCPT ); Sun, 29 Dec 2019 12:24:04 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F3A01207FD; Sun, 29 Dec 2019 17:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640243; bh=LzEFEz/rwAarUMRtuzFxTzAa7OZ9EE8KIOv5dBfUEak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xiWFZ15D+UJ5rFUiJrfJNSPKiEE+aMfOXj8e/JFhC4e9gS4acz4xEkRImreKzjLQ3 NCd0BapaMdHDhsCkKUBf0lhe6JFLx4SDL07P5oQ2zd1Th4Q4KLkS9Bu9qZMmL4vfAL rnYm8RYllvjAy4puZwdaVOkLVj6Ih3yFtDmj3Dnc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Sasha Levin Subject: [PATCH 4.14 076/161] s390/time: ensure get_clock_monotonic() returns monotonic values Date: Sun, 29 Dec 2019 18:18:44 +0100 Message-Id: <20191229162423.283631437@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Heiko Carstens [ Upstream commit 011620688a71f2f1fe9901dbc2479a7c01053196 ] The current implementation of get_clock_monotonic() leaves it up to the caller to call the function with preemption disabled. The only core kernel caller (sched_clock) however does not disable preemption. In order to make sure that all callers of this function see monotonic values handle disabling preemption within the function itself. Signed-off-by: Heiko Carstens Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/include/asm/timex.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h index 64539c221672..0f12a3f91282 100644 --- a/arch/s390/include/asm/timex.h +++ b/arch/s390/include/asm/timex.h @@ -10,8 +10,9 @@ #ifndef _ASM_S390_TIMEX_H #define _ASM_S390_TIMEX_H -#include +#include #include +#include /* The value of the TOD clock for 1.1.1970. */ #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL @@ -186,15 +187,18 @@ extern unsigned char tod_clock_base[16] __aligned(8); /** * get_clock_monotonic - returns current time in clock rate units * - * The caller must ensure that preemption is disabled. * The clock and tod_clock_base get changed via stop_machine. - * Therefore preemption must be disabled when calling this - * function, otherwise the returned value is not guaranteed to - * be monotonic. + * Therefore preemption must be disabled, otherwise the returned + * value is not guaranteed to be monotonic. */ static inline unsigned long long get_tod_clock_monotonic(void) { - return get_tod_clock() - *(unsigned long long *) &tod_clock_base[1]; + unsigned long long tod; + + preempt_disable(); + tod = get_tod_clock() - *(unsigned long long *) &tod_clock_base[1]; + preempt_enable(); + return tod; } /** -- 2.20.1