From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01D46C7EE23 for ; Fri, 19 May 2023 21:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231671AbjESV3f (ORCPT ); Fri, 19 May 2023 17:29:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229812AbjESV3W (ORCPT ); Fri, 19 May 2023 17:29:22 -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 EF9751B5 for ; Fri, 19 May 2023 14:29:20 -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 75D6865AF6 for ; Fri, 19 May 2023 21:29:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C294EC433EF; Fri, 19 May 2023 21:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1684531759; bh=1gaD8tgmPXXTRF8vMDQowiwpNFsYivyop8BrFPCFDtg=; h=Date:To:From:Subject:From; b=qqwoZsUcAVCk0FNQL74W/BeAHlIRFrvZbZ0B7SRHvVCgkTcOg5YAqJmC/TJ32dTX5 pWrrihaFs18Tr8I6TCtFQxWr43rzIdaY8C7aMpNu7Ju487DXrX+l/6s72IXAcejht8 Hw2zyYnOS5UQUVbsdvigisP+32PtJz7YgLz6S8wY= Date: Fri, 19 May 2023 14:29:19 -0700 To: mm-commits@vger.kernel.org, will@kernel.org, wens@csie.org, tzungbi@chromium.org, swboyd@chromium.org, sumit.garg@linaro.org, ricardo.neri@intel.com, rdunlap@infradead.org, ravi.v.shankar@intel.com, pmladek@suse.com, npiggin@gmail.com, msys.mizuma@gmail.com, mpe@ellerman.id.au, mka@chromium.org, maz@kernel.org, mark.rutland@arm.com, lecopzer.chen@mediatek.com, kernelfans@gmail.com, irogers@google.com, groeck@chromium.org, eranian@google.com, davem@davemloft.net, daniel.thompson@linaro.org, christophe.leroy@csgroup.eu, ccross@android.com, catalin.marinas@arm.com, ak@linux.intel.com, dianders@chromium.org, akpm@linux-foundation.org From: Andrew Morton Subject: + watchdog-hardlockup-have-the-perf-hardlockup-use-__weak-functions-more-cleanly.patch added to mm-nonmm-unstable branch Message-Id: <20230519212919.C294EC433EF@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: watchdog/hardlockup: have the perf hardlockup use __weak functions more cleanly has been added to the -mm mm-nonmm-unstable branch. Its filename is watchdog-hardlockup-have-the-perf-hardlockup-use-__weak-functions-more-cleanly.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/watchdog-hardlockup-have-the-perf-hardlockup-use-__weak-functions-more-cleanly.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Douglas Anderson Subject: watchdog/hardlockup: have the perf hardlockup use __weak functions more cleanly Date: Fri, 19 May 2023 10:18:37 -0700 The fact that there watchdog_hardlockup_enable(), watchdog_hardlockup_disable(), and watchdog_hardlockup_probe() are declared __weak means that the configured hardlockup detector can define non-weak versions of those functions if it needs to. Instead of doing this, the perf hardlockup detector hooked itself into the default __weak implementation, which was a bit awkward. Clean this up. >From comments, it looks as if the original design was done because the __weak function were expected to implemented by the architecture and not by the configured hardlockup detector. This got awkward when we tried to add the buddy lockup detector which was not arch-specific but wanted to hook into those same functions. This is not expected to have any functional impact. Link: https://lkml.kernel.org/r/20230519101840.v5.13.I847d9ec852449350997ba00401d2462a9cb4302b@changeid Signed-off-by: Douglas Anderson Reviewed-by: Petr Mladek Cc: Andi Kleen Cc: Catalin Marinas Cc: Chen-Yu Tsai Cc: Christophe Leroy Cc: Colin Cross Cc: Daniel Thompson Cc: "David S. Miller" Cc: Guenter Roeck Cc: Ian Rogers Cc: Lecopzer Chen Cc: Marc Zyngier Cc: Mark Rutland Cc: Masayoshi Mizuma Cc: Matthias Kaehlcke Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Pingfan Liu Cc: Randy Dunlap Cc: "Ravi V. Shankar" Cc: Ricardo Neri Cc: Stephane Eranian Cc: Stephen Boyd Cc: Sumit Garg Cc: Tzung-Bi Shih Cc: Will Deacon Signed-off-by: Andrew Morton --- include/linux/nmi.h | 10 ---------- kernel/watchdog.c | 30 ++++++++++++++++++------------ kernel/watchdog_perf.c | 20 ++++++++++++++------ 3 files changed, 32 insertions(+), 28 deletions(-) --- a/include/linux/nmi.h~watchdog-hardlockup-have-the-perf-hardlockup-use-__weak-functions-more-cleanly +++ a/include/linux/nmi.h @@ -103,21 +103,11 @@ static inline void arch_touch_nmi_watchd #if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) extern void hardlockup_detector_perf_stop(void); extern void hardlockup_detector_perf_restart(void); -extern void hardlockup_detector_perf_disable(void); -extern void hardlockup_detector_perf_enable(void); extern void hardlockup_detector_perf_cleanup(void); -extern int hardlockup_detector_perf_init(void); #else static inline void hardlockup_detector_perf_stop(void) { } static inline void hardlockup_detector_perf_restart(void) { } -static inline void hardlockup_detector_perf_disable(void) { } -static inline void hardlockup_detector_perf_enable(void) { } static inline void hardlockup_detector_perf_cleanup(void) { } -# if !defined(CONFIG_HAVE_NMI_WATCHDOG) -static inline int hardlockup_detector_perf_init(void) { return -ENODEV; } -# else -static inline int hardlockup_detector_perf_init(void) { return 0; } -# endif #endif void watchdog_hardlockup_stop(void); --- a/kernel/watchdog.c~watchdog-hardlockup-have-the-perf-hardlockup-use-__weak-functions-more-cleanly +++ a/kernel/watchdog.c @@ -187,27 +187,33 @@ static inline void watchdog_hardlockup_k #endif /* !CONFIG_HARDLOCKUP_DETECTOR_PERF */ /* - * These functions can be overridden if an architecture implements its - * own hardlockup detector. + * These functions can be overridden based on the configured hardlockdup detector. * * watchdog_hardlockup_enable/disable can be implemented to start and stop when - * softlockup watchdog start and stop. The arch must select the + * softlockup watchdog start and stop. The detector must select the * SOFTLOCKUP_DETECTOR Kconfig. */ -void __weak watchdog_hardlockup_enable(unsigned int cpu) -{ - hardlockup_detector_perf_enable(); -} +void __weak watchdog_hardlockup_enable(unsigned int cpu) { } -void __weak watchdog_hardlockup_disable(unsigned int cpu) -{ - hardlockup_detector_perf_disable(); -} +void __weak watchdog_hardlockup_disable(unsigned int cpu) { } /* Return 0, if a hardlockup watchdog is available. Error code otherwise */ int __weak __init watchdog_hardlockup_probe(void) { - return hardlockup_detector_perf_init(); + /* + * If CONFIG_HAVE_NMI_WATCHDOG is defined then an architecture + * is assumed to have the hard watchdog available and we return 0. + */ + if (IS_ENABLED(CONFIG_HAVE_NMI_WATCHDOG)) + return 0; + + /* + * Hardlockup detectors other than those using CONFIG_HAVE_NMI_WATCHDOG + * are required to implement a non-weak version of this probe function + * to tell whether they are available. If they don't override then + * we'll return -ENODEV. + */ + return -ENODEV; } /** --- a/kernel/watchdog_perf.c~watchdog-hardlockup-have-the-perf-hardlockup-use-__weak-functions-more-cleanly +++ a/kernel/watchdog_perf.c @@ -132,10 +132,14 @@ static int hardlockup_detector_event_cre } /** - * hardlockup_detector_perf_enable - Enable the local event + * watchdog_hardlockup_enable - Enable the local event + * + * @cpu: The CPU to enable hard lockup on. */ -void hardlockup_detector_perf_enable(void) +void watchdog_hardlockup_enable(unsigned int cpu) { + WARN_ON_ONCE(cpu != smp_processor_id()); + if (hardlockup_detector_event_create()) return; @@ -147,12 +151,16 @@ void hardlockup_detector_perf_enable(voi } /** - * hardlockup_detector_perf_disable - Disable the local event + * watchdog_hardlockup_disable - Disable the local event + * + * @cpu: The CPU to enable hard lockup on. */ -void hardlockup_detector_perf_disable(void) +void watchdog_hardlockup_disable(unsigned int cpu) { struct perf_event *event = this_cpu_read(watchdog_ev); + WARN_ON_ONCE(cpu != smp_processor_id()); + if (event) { perf_event_disable(event); this_cpu_write(watchdog_ev, NULL); @@ -227,9 +235,9 @@ void __init hardlockup_detector_perf_res } /** - * hardlockup_detector_perf_init - Probe whether NMI event is available at all + * watchdog_hardlockup_probe - Probe whether NMI event is available at all */ -int __init hardlockup_detector_perf_init(void) +int __init watchdog_hardlockup_probe(void) { int ret = hardlockup_detector_event_create(); _ Patches currently in -mm which might be from dianders@chromium.org are migrate_pages-avoid-blocking-for-io-in-migrate_sync_light.patch watchdog-perf-define-dummy-watchdog_update_hrtimer_threshold-on-correct-config.patch watchdog-perf-more-properly-prevent-false-positives-with-turbo-modes.patch watchdog-hardlockup-add-comments-to-touch_nmi_watchdog.patch watchdog-perf-rename-watchdog_hldc-to-watchdog_perfc.patch watchdog-hardlockup-move-perf-hardlockup-checking-panic-to-common-watchdogc.patch watchdog-hardlockup-style-changes-to-watchdog_hardlockup_check-is_hardlockup.patch watchdog-hardlockup-add-a-cpu-param-to-watchdog_hardlockup_check.patch watchdog-hardlockup-move-perf-hardlockup-watchdog-petting-to-watchdogc.patch watchdog-hardlockup-rename-some-nmi-watchdog-constants-function.patch watchdog-hardlockup-have-the-perf-hardlockup-use-__weak-functions-more-cleanly.patch watchdog-hardlockup-detect-hard-lockups-using-secondary-buddy-cpus.patch watchdog-perf-add-a-weak-function-for-an-arch-to-detect-if-perf-can-use-nmis.patch arm64-enable-perf-events-based-hard-lockup-detector.patch