Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp403119ybg; Thu, 19 Mar 2020 01:50:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsTwQ6lQN47pijN1n0Dmg11p498uXrfGO5bwHk35Zx6AHPGMfFgayyN+b4/xdWQWHMHHucD X-Received: by 2002:aca:646:: with SMTP id 67mr1462460oig.4.1584607807192; Thu, 19 Mar 2020 01:50:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584607807; cv=none; d=google.com; s=arc-20160816; b=uCOFmjT8o0iB+lPuHGOqFPwdKwfAuWFrk50RGCHvC7C6so+xvQCDMEFC66oXgLg8IL du4lYDne/zHcDonScvtLw9MnI/+YmdhKtD5cKsUQ5J4Sp1ncn7DqTYiqfYG2lW1WzZ3j UfT1z16DzHWiyint1EJTG2td4Cp/Ha7yqU5r6O0xDs1OGsdoAMuVB8ZQ9R7sW6btVcUn 58IPA6MMf9tGcj8/jzBufsjI9bQTGFfxnk4vrDIP/E8RJ8B7e26+SYrN/RPFJG3yUJqI ooCCNphtElL8E45xz6VHb0UFkRoHJNtqarFhBGFkSTfWKD7qkDB9LvbnGFkzcix00HWe YUyA== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=MhbbjgklDuxq2bu7kuBf1RyMHdL1B42BAPgoZ5rG4A4=; b=x3VCvslIBZkvccKD/uDT6/W9dqdZK6FenA4BOLfS/zx86oao+EVlkjfrOBXRXBHTsk uaRGjrplyjk3w7Z5inv6in5Y6/Gol+ftoN9LlT251y3PzP946fNjhCbESmaHznnApcYT 6YFhjuDgQDH/dKZcm+kDwqRosUu9hcwWEDQuTS2Lu9YqtpSvFOtZUdmcD0eUZQ9fPsyR eoYjHqDYq5JCTavFk3GdU5zMveWREFMLS4rCfJBrdvU/wU1SV0N1/cIEXZbFGmMI73TZ +FL8miIAvYQezkDA76O76JZ/ym9gpmQBB2+j4a62aZfyp1mHnOKHaIccxcOubbqh09c8 K/Ow== 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 a128si785781oif.202.2020.03.19.01.49.55; Thu, 19 Mar 2020 01:50:07 -0700 (PDT) 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 S1727235AbgCSItK (ORCPT + 99 others); Thu, 19 Mar 2020 04:49:10 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:59681 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgCSIrw (ORCPT ); Thu, 19 Mar 2020 04:47:52 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jEqqC-0002xE-TU; Thu, 19 Mar 2020 09:47:49 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 45A8B1C1DC3; Thu, 19 Mar 2020 09:47:46 +0100 (CET) Date: Thu, 19 Mar 2020 08:47:45 -0000 From: "tip-bot2 for Ahmed S. Darwish" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] time/sched_clock: Expire timer in hardirq context Cc: "Ahmed S. Darwish" , Thomas Gleixner , x86 , LKML In-Reply-To: <20200309181529.26558-1-a.darwish@linutronix.de> References: <20200309181529.26558-1-a.darwish@linutronix.de> MIME-Version: 1.0 Message-ID: <158460766596.28353.12288239928107345497.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: 2c8bd58812ee3dbf0d78b566822f7eacd34bdd7b Gitweb: https://git.kernel.org/tip/2c8bd58812ee3dbf0d78b566822f7eacd34bdd7b Author: Ahmed S. Darwish AuthorDate: Mon, 09 Mar 2020 18:15:29 Committer: Thomas Gleixner CommitterDate: Thu, 19 Mar 2020 09:45:08 +01:00 time/sched_clock: Expire timer in hardirq context To minimize latency, PREEMPT_RT kernels expires hrtimers in preemptible softirq context by default. This can be overriden by marking the timer's expiry with HRTIMER_MODE_HARD. sched_clock_timer is missing this annotation: if its callback is preempted and the duration of the preemption exceeds the wrap around time of the underlying clocksource, sched clock will get out of sync. Mark the sched_clock_timer for expiry in hard interrupt context. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200309181529.26558-1-a.darwish@linutronix.de --- kernel/time/sched_clock.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index e4332e3..fa3f800 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -208,7 +208,8 @@ sched_clock_register(u64 (*read)(void), int bits, unsigned long rate) if (sched_clock_timer.function != NULL) { /* update timeout for clock wrap */ - hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); + hrtimer_start(&sched_clock_timer, cd.wrap_kt, + HRTIMER_MODE_REL_HARD); } r = rate; @@ -254,9 +255,9 @@ void __init generic_sched_clock_init(void) * Start the timer to keep sched_clock() properly updated and * sets the initial epoch. */ - hrtimer_init(&sched_clock_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer_init(&sched_clock_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); sched_clock_timer.function = sched_clock_poll; - hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); + hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL_HARD); } /* @@ -293,7 +294,7 @@ void sched_clock_resume(void) struct clock_read_data *rd = &cd.read_data[0]; rd->epoch_cyc = cd.actual_read_sched_clock(); - hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); + hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL_HARD); rd->read_sched_clock = cd.actual_read_sched_clock; }