Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp3850459rwb; Sun, 7 Aug 2022 08:40:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5lF/Hjc62TX+7IEBFCfzWMXSf7ekUowh/FtPEBimTYDmySVqbmMrDJeJB5C2HBe4pWv6e8 X-Received: by 2002:a17:90b:1b08:b0:1f5:b65:9654 with SMTP id nu8-20020a17090b1b0800b001f50b659654mr16806017pjb.77.1659886848551; Sun, 07 Aug 2022 08:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659886848; cv=none; d=google.com; s=arc-20160816; b=u1icDiDrMmqhJt3aGRDQl68PMRAsTM6gLi3IvLW4zrPEBCgegKyJxbi58JHe1cbK8m PM9xl+sqGYiyUcgNBGb6QkpMkWF3o53/tdVkyuy/Fv30lAWmzP309j8vhkoakIs5xc6w 4Mn/CK2N1vME9oxc999R4ovsiUka6q6dLMFVsrqoR2W99Sr9YgoPai4d6YuafHfJvEBX dHLjHzuBO66ihau4n1OQtH1a3WnN5S63/H8oFGFXB+LEDizAkc1tshKRMw++4OBbVLbZ zNIebF6i4ysvJ9mCiCcAOuYlb2fcF/+C4O8CR9Q7aOtbewu60b0W0vOyS0r2IZjpndFs om2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:message-id:date:subject:cc:from :dkim-signature; bh=f4puBzIh+2fwMzCLxOTv6T0TgB7OLw32VLd1/PfG9h4=; b=Uj1r8STGmLTVwlG4+nMftnrIsxNN1MZbqIz8aCULV3cgGG1aCA3kMN26GQtU8KrXu6 MpeBy+QeBUauVCqua1pwfBJoC9r4fD0p5M4z7+yZKuoqzUlgGy3GWN8LqW5A/1teYZpg uA4cxE4D3TlBeGaQ8X3eETb4vhZzzVgguEjCwgOpPYGjRNZnLMZGZa3vcBbpCCsgPOuJ 11HcC7Zoyyw2Cw+UnvayTSzbl9vXaSTKNTEOw7V+TiMs8sbU/pnZ9U0aq1Gpt4YPagEx ZgWMvxTHl6a8wRGVzSGXZDlcARlOF3rdp9EVXd/Sh02qrghaXqap4seQpOBnNFu0/zxG twXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=Xo2bBbXb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e1-20020a631e01000000b0041bb37b1f3asi8178840pge.298.2022.08.07.08.40.34; Sun, 07 Aug 2022 08:40:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=Xo2bBbXb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234222AbiHGPSo (ORCPT + 99 others); Sun, 7 Aug 2022 11:18:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiHGPSk (ORCPT ); Sun, 7 Aug 2022 11:18:40 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D148762E9 for ; Sun, 7 Aug 2022 08:18:39 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id q9-20020a17090a2dc900b001f58bcaca95so5534636pjm.3 for ; Sun, 07 Aug 2022 08:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:subject:cc:to:from:from:to:cc; bh=f4puBzIh+2fwMzCLxOTv6T0TgB7OLw32VLd1/PfG9h4=; b=Xo2bBbXbHiiU45ogFCXtsMLy4vyVdoXrSALkxLIL+3dE/LtOUa6Ifp5Ctwh3TQHJCX jL5nJg6qehl6itnqY1KuVzmnSlb7HJDZRpxIRRHI7nTklnpOFiV9Sa2R/hNi9vfJsEL/ 1J7zK+6WrLXpoHAjP3/G0yEAhn+WOm2KkLc87ZVr59KZUnxfJxqCS52Np87/LYMWPWzL KFqU7VnykHsbf/9Or0FhVNNIYKo0Qsu+JiWwb8+9mC4DsQrAEWfo3Z33RWtg2a0h+8lW pUzpNQ7VefZsF8awcIpIsUZxvUAQjHSec9wPUKDXVh4LDJUOdsUuB1GSYtloQfaJxd8k fsBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=f4puBzIh+2fwMzCLxOTv6T0TgB7OLw32VLd1/PfG9h4=; b=xe8O6BlyAZQuXTsmTpltTAqZNhPD0gQapFCrowPxmSB2M31mbkcu74B5112e+eJdMz MX28WlROsPYtDoN0xLyBn9vgpLTJ7bT3pvtUpaX2dkPscnkNMvjNQzn3BnFehNaCu85O U6GIgfCNRKm3JpSHIhOy2vMuNcuuuw7gLAF9Y3JPtGmaCrtUVwzpq5P6o99rrNhzUnfb em6DdgC8hrNkvN2uMRwKyy+jWaoFUJe66UZBQZ00lnfnwvBIuigpGyF7anC541O2ZXMA ekT5daAglYSOKNDyHhKObwbB4sPqZ32tqEFPrGr6BWCTBL1gQvZvs7JzAbfFevt9otLx 1GTw== X-Gm-Message-State: ACgBeo0lpm8BB7hXXClSRjrwD88SYqjjdwEhLh+IaUzbET/CUnjM2A3o GiDnYfrJ81JT6Y2F1wY6ya78NO+EKl1bHM4SQmE= X-Received: by 2002:a17:90a:ead3:b0:1f3:366d:5005 with SMTP id ev19-20020a17090aead300b001f3366d5005mr25537234pjb.1.1659885519228; Sun, 07 Aug 2022 08:18:39 -0700 (PDT) Received: from localhost.localdomain ([113.88.93.147]) by smtp.gmail.com with ESMTPSA id b2-20020a170902d50200b0016b90620910sm6867626plg.71.2022.08.07.08.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Aug 2022 08:18:38 -0700 (PDT) From: Puyou Lu Cc: Puyou Lu , Petr Mladek , Andrew Morton , Phil Auld , "Peter Zijlstra (Intel)" , Rasmus Villemoes , John Ogness , Laurent Dufour , Frederic Weisbecker , Xiaoming Ni , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] watchdog: enable watchdog only when watchdog_thresh != 0 Date: Sun, 7 Aug 2022 23:17:55 +0800 Message-Id: <20220807151757.18466-1-puyou.lu@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can simplify the check of watchdog_thresh, as watchdog_thresh shouldn't be zero for both nmi and soft watchdog. Signed-off-by: Puyou Lu --- kernel/watchdog.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 8e61f21e7e33..bed1fe7ecaea 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -144,7 +144,7 @@ void __weak watchdog_nmi_start(void) { } static void lockup_detector_update_enable(void) { watchdog_enabled = 0; - if (!watchdog_user_enabled) + if (!(watchdog_user_enabled && watchdog_thresh)) return; if (nmi_watchdog_available && nmi_watchdog_user_enabled) watchdog_enabled |= NMI_WATCHDOG_ENABLED; @@ -306,7 +306,7 @@ static int is_softlockup(unsigned long touch_ts, unsigned long period_ts, unsigned long now) { - if ((watchdog_enabled & SOFT_WATCHDOG_ENABLED) && watchdog_thresh){ + if (watchdog_enabled & SOFT_WATCHDOG_ENABLED) { /* Warn about unreasonable delays. */ if (time_after(now, period_ts + get_softlockup_thresh())) return now - touch_ts; @@ -543,9 +543,10 @@ static void __lockup_detector_reconfigure(void) watchdog_nmi_stop(); softlockup_stop_all(); + set_sample_period(); lockup_detector_update_enable(); - if (watchdog_enabled && watchdog_thresh) + if (watchdog_enabled & SOFT_WATCHDOG_ENABLED) softlockup_start_all(); watchdog_nmi_start(); @@ -575,8 +576,7 @@ static __init void lockup_detector_setup(void) */ lockup_detector_update_enable(); - if (!IS_ENABLED(CONFIG_SYSCTL) && - !(watchdog_enabled && watchdog_thresh)) + if (!IS_ENABLED(CONFIG_SYSCTL) && !watchdog_enabled) return; mutex_lock(&watchdog_mutex); -- 2.17.1