From patchwork Thu May 4 22:13:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231888 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 B66FFC77B7C for ; Thu, 4 May 2023 22:41:07 +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=WrcMe9r5Ww6T+Ys1a8p1ul7NvEn1QBWPOgWjXOqxNyk=; b=B1IParZUr1o+G+ oMeBvcN8Myd3sDCFHD0qLA0FM3Pp8rjk7fHktj45Valq6dEHJkBw+y1zmfGRD01pdB3/HyWozbG/V baZbkGvAKy0V0Yl7ZZBEQZmIMHlwunQWtUHzgjTtG4zlTViFvXQuaevl4FUgGNYLBndAwgfqI7T1r gP4y4KpvFTno2haPYHASXUzDPW3RefMF6gdOYz7FNh51zWwhvEBJ5QWy43AGnVW5ghwRY4l8j0lSu lvCKXLYWuNnPrxeg1mjs7QKtpsaN2/gQZe4dPWumDBDtEw2YbW0KntiJAHAxheOeVkyn3+pDWMS2+ qCrJThjsg11rQDQ6A0yQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhcb-009EIH-2A; Thu, 04 May 2023 22:40:21 +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 1puhcY-009EGQ-0a for linux-arm-kernel@bombadil.infradead.org; Thu, 04 May 2023 22:40:18 +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=FhHtU5MlgVkLZBN593zWW2dHO7raDMa9z0DGkh7aQQA=; b=Gs86t+cJeNmK889wzbLFzUt05+ VwMLI1415sw+qYyyZS3Np0p5pp8Ala7UnFtsaHRJKv8nHchZVIJikCFpHuUUTpP53HUcVHnmAlsUr jPU3PPy0MYA4rX0tTnh0R5GvIoxZKauSwAziuXO1suMOAfncp/7gvaSTFyMWsp9QXErBe0MCsMiri 1wbsgXHc+UzjASTR2Alrz/6cZrNjMyeR/BjaQRtDJlldV0orjfHjm37xQKf5CWdt0p64BsDNkWN+5 cLjZjL8GMffxymgaMOKF22wZUPnN0Ujns0pX0Cvk7d1Rv4UFHjrnzQ2l+ru1h8Uu/TJ+D6faWZbvC 0z3IAxXw==; Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEX-001suR-2z for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:32 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-64115e652eeso15803781b3a.0 for ; Thu, 04 May 2023 15:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238528; x=1685830528; 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=FhHtU5MlgVkLZBN593zWW2dHO7raDMa9z0DGkh7aQQA=; b=AZfJjOvlBRLPq35PSplJJ+JYRGZt7OefDhVJlRBHr9EYYdVNT51FCHscN9mOVWJ7+X 2XnR0HqhUhDmrlmX4oNHyvCzSNHTlLNyfKHQ8biB/hGV6PVWpiFIzyZaQ0nZtQgYNML8 QgmfxWJsTrrtszemd5AoyBsyIti+tLvC+QSk4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238528; x=1685830528; 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=FhHtU5MlgVkLZBN593zWW2dHO7raDMa9z0DGkh7aQQA=; b=ZSCQE3EgurTaoXbRF5ESuzdLY0SSPYzJn/rgXuu7Bwgoko0xAvH9NG5NVnxuhlPARh +k4537xComA9OW4xqDFXWP5hNIyoa5kVbg40KGWlohgiz0/bcKRrrgvEPpKEFWfUpsyH HluQoihL1aRG6TSW28/ZNI+KeVpmCLtXjUliEaKjcoJgp3w+I0eqjQ5YiqCz/nCn9coZ W5U7F6DwPZMndwLKS5QllrFBtUJz/8oocldm3kqFUT7eb5RgRITkqV+lAJLWtzK2qKQo sby1Eac1oGJdpTRWW64wUyJ5u5zCsM52vW0kJelQNuDD4mqYkszBPNFi2xYlZmYaTtwH CWwg== X-Gm-Message-State: AC+VfDzNyWfx0qkuxaKY0l5pshTjYvO0dxSz9Fb/9d4jNRZ1AXRuNADG 3+7B7W9NIpiKWGJrkj3u+sDQKA== X-Google-Smtp-Source: ACHHUZ4biFdgijoXhRdQ+wzTyW9etdV3w75397sev3cW79igPU1T0GmbQpPqaTum52xSmugcqsSXFw== X-Received: by 2002:a05:6a00:234b:b0:63d:3c39:ecc2 with SMTP id j11-20020a056a00234b00b0063d3c39ecc2mr4256892pfj.12.1683238527839; Thu, 04 May 2023 15:15:27 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:edf0:7321:6b9e:d5e7]) by smtp.gmail.com with ESMTPSA id g26-20020aa7819a000000b006437c0edf9csm169615pfi.16.2023.05.04.15.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:27 -0700 (PDT) From: Douglas Anderson To: Petr Mladek , Andrew Morton Cc: Sumit Garg , Mark Rutland , Matthias Kaehlcke , Stephane Eranian , Stephen Boyd , ricardo.neri@intel.com, Tzung-Bi Shih , Lecopzer Chen , kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , Guenter Roeck , Pingfan Liu , Andi Kleen , Ian Rogers , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Randy Dunlap , Chen-Yu Tsai , christophe.leroy@csgroup.eu, davem@davemloft.net, sparclinux@vger.kernel.org, mpe@ellerman.id.au, Will Deacon , ravi.v.shankar@intel.com, npiggin@gmail.com, linuxppc-dev@lists.ozlabs.org, Marc Zyngier , Catalin Marinas , Daniel Thompson , Douglas Anderson Subject: [PATCH v4 14/17] watchdog/perf: Add a weak function for an arch to detect if perf can use NMIs Date: Thu, 4 May 2023 15:13:46 -0700 Message-ID: <20230504151100.v4.14.Ic55cb6f90ef5967d8aaa2b503a4e67c753f64d3a@changeid> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog In-Reply-To: <20230504221349.1535669-1-dianders@chromium.org> References: <20230504221349.1535669-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230504_231530_382590_8A276CA4 X-CRM114-Status: GOOD ( 18.46 ) 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"? 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 90aa33317b4c..9caea5ba494d 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -212,6 +212,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 a55a6eab1b3a..0d1c292a655d 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");