Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1634892ybv; Fri, 21 Feb 2020 00:42:48 -0800 (PST) X-Google-Smtp-Source: APXvYqwZv2zs7VigsjEDnB0nw614ijzxgqfdCwfdowj2TNPjRBRVt5HjK09qutPl8dMuuxyiUfdI X-Received: by 2002:aca:5083:: with SMTP id e125mr1098794oib.96.1582274568648; Fri, 21 Feb 2020 00:42:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582274568; cv=none; d=google.com; s=arc-20160816; b=kCsMhSA/fc2Tv9ANSycfoF8AUyxlDsv5Q8hEDs3zPUzAV+Z8Mobst20f6NM5pPCg+V 3Z4nkaUj1rk1ayCGo77HxVE2uBZhkATcBFBC+UrnRI/1QxhrldHjMb59+bqMiLUdwwzC CXeLREAwL32p3XyMywiBf4CK5NxhOr4Tp2gXcqCNvoPWoEbQwol8I3nkpupjTGzn8mw0 hm3y9GclGpBvfm8iYBhFsurRtJnnz57gRTm1FvjlLYuXvltSpddajfhYw3qdNviQX8ID gihUlZFQn72OaWYxKqEtdUDgO6A32wbUFcRQ7gJgM5th5P+mhPs4eHtle++af/ivxK+u eDrQ== 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=iXJo0oGGFAqFJLzOA4LCHErCBbnKSS4eadPoPsdT8yY=; b=E4nStuhMa9a31UJBBtEQtqM4hgxM59vePd7O53GeatmurNqNqR3Bm2FkHHFyFXSXN0 9Z+0NEwD3lFu8rDZFYaJvIoyZ2Bbcc8amz8JfREDrc/6gomAieVaeXz2wlAXvrnEvuiZ xcUJ0QDkUt/ypmBY5bKKxhu1U+zVGOYT4NLsjo5PwvDKha+67Z8IaxLucT/o8sA7QSN+ fJvetN7QBJ1iCtx3ChMt15i/644AH0TxBXlF/qX2K3KNZayrW2Q1HxOSZwkJ5CVpqkIz hTnpnjLDsb/S76jVpFU6V+39yuUHI9CjFDNroPkCFlapK5Dbd8glbXiQxENGNH/Vwupe dPGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="V9/KPDWw"; 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 d125si437262oia.86.2020.02.21.00.42.37; Fri, 21 Feb 2020 00:42:48 -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="V9/KPDWw"; 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 S1731804AbgBUIl7 (ORCPT + 99 others); Fri, 21 Feb 2020 03:41:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:55300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730426AbgBUH4G (ORCPT ); Fri, 21 Feb 2020 02:56:06 -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 A551220658; Fri, 21 Feb 2020 07:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271766; bh=ipx4Td6141LujbD+iqs7ftTylfFP+MA6LuFhN97F7WA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V9/KPDWw6imE+o89L73B4P7qg7JkiYztMRVdmqACbAElz6yeI6gsj/XB2068h5FYv YiCJZ0Bw9bChohzNqFx1nIV+Hem2yjddVR1DfNPGvaH4of1U+zIsJeeX1YaYoJtCWz fEu3tlNTA0lPf9u3q3uL1+eOvgrYWCZrOI4lGzjA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Richter , Thomas Gleixner , Sasha Levin Subject: [PATCH 5.5 291/399] watchdog/softlockup: Enforce that timestamp is valid on boot Date: Fri, 21 Feb 2020 08:40:16 +0100 Message-Id: <20200221072430.092296274@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@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: Thomas Gleixner [ Upstream commit 11e31f608b499f044f24b20be73f1dcab3e43f8a ] 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 Signed-off-by: Sasha Levin --- kernel/watchdog.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index f41334ef09713..cbd3cf503c904 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; @@ -274,7 +276,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) @@ -298,14 +300,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) @@ -383,7 +385,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 -- 2.20.1