Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1618926ybv; Fri, 21 Feb 2020 00:24:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwBmjgSUrXOAG9tX8diKmwTxvVYMwIavpOCoxb8xpSEXm+gm/lEAdNKAKNw9nJ26LLgdNpG X-Received: by 2002:a9d:729c:: with SMTP id t28mr26971046otj.66.1582273455765; Fri, 21 Feb 2020 00:24:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273455; cv=none; d=google.com; s=arc-20160816; b=SqkJeptFJYkdy0JbWJX+za5IFZ5XoEAiX9sASTOahNoO/9CD4Pqz/IjIqTXQO8OtdT ghxw2AlI7pl/rK249h8zwp7+ulFiuA6jUDmfVQySng4rj0SYJirriHM4pPl6WCejpkta LvkuAzQNk13ibnUYoEuKdZZYq2GDuR0bnd2QbTsBER/337u4Dxy7JVIAClAGFbabbest MAzDrCiEmd32h5r3M48RmBkpsibSDHSrAEaJ+3dObNXUUBcxmfiXFWsKLAblvykzlLSd QG1OiGc3sN0Qn63BgHZQy7YM/YHXHotMDon/R+SxYJZxL8cK7veoToz7JnCqfkkz4Q0H 4oVg== 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=Qm2LibDr26qDfcxT0z8O3GUHh42fX9W0VPkf3vcXpVM=; b=obOoltUxt+eIKou4q9sx7/geKqvv3jzChfHtWOMd21uxSaEE3D8WnJLg0urZTw8BBW 78G+9Y6mflJiuelsGGs843GwqbVp3bbXWm8yZFGpmA//7ZYGU42/7s75H2igCti6RqbM RRvpS0kxi5LbjQ7lBooNb4VSwRuBchJ5+uCZSBsuNu/sdfTqLAzqYG0PzJ+cW8ERO0/y 1VAMEF/wBagGu8Wmu7Tj5UERFMcWRC6nqpEBB1D22NfGjnrLhNrhHDrPqXpgBuTMM+Eg LZFUPWvwHiv56MkMsRVKP7wBdJVyngW5NI7c9I07wr7Ykz6iGabdm8Bt8vzr4F07ThCG JwfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K86l6mVu; 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 h138si520849oib.6.2020.02.21.00.24.03; Fri, 21 Feb 2020 00:24:15 -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=K86l6mVu; 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 S2388298AbgBUIW0 (ORCPT + 99 others); Fri, 21 Feb 2020 03:22:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:33976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388290AbgBUIWY (ORCPT ); Fri, 21 Feb 2020 03:22:24 -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 07AC824672; Fri, 21 Feb 2020 08:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273343; bh=O6NHsOKP5WI6rUdV37NfHsDshjlGXVTkDbk7qfG4Jhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K86l6mVukoeVqz8gWq5GCJ4IqnRnXVL1uQKVgAb0CGtoOgfAoE7g6qT05CzeLlvJW lur9tnTlzcWG573szagXydf0PSjFZyjkgcnvlcOD+EOT+ZCqwv3RkrK/yJ917zYwDn MK2gxafkSezEam4WMn5nN4ZOs6OlbpfM1EC/PU0M= 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 4.19 136/191] watchdog/softlockup: Enforce that timestamp is valid on boot Date: Fri, 21 Feb 2020 08:41:49 +0100 Message-Id: <20200221072307.055337500@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@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 bbc4940f21af6..6d60701dc6361 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; @@ -267,7 +269,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) @@ -291,14 +293,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) @@ -376,7 +378,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