Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4432964imw; Tue, 12 Jul 2022 07:53:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t6Iz+snAmb/uE//aIKByrh9hFGG4Mo+iqc8x5wPBesWwcvln4gBbCZ7AsWHOBI+QNLrNrn X-Received: by 2002:a17:90b:2243:b0:1f0:b0a:e40c with SMTP id hk3-20020a17090b224300b001f00b0ae40cmr4962169pjb.76.1657637584829; Tue, 12 Jul 2022 07:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657637584; cv=none; d=google.com; s=arc-20160816; b=L2bCcLuvvF6t3raO3inrBaYtM/DTqsJXOMMw7STljtt2XC8e6oIcmZOy4/cjA9cQeC czMIO/gUnQL/xDcreaUlOq4vIFttr/Dan91tVdxJlrVrc4ZaLmg8oa13DEWPq9K19RFL X3i92a0YPcOrNWSoflfc7Pr+JjMX+MoyNpq5rImZuG1LxxtWRlIPDL/4IXcgeo+GkLWa bAmhM9WH2grVtxDmaeM+lJzEyuM5jJkkbOpjJiHGLysQxI0EORGXPaUcEbzP7Yw9CVLL AOLL1H1WFJc4Udbveu3mjzNgiJXYtCI0JwxAG65mE1QAhNln+FdVvRJAUFBgZXHZl6G4 bliA== 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=OqEsGehoDv7WhZIWjrAncQCiO+QkUV2kIJiuCbfX46c=; b=OqE+5duGnSv6Kem695yBulso2WwJ0v5NyEEPjI+IEQczRYgYBTBkyNKuokTcBLd92B dKwiX6Coh0C1uEPxofPG0AyApSjjPt8DVH8Z9IqD+XZUjmw8gAoSxWNINZh7zbGixucc /j+8vy8bBXYK464PWsUJ90lMqLI05KnyY44NcwLHOTKPsqO+sUqt3HeaKtyVwFNFyNVx juXvBIPiHuvLxo4EQKQffCbwWKa4Zi0U6VGaFmIpl/RPZf0nQ3OWZnXVm6KUv3g+8ocj Ku0QCE3oMr0SUv7hNQTBnLNG2pyiJRZLrNa9d3ya/IEYOqIFBgJ/JszOFFyUhz6VfePS xQ9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=tQwpbPwJ; 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=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id me14-20020a17090b17ce00b001e0b16a6bb9si15557482pjb.159.2022.07.12.07.52.52; Tue, 12 Jul 2022 07:53:04 -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=@ibm.com header.s=pp1 header.b=tQwpbPwJ; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233244AbiGLOcr (ORCPT + 99 others); Tue, 12 Jul 2022 10:32:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbiGLOcg (ORCPT ); Tue, 12 Jul 2022 10:32:36 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77EB120F51; Tue, 12 Jul 2022 07:32:35 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26CDJ0Ag006981; Tue, 12 Jul 2022 14:32:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=OqEsGehoDv7WhZIWjrAncQCiO+QkUV2kIJiuCbfX46c=; b=tQwpbPwJRqFs4fEcXf2zCihGiXm5VxUBNc3lsPC0tMWmK+uPXlkUD6n8F/eXhajc4hFf aVLPTeEmzDnxroIHHJw5lFwOquN62+DwXPh/sWuDk8dAXrgVCW/uBm4Yhi8clYhWfPve d0gcmayhT4bQTtuR1rcC+TgY3c0EB6BQ6MVDvs2MaRHx9Jf+oQPgqOoNLD+zL5KsoYJw y4+8QCC1hFLkY1Is8gBgRyDoIRi/YYKjAoYz8Sb5ze4bnEWkJo5yhgmd5Hbf4zededCZ vnLE6BGZxHNn3SBGNWjJZf926xPG/+ka2HA/dZ3hEJNMp247CtoD0jMei7chQ9H7H6/g Ag== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3h99r0228r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 14:32:12 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26CDfZwf002699; Tue, 12 Jul 2022 14:32:11 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3h99r0226d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 14:32:11 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26CEMDi3029760; Tue, 12 Jul 2022 14:32:06 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06fra.de.ibm.com with ESMTP id 3h8ncngdq5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 14:32:06 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26CEW4Rk16384434 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Jul 2022 14:32:04 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CBFCA405F; Tue, 12 Jul 2022 14:32:04 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7301A4054; Tue, 12 Jul 2022 14:32:03 +0000 (GMT) Received: from pomme.tlslab.ibm.com (unknown [9.101.4.33]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 12 Jul 2022 14:32:03 +0000 (GMT) From: Laurent Dufour To: mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, wim@linux-watchdog.org, linux@roeck-us.net, nathanl@linux.ibm.com Cc: haren@linux.vnet.ibm.com, hch@infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-watchdog@vger.kernel.org Subject: [PATCH v4 2/4] watchdog: export lockup_detector_reconfigure Date: Tue, 12 Jul 2022 16:32:00 +0200 Message-Id: <20220712143202.23144-3-ldufour@linux.ibm.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712143202.23144-1-ldufour@linux.ibm.com> References: <20220712143202.23144-1-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: EuQ7dFqyQ2kclyPpg0qGIUzE6zxKXqRY X-Proofpoint-ORIG-GUID: L4hbfXEqjeFr9W7WKTq27rcfQ3vkY1eZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-12_08,2022-07-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 phishscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 clxscore=1015 spamscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207120056 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,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 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. Cc: Christoph Hellwig Signed-off-by: Laurent Dufour --- 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 20a7a55e62b6..90e6c41d5e33 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -541,7 +541,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(); @@ -561,6 +561,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). */ @@ -577,13 +584,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) +void __lockup_detector_reconfigure(void) { cpus_read_lock(); watchdog_nmi_stop(); @@ -591,9 +598,13 @@ static void lockup_detector_reconfigure(void) watchdog_nmi_start(); cpus_read_unlock(); } +static inline 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 */ @@ -633,7 +644,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.37.0