From patchwork Fri May 19 17:18:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13248686 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DFA35C7EE29 for ; Fri, 19 May 2023 17:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0tMtQkh2Ofe36cwYrbR4WC2Nlax+1R6w4FvFoBp7sAU=; b=TffzQsV0BGxt+T 0Cs4/bko67WUTN4ZdsTDCxHJoYRkhi6VVVianvfnMJMmzQXPA0qbRLwhR+RUDLADjnKPEqK2qPTR6 VglSzk22IWNsrdp8nbYiHKDhL09S/CZk6UFU6hYc4Fv+rpJotcJGGItlhGkiPoanSaBcm3yKOyisr scvX202f5VEWG5Kmvjm7QAak2bBgJ14KIqtrHZuQ3o8eCIblsnLGyM9/h40tFC1wobPS9FUurc/Eq eze/RiZVTRtFY+/5LG/7mHc45t48mGCdcv/7xFoUSzD8cwD9GUJ2jU3TbOb5zj73JwpqRsfdA+yzE zZT4FyTUgZHB02yFP7Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q046u-00GtB5-25; Fri, 19 May 2023 17:41:48 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q046s-00Gt9Z-1v for linux-arm-kernel@bombadil.infradead.org; Fri, 19 May 2023 17:41:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=TL6x11AHUdbqwPOBex8MH92mOu6poqhjfJN8Bz63N4s=; b=PoA2EMq1ZNUxXgnnhRAi5smG6K PKxDLAMv+zFb8Eny4kfPF4pIo3w97rR3Uw4jGFmzSaGcJODqSZobY/AIXW1Deje5SsvIR4ySsCNkQ mPBMISInYgmYHT5/zwTDVaSlMvOjCsEdEGl9iLVN4LKoeI3KdSjMT4SkkIV96FzKeAYPvMwPmUTb+ pIJq04XLrS8uRzb20pvydA+XxGZa2eGTSwCRbQX5RR0kj9IGUq7uB6Jn5icT97FkKKaIb0ZOq6tys HkvHex0reEQG6i90383cG4HQPvDPrMUAIuJSd2jW98GvnNKrdHsB+aeLc4vqAECr8Hg7M8GokS1NI iP2uf00g==; Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q03nB-00Fxv0-0O for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2023 17:21:26 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1ae54b623c2so31826255ad.3 for ; Fri, 19 May 2023 10:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684516884; x=1687108884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TL6x11AHUdbqwPOBex8MH92mOu6poqhjfJN8Bz63N4s=; b=Pht+hrXlamhoKc3Sfk+JnwTbwmcG4p0AC6wXT9KK+YLT5G/A8PMg/Kgierf2mtzawr ClBv70BUaPRNqYHKjGkk7QBTOalxnZ8r6RtmZDQddTP1/P2XptlY4Z2wVzZmyx2mgkUl BcimCZ+ntm13VOGd+9TV47CPKcYCQWDP2CsA4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684516884; x=1687108884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TL6x11AHUdbqwPOBex8MH92mOu6poqhjfJN8Bz63N4s=; b=eXSzFPegNkZ2WtpRK48Xi5I9K5sB3UEKmvMBuV7Vq3uccQYmMCbO1mqecNKBRtOmdh gOKSFdqmrjzK0l6Q+7SvuGyDi0Ohc5qXqDbigN+IYZSfc+HMrnXNCnTEmFgacg/88g7n 5K8dy8Mc1l5gJ+rbZ/xn+jTL6haJ9XOQ/xnbN9YCTVmZJQ3oNtm5zEHoXXVX+KJCaWb0 +93pmm/T+N1ykUpEm5Y9ZpFKzTEBWpf2Yh08gaMS+Zqbc/TYgR+M9h2iPlKFeZ7KMbT+ TitPYo78juedhxLMwEvJLBxX6pc9frI9tIK0cTPVa7yRh+VjWfjww8Nle2zHzIX9NCxy Kk/g== X-Gm-Message-State: AC+VfDx3dW4FNmq2gVZhyH3IyTbkmPggx6FWASnK1U9ZJ0AmlYQYgPeE REFg3MPLspEVVGP7a6Yz5lvtWA== X-Google-Smtp-Source: ACHHUZ42iEc62iH4hoBzId667tClAxoJ0OHdYYIBvBIVMKi1bhk7AD73MYNJ7aE36NwledCLjmXG2w== X-Received: by 2002:a17:902:e80b:b0:1a1:f5dd:2dce with SMTP id u11-20020a170902e80b00b001a1f5dd2dcemr3490112plg.6.1684516883784; Fri, 19 May 2023 10:21:23 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:9b89:2dd0:d160:429d]) by smtp.gmail.com with ESMTPSA id gj19-20020a17090b109300b0024e4f169931sm1763835pjb.2.2023.05.19.10.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 10:21:23 -0700 (PDT) From: Douglas Anderson To: Petr Mladek , Andrew Morton Cc: Matthias Kaehlcke , kgdb-bugreport@lists.sourceforge.net, Stephane Eranian , mpe@ellerman.id.au, Tzung-Bi Shih , Daniel Thompson , Mark Rutland , linuxppc-dev@lists.ozlabs.org, Sumit Garg , npiggin@gmail.com, davem@davemloft.net, Marc Zyngier , Stephen Boyd , sparclinux@vger.kernel.org, christophe.leroy@csgroup.eu, Catalin Marinas , ravi.v.shankar@intel.com, Randy Dunlap , Pingfan Liu , Guenter Roeck , Lecopzer Chen , Ian Rogers , ito-yuichi@fujitsu.com, ricardo.neri@intel.com, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, Will Deacon , Chen-Yu Tsai , linux-kernel@vger.kernel.org, Masayoshi Mizuma , Andi Kleen , Douglas Anderson Subject: [PATCH v5 15/18] watchdog/perf: Add a weak function for an arch to detect if perf can use NMIs Date: Fri, 19 May 2023 10:18:39 -0700 Message-ID: <20230519101840.v5.15.Ic55cb6f90ef5967d8aaa2b503a4e67c753f64d3a@changeid> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog In-Reply-To: <20230519101840.v5.18.Ia44852044cdcb074f387e80df6b45e892965d4a1@changeid> References: <20230519101840.v5.18.Ia44852044cdcb074f387e80df6b45e892965d4a1@changeid> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230519_182125_289000_96A55BDB X-CRM114-Status: GOOD ( 18.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On arm64, NMI support needs to be detected at runtime. Add a weak function to the perf hardlockup detector so that an architecture can implement it to detect whether NMIs are available. Signed-off-by: Douglas Anderson --- While I won't object to this patch landing, I consider it part of the arm64 perf hardlockup effort. I would be OK with the earlier patches in the series landing and then not landing ${SUBJECT} patch nor anything else later. I'll also note that, as an alternative to this, it would be nice if we could figure out how to make perf_event_create_kernel_counter() fail on arm64 if NMIs aren't available. Maybe we could add a "must_use_nmi" element to "struct perf_event_attr"? (no changes since v4) Changes in v4: - ("Add a weak function for an arch to detect ...") new for v4. include/linux/nmi.h | 1 + kernel/watchdog_perf.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 47db14e7da52..eb616fc07c85 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -210,6 +210,7 @@ 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/kernel/watchdog_perf.c b/kernel/watchdog_perf.c index 349fcd4d2abc..8ea00c4a24b2 100644 --- a/kernel/watchdog_perf.c +++ b/kernel/watchdog_perf.c @@ -234,12 +234,22 @@ void __init hardlockup_detector_perf_restart(void) } } +bool __weak __init arch_perf_nmi_is_available(void) +{ + return true; +} + /** * watchdog_hardlockup_probe - Probe whether NMI event is available at all */ int __init watchdog_hardlockup_probe(void) { - int ret = hardlockup_detector_event_create(); + int ret; + + if (!arch_perf_nmi_is_available()) + return -ENODEV; + + ret = hardlockup_detector_event_create(); if (ret) { pr_info("Perf NMI watchdog permanently disabled\n");