Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1711548rwb; Sun, 14 Aug 2022 10:09:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR6jKKBrifUFGwca7gIvoAZ6xNMX+8xF54E1XCoTb6EPpqvr/yoMgKjusIIThod1UfhhqfAU X-Received: by 2002:a17:907:9688:b0:730:f098:86d0 with SMTP id hd8-20020a170907968800b00730f09886d0mr8201012ejc.60.1660496954046; Sun, 14 Aug 2022 10:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660496954; cv=none; d=google.com; s=arc-20160816; b=O3Re/LuJwa255ssXlH/0gv59KJScdzY7rSyvqDhSadQVmc6QRawpuSJqf3S7TTQ4nP 6mzR6qft77Sg6qMDx9fkhJ5k5/dTiYUPO5d9OUt+kWgT/OqH774U5py/n691xjc3ezav MOucntRzkhWWa1sFeEshgIzNMO7TuSqktzufOiTzKCmjty3zkI65ufo7PCVu7Ye1V5HI f10youF4+Ozg19yKrE9ske9zb9FtIoAOuaj2G9REPRJnN+BK9z4ze93dT7+1sm4tdS2H dr7q1lMW029TCYqT950M4aIi1IK9pUvUfjzQPbHmbHvQeosM3UthscA/z6/7y6yTXypp TUqw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z/cAu2ln+pRJDmNk9vZeHKRbkZhXl+mUKiBsxcD7428=; b=DF+85aFqYYLzb0k1ZPamqxINAyuUAcg2GdSDH3GjxB0qgsGW1kLx0KN+TnIBG2XiJm BB0TNIcwbyNBM0GQP1hzqcx6q7fjTBm393JgXbQrE2kh8CuoGI6p6qdNFFX4PkkZj5OR Cpj/dF3W16VT8ug8JSrAL09PnIb6ocxGPuVSFs9Ld71FoiOCTUkPiOKjGZqAUMCYoWhx 6AET4y4J7oqQIjxkqgB3GrNcZBisY0QD7hwaBA5smcEe30S3KOZemu9V4konvq21J692 VwVD1eX93/o47skdqQKUnzm/B9eVBzgd+cYfgMnufiozkv40sisgwemZ0FCqE8Z3yP2J IyqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cPnjcOBP; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i21-20020a17090685d500b007123952b00dsi5051904ejy.100.2022.08.14.10.08.49; Sun, 14 Aug 2022 10:09:14 -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=@kernel.org header.s=k20201202 header.b=cPnjcOBP; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242798AbiHNQeq (ORCPT + 99 others); Sun, 14 Aug 2022 12:34:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242068AbiHNQcS (ORCPT ); Sun, 14 Aug 2022 12:32:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B31D325296; Sun, 14 Aug 2022 09:26:58 -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 A57A060FBD; Sun, 14 Aug 2022 16:26:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B11A2C433C1; Sun, 14 Aug 2022 16:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660494417; bh=43GzhRkhEbwNxskyppUOE7zuVHwQvae/qFtzbaRz0xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cPnjcOBPewbu2orc1l2o20D6eggMxlU1VrA4KZIJ1Z9vABorLxvUkMbNocGDYqPn2 3oM7mqSbvoduXk5lXAIsiMmy6x1H4OJPEWy6Tp8aaMKZFS5DEjOiYLtmt/F9DTx5IR dFIN1ONOv4yyMCHRVPc162Hf8oWMXrMIEam5EG11ltMZIe2rxU48gmdigy7OrHyE8G /g7opHl+a84pDElvwDchEVWPrPx8+VQxR4J3/Wr/dGxqmQmnNdrARJryuh2e4sqMg3 /ApUKBUWlpygNFN6Q8kQrBI9mZI1vpxXPAcYfBZv4aJRQwhwPwYja0Fs/KPHlhPaAO iYLGqYnfGCzJw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Laurent Dufour , Michael Ellerman , Sasha Levin , pmladek@suse.com, akpm@linux-foundation.org, juri.lelli@redhat.com, pauld@redhat.com, nixiaoming@huawei.com, john.ogness@linutronix.de, frederic@kernel.org, linux@rasmusvillemoes.dk Subject: [PATCH AUTOSEL 5.15 14/28] watchdog: export lockup_detector_reconfigure Date: Sun, 14 Aug 2022 12:25:54 -0400 Message-Id: <20220814162610.2397644-14-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814162610.2397644-1-sashal@kernel.org> References: <20220814162610.2397644-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 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 ad912511a0c0..1cfa269bd448 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