Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8864485ybl; Fri, 17 Jan 2020 02:27:02 -0800 (PST) X-Google-Smtp-Source: APXvYqyiIVHZDf42elQ58d5qg2N0L+XCqQpEqo0zoo1Kr7OZkj2GpYkop1OPYIHsqpD0mGLjj+rp X-Received: by 2002:a05:6808:30d:: with SMTP id i13mr2753617oie.144.1579256822373; Fri, 17 Jan 2020 02:27:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579256822; cv=none; d=google.com; s=arc-20160816; b=gebSVmXGly99Y4dkubSD0clEUcx9mECnmk32Ov5eMNtnCUV506pVrCfWYr71Eh6HwH 5uVGcrEXFVENt28f2M5svOUfNYJlnDhv4qxZUM/c3MpN2n43skGOcvM182B/JCgkqkuJ D58elIrV0dgDBVDwfFIafNqZTZrPxBBmjt8M2/8kBLkayESLkzl08eJHTAoNJDUKlBK0 7GeAj56OMNuoPiFh8CkFBj/AVJxaNQyIp6nW/+wVdQivCLGyZ1rUxd1sxjaY3tQuXOWT rjYzFvu8NcHyyVFz39AMIczWWApSiHxolehm5Gmknkz4i7I3wKW8+oTxJVb6LOy4rBqx C1dQ== 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=KpSgjqhHnn8UPXniKLaywaGLTy74TMwijyeGs25gR/Q=; b=uBUYXWHdlM1SKzBWnMbY4FsMtPZVYu7Oy8LMvezflBKnnbfimfKdfSeOSVaC2U8r5M 0Ea3YWWgTCPaoCZiuli3aM6bKFrtrMw348+J0XERaaOkyHA/pmiSIKKB6e4LaDRVEdKr Hxl65785mjAseZUHoJTGT/kxcSWlmWyuFUzW63Y2URmZ7MvCpHDiNZnm9Zzl/zbW7WSf PIte9M5LiDNoP2rQY4ritamD8cd407eagafT/Q/81r0xsFrvGZecDpokqWKzlyDfbsT+ kJsyRIO+cC0IYmy1iLmEckPEao+5dB//kxefQ0yeIzWvoVCjISxy7QXZ/EwWV2QMzIpf ocsQ== 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 f22si6212181otp.145.2020.01.17.02.26.48; Fri, 17 Jan 2020 02:27:02 -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 S1726688AbgAQKZu (ORCPT + 99 others); Fri, 17 Jan 2020 05:25:50 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:55490 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgAQKZu (ORCPT ); Fri, 17 Jan 2020 05:25:50 -0500 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 1isOoy-00063A-Oh; Fri, 17 Jan 2020 11:25:44 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 1E03F1C19D7; Fri, 17 Jan 2020 11:25:44 +0100 (CET) Date: Fri, 17 Jan 2020 10:25:43 -0000 From: "tip-bot2 for Thomas Gleixner" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/core] watchdog/softlockup: Enforce that timestamp is valid on boot Cc: Robert Richter , Thomas Gleixner , x86 , LKML In-Reply-To: <87o8v3uuzl.fsf@nanos.tec.linutronix.de> References: <87o8v3uuzl.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Message-ID: <157925674381.396.17427763570273066050.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 core/core branch of tip: Commit-ID: 11e31f608b499f044f24b20be73f1dcab3e43f8a Gitweb: https://git.kernel.org/tip/11e31f608b499f044f24b20be73f1dcab3e43f8a Author: Thomas Gleixner AuthorDate: Thu, 16 Jan 2020 19:17:02 +01:00 Committer: Thomas Gleixner CommitterDate: Fri, 17 Jan 2020 11:19:22 +01:00 watchdog/softlockup: Enforce that timestamp is valid on boot Robert reported that during boot the watchdog timestamp is set to 0 for one second which is the indicator for a watchdog reset. The reason for this is that the timestamp is in seconds and the time is taken from sched clock and divided by ~1e9. sched clock starts at 0 which means that for the first second during boot the watchdog timestamp is 0, i.e. reset. Use ULONG_MAX as the reset indicator value so the watchdog works correctly right from the start. ULONG_MAX would only conflict with a real timestamp if the system reaches an uptime of 136 years on 32bit and almost eternity on 64bit. Reported-by: Robert Richter Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/87o8v3uuzl.fsf@nanos.tec.linutronix.de --- kernel/watchdog.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index e3774e9..b6b1f54 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -161,6 +161,8 @@ static void lockup_detector_update_enable(void) #ifdef CONFIG_SOFTLOCKUP_DETECTOR +#define SOFTLOCKUP_RESET ULONG_MAX + /* Global variables, exported for sysctl */ unsigned int __read_mostly softlockup_panic = CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE; @@ -272,7 +274,7 @@ notrace void touch_softlockup_watchdog_sched(void) * Preemption can be enabled. It doesn't matter which CPU's timestamp * gets zeroed here, so use the raw_ operation. */ - raw_cpu_write(watchdog_touch_ts, 0); + raw_cpu_write(watchdog_touch_ts, SOFTLOCKUP_RESET); } notrace void touch_softlockup_watchdog(void) @@ -296,14 +298,14 @@ void touch_all_softlockup_watchdogs(void) * the softlockup check. */ for_each_cpu(cpu, &watchdog_allowed_mask) - per_cpu(watchdog_touch_ts, cpu) = 0; + per_cpu(watchdog_touch_ts, cpu) = SOFTLOCKUP_RESET; wq_watchdog_touch(-1); } void touch_softlockup_watchdog_sync(void) { __this_cpu_write(softlockup_touch_sync, true); - __this_cpu_write(watchdog_touch_ts, 0); + __this_cpu_write(watchdog_touch_ts, SOFTLOCKUP_RESET); } static int is_softlockup(unsigned long touch_ts) @@ -379,7 +381,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) /* .. and repeat */ hrtimer_forward_now(hrtimer, ns_to_ktime(sample_period)); - if (touch_ts == 0) { + if (touch_ts == SOFTLOCKUP_RESET) { if (unlikely(__this_cpu_read(softlockup_touch_sync))) { /* * If the time stamp was touched atomically