From patchwork Mon May 22 11:48:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 97328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1386091vqo; Mon, 22 May 2023 04:52:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4FGZKR94RVyb8IY2ofW9S9VO3iCMjhpfHrn9cF7ePitgt+2EvlqrhlkX5nPAze0Bwi6+Qx X-Received: by 2002:a05:6a00:1594:b0:643:53b6:d841 with SMTP id u20-20020a056a00159400b0064353b6d841mr17379595pfk.2.1684756331635; Mon, 22 May 2023 04:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684756331; cv=none; d=google.com; s=arc-20160816; b=D6V6DYCKNeEeKCsbVe1ZOAnD6fqBMmEa8CjKjNsuHHrmfHOHXKhnmicaaO7vPyYmIC 6fMiA5UMvTRZayo2nF78f/lWjNAPiVZJX8kvhfpCObTfYYJYh6YKH0jAxbqTrT0DT1ln RIqKQxT/WiUfw5qa6l+EnUm/Z4CGVmvsPPFHnmcLF17hgIX4IzhqJjKX5rzexlkDmEZW Gop22wLCQhDzys6qmOLu7fHAwJf9UXuruTX7Dt4bui5fcd1u5NFU7X68FRy4PwkY5QuT Ol8f7P08IxEXqhq7uUKQ4I8+oyjKlIsqzlSwYfwRcQBKYnCsVyfQF0qgzvhhebbPIIRh Rz7g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=AgCv1U4CYhcYZE3oRMQv6NtW2Kz4WsiUBcqWmJF3oeU=; b=gkoBCRyuQxItRa8k2I3tcni9MOBgbrXF21ol6/YfnsdaKQVXjhSsntqYSm0PIFOQQl lpe1fJW/USauueF3uuruMp41lnxenZXSvLmkBX1Aeg/aAdYmSG3SjL0ODYnvoAuEAD38 h6ANtjZWYnbhwHPuTdN8+A0BmhqB5WdHpFxIxvxwXbq26Vl30o6MA9gPgmTJmUKg2Xrd KbPQAPuUgnLBcYh14BT3mNRx5HuL5RibEmB037E7VYt6sIkAkm6PEBKR29FXs09S9inu 9e1NlPrS2KNr3e+G7vTVzAneeG12kCAQYjsYMYE5z0Is4ix0+6Ri83JqAHCoCllIZbPH Sg7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c0KqqmNu; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a626105000000b0063d61f05a8fsi4533373pfb.198.2023.05.22.04.51.57; Mon, 22 May 2023 04:52:11 -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=c0KqqmNu; 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 S233417AbjEVLtd (ORCPT + 99 others); Mon, 22 May 2023 07:49:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233408AbjEVLta (ORCPT ); Mon, 22 May 2023 07:49:30 -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 E4458A3 for ; Mon, 22 May 2023 04:49:29 -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 716B86179D for ; Mon, 22 May 2023 11:49:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AADAC4339B; Mon, 22 May 2023 11:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684756168; bh=09RSAK353TjlZgFkK3E0PRiLI2ExOq5xZFRF9Hx0UP4=; h=From:To:Cc:Subject:Date:From; b=c0KqqmNuYsyt4bX1BLvfXqWPZCcBjtdh5HqKH68YbaY3HI4wEBOj7i0vTaevkB2Zf 1MUuJOSzE95fw9E4IITgFHNfrUIV9jQ5R8tHCZak380ujmsa4BkNrnItvev24qZu8o yzQnEOpXEGXdTEuzWCFKqW0IyzoyXLmYGbsSUke1f5qghWfmPEtciIxciOfV+9476M zwW/0syTWrRo7saMFxsm5FELZdvqbMKqwFOgBxIRFDz3ED5oGE/T807hXFO/8fYzGT kb+nyc89Ci19CXWtC/qQdnG9/ERmvnEEAJBVLxfcHl1PTEXAoJvhVktaGsEmzFy4AU BK7+3DASuOMmQ== From: Arnd Bergmann To: Andrew Morton , Douglas Anderson Cc: Arnd Bergmann , Catalin Marinas , Will Deacon , Mark Rutland , Pingfan Liu , Sumit Garg , Lecopzer Chen , Petr Mladek , Anshuman Khandual , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arm64: watchdog_hld: provide arm_pmu_irq_is_nmi stub Date: Mon, 22 May 2023 13:48:19 +0200 Message-Id: <20230522114922.1052421-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766595055520555021?= X-GMAIL-MSGID: =?utf-8?q?1766595055520555021?= From: Arnd Bergmann The newly added arch_perf_nmi_is_available() function fails to build when CONFIG_ARM_PMU is disabled: arch/arm64/kernel/watchdog_hld.c: In function 'arch_perf_nmi_is_available': arch/arm64/kernel/watchdog_hld.c:35:16: error: implicit declaration of function 'arm_pmu_irq_is_nmi' [-Werror=implicit-function-declaration] 35 | return arm_pmu_irq_is_nmi(); As it turns out, there is only one caller for that function anyway, in the same file as the __weak definition, and this can only be called if CONFIG_ARM_PMU is also enabled. I tried a number of variants, but everything ended up with more complexity from having both the __weak function and one or more added #ifdef. Keeping it in watchdog_perf.c is a small layering violation but otherwise the most robust. Fixes: 7e61b33831bc ("arm64: enable perf events based hard lockup detector") Signed-off-by: Arnd Bergmann --- --- arch/arm64/kernel/watchdog_hld.c | 10 ---------- include/linux/nmi.h | 1 - include/linux/perf/arm_pmu.h | 7 ++++--- kernel/watchdog_perf.c | 11 ++++++++++- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/arch/arm64/kernel/watchdog_hld.c b/arch/arm64/kernel/watchdog_hld.c index dcd25322127c..3d948e5c1c1e 100644 --- a/arch/arm64/kernel/watchdog_hld.c +++ b/arch/arm64/kernel/watchdog_hld.c @@ -24,13 +24,3 @@ u64 hw_nmi_get_sample_period(int watchdog_thresh) return (u64)max_cpu_freq * watchdog_thresh; } - -bool __init arch_perf_nmi_is_available(void) -{ - /* - * hardlockup_detector_perf_init() will success even if Pseudo-NMI turns off, - * however, the pmu interrupts will act like a normal interrupt instead of - * NMI and the hardlockup detector would be broken. - */ - return arm_pmu_irq_is_nmi(); -} diff --git a/include/linux/nmi.h b/include/linux/nmi.h index d23902a2fd49..1fabf8c35d27 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -212,7 +212,6 @@ static inline bool trigger_single_cpu_backtrace(int cpu) #ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period(int watchdog_thresh); -bool arch_perf_nmi_is_available(void); #endif #if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) && \ diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 5b00f5cb4cf9..cbdd3533d843 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -12,10 +12,11 @@ #include #include #include -#include #ifdef CONFIG_ARM_PMU +#include + /* * The ARMv7 CPU PMU supports up to 32 event counters. */ @@ -171,8 +172,6 @@ void kvm_host_pmu_init(struct arm_pmu *pmu); #define kvm_host_pmu_init(x) do { } while(0) #endif -bool arm_pmu_irq_is_nmi(void); - /* Internal functions only for core arm_pmu code */ struct arm_pmu *armpmu_alloc(void); void armpmu_free(struct arm_pmu *pmu); @@ -184,6 +183,8 @@ void armpmu_free_irq(int irq, int cpu); #endif /* CONFIG_ARM_PMU */ +bool arm_pmu_irq_is_nmi(void); + #define ARMV8_SPE_PDEV_NAME "arm,spe-v1" #endif /* __ARM_PMU_H__ */ diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c index 8ea00c4a24b2..ee7d3dcfdda2 100644 --- a/kernel/watchdog_perf.c +++ b/kernel/watchdog_perf.c @@ -19,6 +19,7 @@ #include #include +#include static DEFINE_PER_CPU(struct perf_event *, watchdog_ev); static DEFINE_PER_CPU(struct perf_event *, dead_event); @@ -234,8 +235,16 @@ void __init hardlockup_detector_perf_restart(void) } } -bool __weak __init arch_perf_nmi_is_available(void) +static bool __init arch_perf_nmi_is_available(void) { + /* + * hardlockup_detector_perf_init() will success even if Pseudo-NMI turns off, + * however, the pmu interrupts will act like a normal interrupt instead of + * NMI and the hardlockup detector would be broken. + */ + if (IS_ENABLED(CONFIG_ARM_PMU)) + return arm_pmu_irq_is_nmi(); + return true; }