Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3406160rwa; Tue, 23 Aug 2022 04:21:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR5rMdbzlmnXYWZcDX377cPKIyWcR2QonXkFrJ9ybEA2njmxIJsb9TtqnIy+mpZtMhrKtEnd X-Received: by 2002:a63:6a05:0:b0:42a:3b5d:8084 with SMTP id f5-20020a636a05000000b0042a3b5d8084mr16939315pgc.281.1661253711540; Tue, 23 Aug 2022 04:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253711; cv=none; d=google.com; s=arc-20160816; b=GA/8Y5tsPoIjw6nGfd5kw4G96l9msyAYrJ/dgRIA6SEQFlEbST3p5id+lrQiZDJCkA 1+hsISZHzQOFLvlHD8nVWxVxAJzj2j6VhS14UIx033m4XdYSIRxNc+BW0++BAL2TeAhv GMSltOJqdiVYuMjgZzIISY5j4P/4J7nr7awLaDvP/+APy7BDYUuIHFFeC0L68Z8LRCYb 0BOY6ODHwyqs05j6JvMF7YY5ZWaFgxNqGNGweY0geQWvskBeuoQBK25BWi2K2YsCluAz WZKNRVQCpoiH8jBiaq5GDsmq91tGNcZx/Z7k4MI8dnwczOsBfIOPjgKKC5YhhUMu8vYO YMqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AGEpvPiYWmg/KFvvec+5DUb3EtuZXrC6uAKDtxTJuC4=; b=iZrZolMn0RWKtBJlASWRM2pWzN73DM6CZDUEl2hjTHAtSLbDcgWOLx4XmdeepdEgJ6 ZtIpA8rbdNz9cFbWeyQonX7Q3jjn4C7RdXcLL45eIg0I7NzUViGddhWGRQ/uELHHTEvo B869+uAnfTaFhYoAfXmXc3GZN7Qm5U06rZtGmhp7W5kWam47Y/bsN2QK7EhhLzS2/+4O c5dWzTAbCyS23qS1Ou1CTdyQURNafmWu80nYLUX9+HpFAOt0zoh9Jjg06zkpJwyfbn5u CcLY1vAlqljxN+5tXBNNe+USYEsE+Sxn6Vntfm0elYx4lztR5MkcpsW3C94+WFq3/rEy +DSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S+p3CsUB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a63d009000000b00429cf28b83dsi15258182pgf.396.2022.08.23.04.21.39; Tue, 23 Aug 2022 04:21:51 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=S+p3CsUB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349489AbiHWJYQ (ORCPT + 99 others); Tue, 23 Aug 2022 05:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350570AbiHWJV7 (ORCPT ); Tue, 23 Aug 2022 05:21:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C50D8E0C7; Tue, 23 Aug 2022 01:35:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E6B96614DA; Tue, 23 Aug 2022 08:34:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF406C433D6; Tue, 23 Aug 2022 08:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243644; bh=mVBmaehpQ/O+zrjmiuuFeI+9dN+eLesTdAlf4Fd5+Rw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S+p3CsUBmcPjfd8Nfv9gMvx9Et44Ay19hIZnX3EB1QERQ7WM5h5EQrQgxgmBH1m71 WH7ugcQpl3w1etLBw3pic8rrlWn1CMiUqmZ7VrKPZPNPeb26F9LdCooT+KJhm4+g0+ TFMF1aBC6LpmmNZXRfdnCZsb69aBGAWjpJ08VGG8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Dufour , Michael Ellerman , Sasha Levin Subject: [PATCH 5.19 343/365] watchdog: export lockup_detector_reconfigure Date: Tue, 23 Aug 2022 10:04:04 +0200 Message-Id: <20220823080132.584041384@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurent Dufour [ Upstream commit 7c56a8733d0a2a4be2438a7512566e5ce552fccf ] In some circumstances it may be interesting to reconfigure the watchdog from inside the kernel. On PowerPC, this may helpful before and after a LPAR migration (LPM) is initiated, because it implies some latencies, watchdog, and especially NMI watchdog is expected to be triggered during this operation. Reconfiguring the watchdog with a factor, would prevent it to happen too frequently during LPM. Rename lockup_detector_reconfigure() as __lockup_detector_reconfigure() and create a new function lockup_detector_reconfigure() calling __lockup_detector_reconfigure() under the protection of watchdog_mutex. Signed-off-by: Laurent Dufour [mpe: Squash in build fix from Laurent, reported by Sachin] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220713154729.80789-3-ldufour@linux.ibm.com Signed-off-by: Sasha Levin --- include/linux/nmi.h | 2 ++ kernel/watchdog.c | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 750c7f395ca9..f700ff2df074 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -122,6 +122,8 @@ int watchdog_nmi_probe(void); int watchdog_nmi_enable(unsigned int cpu); void watchdog_nmi_disable(unsigned int cpu); +void lockup_detector_reconfigure(void); + /** * touch_nmi_watchdog - restart NMI watchdog timeout. * diff --git a/kernel/watchdog.c b/kernel/watchdog.c index ecb0e8346e65..8e61f21e7e33 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -537,7 +537,7 @@ int lockup_detector_offline_cpu(unsigned int cpu) return 0; } -static void lockup_detector_reconfigure(void) +static void __lockup_detector_reconfigure(void) { cpus_read_lock(); watchdog_nmi_stop(); @@ -557,6 +557,13 @@ static void lockup_detector_reconfigure(void) __lockup_detector_cleanup(); } +void lockup_detector_reconfigure(void) +{ + mutex_lock(&watchdog_mutex); + __lockup_detector_reconfigure(); + mutex_unlock(&watchdog_mutex); +} + /* * Create the watchdog infrastructure and configure the detector(s). */ @@ -573,13 +580,13 @@ static __init void lockup_detector_setup(void) return; mutex_lock(&watchdog_mutex); - lockup_detector_reconfigure(); + __lockup_detector_reconfigure(); softlockup_initialized = true; mutex_unlock(&watchdog_mutex); } #else /* CONFIG_SOFTLOCKUP_DETECTOR */ -static void lockup_detector_reconfigure(void) +static void __lockup_detector_reconfigure(void) { cpus_read_lock(); watchdog_nmi_stop(); @@ -587,9 +594,13 @@ static void lockup_detector_reconfigure(void) watchdog_nmi_start(); cpus_read_unlock(); } +void lockup_detector_reconfigure(void) +{ + __lockup_detector_reconfigure(); +} static inline void lockup_detector_setup(void) { - lockup_detector_reconfigure(); + __lockup_detector_reconfigure(); } #endif /* !CONFIG_SOFTLOCKUP_DETECTOR */ @@ -629,7 +640,7 @@ static void proc_watchdog_update(void) { /* Remove impossible cpus to keep sysctl output clean. */ cpumask_and(&watchdog_cpumask, &watchdog_cpumask, cpu_possible_mask); - lockup_detector_reconfigure(); + __lockup_detector_reconfigure(); } /* -- 2.35.1