From patchwork Thu May 4 22:13:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231879 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 A03C6C77B73 for ; Thu, 4 May 2023 22:16:13 +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=VjjyOmfDknkOtb53b6/k2dR34+N0o7Oswa293VUz2VQ=; b=zfZ++1AK7VdBMz HtuuSwLOQr9NTsLClvZRwYjI3rZ1/HdS9+YnBWLOHqLpHFax7EYbhOpZVgJPUCTZA55+3mVus77gP sza0f2oDaAZfnlan8d/4c0oF3KSkyiMbC5zYSEhEIAPt1OoBwSS0ep7BlGtxY8DcLbI05jwSVKuUt 7McbC9QpZOBoXN20cIubc+KdpkgIor7meIDN+Gz8JRxu16fDbm2GYqcs4juz26PzcPJ08QOfBcey1 +K1HC/e4k9llo1Qcg7yhlArz3wJ7Ui3uhiRjLBecrJHzWa1Drlgd81S89CTangGFftacSvKxXFRvW jjUZvlZUdRtjwaJfApjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhDx-009AQ3-2n; Thu, 04 May 2023 22:14:53 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhDt-009ANB-20 for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:14:51 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5144a9c11c7so920827a12.2 for ; Thu, 04 May 2023 15:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238486; x=1685830486; 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=q1z7mPfi+9kXcDKqT71sJAQGBxu7RyXh4JV2wfNk/es=; b=nIjoIkW3p03FUu+3GxCcNYkSzcj/lDeOENMDPI4fWfUDdG7bT08Sb+dJlzfLePSU5E mVGDvKwII6sScPmLx8Iom+7xMBMbGZTte6pLYZwgEDCl0uBaz3UERsDasZ//5a7Rt8ID KeoANLYDUm1QrguA2OgwX0v7dqA356HU4O/WQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238486; x=1685830486; 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=q1z7mPfi+9kXcDKqT71sJAQGBxu7RyXh4JV2wfNk/es=; b=EasL/HAWCI9638uBtKMWDkzBRq2W89UF+BzImfxZBf1OObxhkI1t+WuA09c/8P1tcs 902MSizZxNoRDjkrmPaHKaTDU4VAE4eR+eM7ZD6/C4QdGv7Dc0zOvCDOrVAx7oOZO3E0 7oAzTzOjojgVEr6jHXvwT5NNeAB5JcTAeAMCH4qxHWFR0rj15BvQiXuOwXGJJ8MuA2U/ tsAjfL/3hUVZEV+jDIyh/r6R6D2XjkOrL5zk95vfeo9tH6sw4JoGGK3gmBW13i7drWgV Mt+wL7nm6koBt+l80s+E3J1SEDqhL+tK46RTGVEr50ihdwTvSDUSyfZtX6yz/0Lno5NX S1ww== X-Gm-Message-State: AC+VfDwihuN4cdV0BIPM+U/8usiVY11aA/MxzPbhTVvePlb2Nk5rbvPQ kYimn3arhSG3eLfgYZ4DsoTYgA== X-Google-Smtp-Source: ACHHUZ6srX3RLh0nySv1vg2bjN5I3jzdANZ2xcZbCkodBOlfCv7QBn4Vf3SuhK63bPEngQxlNTdd2A== X-Received: by 2002:a05:6a20:7f8f:b0:f8:ac26:b899 with SMTP id d15-20020a056a207f8f00b000f8ac26b899mr4830221pzj.0.1683238486722; Thu, 04 May 2023 15:14:46 -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.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:14:46 -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 01/17] watchdog/perf: Define dummy watchdog_update_hrtimer_threshold() on correct config Date: Thu, 4 May 2023 15:13:33 -0700 Message-ID: <20230504151100.v4.1.I8cbb2f4fa740528fcfade4f5439b6cdcdd059251@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_151449_670149_3CF83397 X-CRM114-Status: GOOD ( 15.07 ) 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 The real watchdog_update_hrtimer_threshold() is defined in watchdog_hardlockup_perf.c. That file is included if CONFIG_HARDLOCKUP_DETECTOR_PERF and the function is defined in that file if CONFIG_HARDLOCKUP_CHECK_TIMESTAMP. The dummy version of the function in "nmi.h" didn't get that quite right. While this doesn't appear to be a huge deal, it's nice to make it consistent. Fixes: 7edaeb6841df ("kernel/watchdog: Prevent false positives with turbo modes") Signed-off-by: Douglas Anderson Reviewed-by: Nicholas Piggin --- Changes in v4: - ("Define dummy watchdog_update_hrtimer_threshold() ...") new for v4. include/linux/nmi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 048c0b9aa623..771d77b62bc1 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -197,7 +197,7 @@ u64 hw_nmi_get_sample_period(int watchdog_thresh); #endif #if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) && \ - defined(CONFIG_HARDLOCKUP_DETECTOR) + defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) void watchdog_update_hrtimer_threshold(u64 period); #else static inline void watchdog_update_hrtimer_threshold(u64 period) { } From patchwork Thu May 4 22:13:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231878 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 082D0C77B73 for ; Thu, 4 May 2023 22:16:05 +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=EzyhoKH1ywFwPOyU/aia+NIY4b5HO9XkGTcKeFMyCBA=; b=bfp00JaAhRMi4l fRmpgkPoXfch+2Gw1Vp0LKIvDrOWUD46CfHC3axZOYsdDXGGGzljxqfDTBjVbcmZg2zJ/FO6bvLIC gfvEWa0XT59qOZzmEkFlYBIJ6SjwA8lpkvwhMOC8D24b6okUdwZd3buDrg7+Ykx/jJQOjg+AnHow3 26HT2+1hWPyodEy5hjb91TD8PW/kbPkQM5Rl6tv+Ys4rxP/Me4nPpPS2zGVUIDkoqRWsE6iY70jA7 0dTKrf0uihBUbpWmjtUyyHeNzaqaWxvcS1HlKVOlhbjhB+I0Db87iS1p5RBXiNKXsi8XLqMAbSUV+ To86dmnYqLY3j+2X5q1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhDz-009AQo-35; Thu, 04 May 2023 22:14:55 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhDv-009AOa-1F for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:14:52 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-643990c5373so764485b3a.1 for ; Thu, 04 May 2023 15:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238489; x=1685830489; 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=8/SVxTc3UaBCcYMvWm7ggGzatNZYd3WDIFJWHr8ve6I=; b=X19hszaOFSMqhUUTvYqKnpXKHrV30sSo3SEXBWBDST1p9/syYROS0IIkdVGQ+OBBwc UOUV1W8ZrnobxsdA2rBQzkXVu5EgyHEFKYEabCh94CIJFZVhDifB8A+4LlZoZY+RhnMN 4c+Yj95+6/01UcWsLFOM6meTjnZu2KiTKN6lk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238489; x=1685830489; 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=8/SVxTc3UaBCcYMvWm7ggGzatNZYd3WDIFJWHr8ve6I=; b=gAktbc8u/Yqyq+zRcjdQI8cufMkguVVjg97BxImqb1Zt76jKw8W1w50m/EI18SQYq0 mwsOkP1fWzuPHc5Ux5oT7N/z9YuVl8XCCuKaC1ShRKfENFUiTK7IfShjw/IerlvfMa9C +pGorWIcomy1GeCkCaZyTxFvMagdqf25h6XwtA5iCKjZbc8HDt7e1E8Gp5Xa6jUqmHAU aZOkUNVWSkHEaQ6vZm3TF5B2aeL/NqxpWS7A0J0GaOcV2Cxp10g6cUVKEKtbZ1m7Mn2h PuIGPm+Vh7Y2FRQsqgEf/eZ2+UaXe+RwrgitaOXNo5w53bcdn9qER+BksKaZ3HkH+olR yDJg== X-Gm-Message-State: AC+VfDz8vgkR81bR7M99ZN7hszFQeWAlaNVZCoVxQULWX7hVLs/9gpXL SOkbEk1n+WO1pczCoO3BiRyyRA== X-Google-Smtp-Source: ACHHUZ6x6UvTHK1Uwv8WFmoIDk5oLTRQJtGFN81A04pmMS/WLo2rYeSvtpIwG+erMPl2na+euS5YjQ== X-Received: by 2002:a05:6a00:1407:b0:643:59e7:e601 with SMTP id l7-20020a056a00140700b0064359e7e601mr4271042pfu.26.1683238489665; Thu, 04 May 2023 15:14:49 -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.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:14:49 -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 02/17] watchdog: remove WATCHDOG_DEFAULT Date: Thu, 4 May 2023 15:13:34 -0700 Message-ID: <20230504151100.v4.2.I6a729209a1320e0ad212176e250ff945b8f91b2a@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_151451_421129_72F9A8DE X-CRM114-Status: GOOD ( 13.33 ) 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 From: Lecopzer Chen No reference to WATCHDOG_DEFAULT, remove it. Signed-off-by: Pingfan Liu Signed-off-by: Lecopzer Chen Reviewed-by: Petr Mladek Signed-off-by: Douglas Anderson --- I yanked this patch from the mailing lists [1] into my series just to make it easier to avoid conflicts between my series and the one adding the arm64 perf hardlockup detector, in case someone wanted to test them both together. This is a nice cleanup and could land together with the rest of my series if that makes sense. I changed the patch prefix to match others in my series. [1] https://lore.kernel.org/r/20220903093415.15850-2-lecopzer.chen@mediatek.com/ Changes in v4: - Pulled ("remove WATCHDOG_DEFAULT") into my series for v4. kernel/watchdog.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 8e61f21e7e33..582d572e1379 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -30,10 +30,8 @@ static DEFINE_MUTEX(watchdog_mutex); #if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HAVE_NMI_WATCHDOG) -# define WATCHDOG_DEFAULT (SOFT_WATCHDOG_ENABLED | NMI_WATCHDOG_ENABLED) # define NMI_WATCHDOG_DEFAULT 1 #else -# define WATCHDOG_DEFAULT (SOFT_WATCHDOG_ENABLED) # define NMI_WATCHDOG_DEFAULT 0 #endif From patchwork Thu May 4 22:13:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231877 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 73BC6C77B7C for ; Thu, 4 May 2023 22:16:04 +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=h88kVFjIfEDpYbKFJD8vkzDj90Dqyhgxzy4CGkLHrxo=; b=LVN/GI2KmxQMl9 nOD6O0R8oqtOMBCKPk6c7bDYUGFNLLj/kO7sB65lq+fbaB8QymoGv/7DiJ2v16q21TZs/Z/n+Jlsy oFVU/p0Oxja/Ci2+54GvUPJbx2YpgUDJGf+eP9mdW0z/17nLf6cSTqcsIB2pFbKzzhVRvwe8iIbCE tDg6+PCGGBA8RiZ8f/Cz7KtXUNi7rO5NYd3u/3JqCOXZywdiQlNNSr8C5JBkszqBdBIkAsCFeErk1 zMBYXgYrnyKY9RkYTQQSVqGDTS1cXp/0N2rEBI2lskNN9NJThQIGpJQs8Hfe6s8YJYTnqb13NWQaI rwckvspjFZZnuCNX9eMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhE1-009ARO-07; Thu, 04 May 2023 22:14:57 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhDx-009AN3-0u for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:14:54 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-64115e652eeso15800998b3a.0 for ; Thu, 04 May 2023 15:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238493; x=1685830493; 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=NL7rcG23aHBhCRTTom4GjRgUhxRdjX/HP/vRPjWaRBQ=; b=GMO8fHlXFEYbtSQE0y1Erh7XhWpTlqkqF7KQR1EGn+as2bRV3dzRZBejPggC7pbY8d gGlq9pRDRxEYYwflA4EVjHJo1YwpoHAkB3aN2beGdQA5dOWaq8NCXJc6b4Ma61gwucUS e/v0a9nk8XLhTTiXE2aSXX2NUgdq8L3kt0Cug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238493; x=1685830493; 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=NL7rcG23aHBhCRTTom4GjRgUhxRdjX/HP/vRPjWaRBQ=; b=XyA+A2y/B2kk2NMWY1dRasjHNofhjbLEv8Y9afUGH9EO0PwjtziFLvrvb8qGs0b3za IBIG7V/mIcu/6pC0BvVekIZGkE6YUEdGXs6SQK6RQyaygnooz3iwv80hdvjO3HP5KThp ICBZxEiIWkStXIgZJIeo+as3zBpqN6OTH7E8wuT8J+I9m3o410Ze469qyHUIFFsZU7sh 56DJkhhNtHrNtGXLo4VbjgKAUS4BxMnvYtvUAbX/mkBJz8rPHin66U/rjfo1EN6TshSi AG0gpCRuvDKTti/5va6ESnRUG16R2+4f7YyKKdVotZ3UHHKi/zD2s5/+P8nknPYTrmQt sklA== X-Gm-Message-State: AC+VfDwMM/GmKkQVWFavWGl6T8sUyAFn2owpm+aA1Qt8GzvAs/I/HJv0 /tIL4HQCZKmkfbDIyTPR60QxKA== X-Google-Smtp-Source: ACHHUZ7JqPCyDc8z92+xaK9Du/p6+uKUnOSt9ZL4DNxSc+m9cji2D1Wnpxf06eAMKSyQkGrQReI7sw== X-Received: by 2002:a05:6a00:4186:b0:62d:bf69:e9e0 with SMTP id ca6-20020a056a00418600b0062dbf69e9e0mr3561933pfb.17.1683238492905; Thu, 04 May 2023 15:14:52 -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.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:14:52 -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 03/17] watchdog/hardlockup: change watchdog_nmi_enable() to void Date: Thu, 4 May 2023 15:13:35 -0700 Message-ID: <20230504151100.v4.3.Ic3a19b592eb1ac4c6f6eade44ffd943e8637b6e5@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_151453_318165_E2A5606D X-CRM114-Status: GOOD ( 17.63 ) 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 From: Lecopzer Chen Nobody cares about the return value of watchdog_nmi_enable(), changing its prototype to void. Signed-off-by: Pingfan Liu Signed-off-by: Lecopzer Chen Reviewed-by: Petr Mladek Signed-off-by: Douglas Anderson Acked-by: Nicholas Piggin --- I yanked this patch from the mailing lists [1] into my series just to make it easier to avoid conflicts between my series and the one adding the arm64 perf hardlockup detector, in case someone wanted to test them both together. This is a nice cleanup and could land together with the rest of my series if that makes sense. I changed the patch prefix to match others in my series. [1] https://lore.kernel.org/r/20220903093415.15850-3-lecopzer.chen@mediatek.com/ Changes in v4: - Pulled ("change watchdog_nmi_enable() to void") into my series for v4. arch/sparc/kernel/nmi.c | 8 +++----- include/linux/nmi.h | 2 +- kernel/watchdog.c | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c index 060fff95a305..5dcf31f7e81f 100644 --- a/arch/sparc/kernel/nmi.c +++ b/arch/sparc/kernel/nmi.c @@ -282,11 +282,11 @@ __setup("nmi_watchdog=", setup_nmi_watchdog); * sparc specific NMI watchdog enable function. * Enables watchdog if it is not enabled already. */ -int watchdog_nmi_enable(unsigned int cpu) +void watchdog_nmi_enable(unsigned int cpu) { if (atomic_read(&nmi_active) == -1) { pr_warn("NMI watchdog cannot be enabled or disabled\n"); - return -1; + return; } /* @@ -295,11 +295,9 @@ int watchdog_nmi_enable(unsigned int cpu) * process first. */ if (!nmi_init_done) - return 0; + return; smp_call_function_single(cpu, start_nmi_watchdog, NULL, 1); - - return 0; } /* * sparc specific NMI watchdog disable function. diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 771d77b62bc1..454fe99c4874 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -119,7 +119,7 @@ static inline int hardlockup_detector_perf_init(void) { return 0; } void watchdog_nmi_stop(void); void watchdog_nmi_start(void); int watchdog_nmi_probe(void); -int watchdog_nmi_enable(unsigned int cpu); +void watchdog_nmi_enable(unsigned int cpu); void watchdog_nmi_disable(unsigned int cpu); void lockup_detector_reconfigure(void); diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 582d572e1379..c705a18b26bf 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -93,10 +93,9 @@ __setup("nmi_watchdog=", hardlockup_panic_setup); * softlockup watchdog start and stop. The arch must select the * SOFTLOCKUP_DETECTOR Kconfig. */ -int __weak watchdog_nmi_enable(unsigned int cpu) +void __weak watchdog_nmi_enable(unsigned int cpu) { hardlockup_detector_perf_enable(); - return 0; } void __weak watchdog_nmi_disable(unsigned int cpu) From patchwork Thu May 4 22:13:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231885 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 B45F9C7EE21 for ; Thu, 4 May 2023 22:41:02 +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=Wou4h4AbE3IASRdZqXvPr1QalU77ydFXqV1U2QtP0SQ=; b=qPMHtdUj1UyoHZ 9BC8rfk7p5VRuNvc/dpe1DiafLSBd1MKogbBs5L1xF+2dCvWep9KE8zeSCer3/DFpByyafisLgj5a 0YGWJEyP4330Nn3fyhwQr29i1Issc4h1T4jzDsJ+dgsYoHhVmlNhM5yPbblPxXjCtwQipcXZs7+h3 N3nBkTMNdkWdQFcZmz2cCNLBOeaVI/lDtnlqlHCd4DeYFVVn1d+2v7A4jG/69j6ENwQT2Frn8hvSb 6uR5ef9i+M0AbPMan+OmvVMQ2xyalcp9xBG0DWSM0vMrJJgUbMSt6+RE6l/bauAYavL1aPQfsy6ek NN4A6VlobwrLFUYNhzkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhcS-009EEz-2B; Thu, 04 May 2023 22:40:12 +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 1puhcR-009EEU-04 for linux-arm-kernel@bombadil.infradead.org; Thu, 04 May 2023 22:40:11 +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=+7chyR54aRty46RzcCdMbqi2QxR3fWS0cburZo/9gxI=; b=oFFen1iX5yTT/nxfBhaYKMPyZP gqfWUjl/0YagLey66x5jMN7Fe79CvJJuXr3Xmg7AHoIxYcmTW/CCXhNUDoomak2tX+P8k5vn9u2r9 O4PIDzUJwEoUPgjyI7snT7U4tQBITqlAq8ijJliqyLRKJPYdV+ExuIcSrBHaEmmVSWG3OX7unNn07 isYXj+JAGzPnkc6KtWIf+NJKypbKeLMiG8E5VcCW4u1rXpKhGWMQn+pN1dFku4dU+NxFisnvYLoNW Q+zUypNpG2+0uZtBE2EWHXxxpZqmx1mJed3kYkopSongjJk4IpJOx1+Fv5GHlZnW70gARTjfcqRJQ VPl6wVOg==; Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhE6-001sqc-1j for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:08 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-63b5465fc13so895806b3a.3 for ; Thu, 04 May 2023 15:14:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238496; x=1685830496; 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=+7chyR54aRty46RzcCdMbqi2QxR3fWS0cburZo/9gxI=; b=NQpIfbqEUQKnsAkyEYKExasyztEP9wJ8o+4IEiw9BxrvOoB0l00+ORgkpCBLFkfl+F PivQOONxkj4PAVC2WcZaYn5EMh53GyKpOpu34BApx4vjHnolGOvX4v2oyvAKoW8Y73KU w1j4yU/Hk37qgrXBksSm+ZQ5W6g5IzmgjL538= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238496; x=1685830496; 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=+7chyR54aRty46RzcCdMbqi2QxR3fWS0cburZo/9gxI=; b=Cr1FWdsAEsJuQVsx8qcDGjSDqVn3vDq64MJWV8zgy5hqKCmEw2dbbdoTM/D583kYAF ePVHPJIxaLjZpZB8SXITmtUFzXQLvObvGN1GDleIAkz8l+IltFRpvAibFTR8W7tLSolq FsAUsYvyBKCmpLWBeO1QNP/BNAd08hb7CV+JgoS/a2FkfsO7aw5xlMXKn+2kQbtZTRJm XHEq9W5LUwuO2HQTj8oEYEiFtnv0ufYwtEee5BQvhJIH5Gqj2xyHs18sgCPuXnOBc3Il Fu31JVhHsF6B7b1GMPht+q81aKKbkTx205wodCACOjjjlYQMFiYjKMAB5cq21c9O+vKr l7Mw== X-Gm-Message-State: AC+VfDzaHYmcW/LR9RJBP7jGIIDUBlkLojd9tMq+S0BnZUMY4UPz8Gr+ v1TLIHfCZ3PYTGIYyRfeT/t0Bw== X-Google-Smtp-Source: ACHHUZ6RrkuuKPBgTlGYVBYmU7JHppwAnr7B5nmjdOCKHM4QBI81WKafubaC+FF4dnrAufHF9KP6jQ== X-Received: by 2002:a05:6a00:2e06:b0:62d:8376:3712 with SMTP id fc6-20020a056a002e0600b0062d83763712mr4427628pfb.28.1683238496089; Thu, 04 May 2023 15:14:56 -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.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:14:55 -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 04/17] watchdog/perf: Ensure CPU-bound context when creating hardlockup detector event Date: Thu, 4 May 2023 15:13:36 -0700 Message-ID: <20230504151100.v4.4.I654063e53782b11d53e736a8ad4897ffd207406a@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_231503_397745_D870300A X-CRM114-Status: GOOD ( 18.17 ) 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 From: Pingfan Liu hardlockup_detector_event_create() should create perf_event on the current CPU. Preemption could not get disabled because perf_event_create_kernel_counter() allocates memory. Instead, the CPU locality is achieved by processing the code in a per-CPU bound kthread. Add a check to prevent mistakes when calling the code in another code path. Signed-off-by: Pingfan Liu Co-developed-by: Lecopzer Chen Signed-off-by: Lecopzer Chen Reviewed-by: Petr Mladek Signed-off-by: Douglas Anderson --- I yanked this patch from the mailing lists [1] into my series just to make it easier to avoid conflicts between my series and the one adding the arm64 perf hardlockup detector, in case someone wanted to test them both together. This is a nice cleanup and could land together with the rest of my series if that makes sense. I changed the patch prefix to match others in my series. [1] https://lore.kernel.org/r/20220903093415.15850-4-lecopzer.chen@mediatek.com/ Changes in v4: - Pulled ("Ensure CPU-bound context when creating ...") into my series for v4. kernel/watchdog_hld.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 247bf0b1582c..96b717205952 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -165,10 +165,16 @@ static void watchdog_overflow_callback(struct perf_event *event, static int hardlockup_detector_event_create(void) { - unsigned int cpu = smp_processor_id(); + unsigned int cpu; struct perf_event_attr *wd_attr; struct perf_event *evt; + /* + * Preemption is not disabled because memory will be allocated. + * Ensure CPU-locality by calling this in per-CPU kthread. + */ + WARN_ON(!is_percpu_thread()); + cpu = raw_smp_processor_id(); wd_attr = &wd_hw_attr; wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh); From patchwork Thu May 4 22:13:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231880 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 1039FC77B7C for ; Thu, 4 May 2023 22:16:14 +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=Hd44OiQoQI8Rexs/DTwCnaVfkjoeFn9EEcbPt749Dpc=; b=mdvwjCPBlBo2c2 lH8K7kisIMbrs1NDdHstRNsvFzECLGoufwwrEfYDMn0Ilcqe8qQoG57fmJDZPN0S7DMledC4NmYdp g1o4HFzSqJobwMj3Erdsgim4sMuYNMnF2FE7Hkjvcz5WzRat05Ewre4B/QjGDahDbcec0J0Vu7+6s G5Ft82eTd6N+NZq1GobQ7/58SqRIGikknvCJjy/1kQ4I+WqnUk9YJFX6KFVhwKmeo3p24XAf0tvRK abX0/pxOLofmwu0L7aonyN8/G5tG+Kk2edo2kSOJj9qK0EFeXN+2UcaW4eOFCEeUFxy/oGLg350G9 NzQTLko7puOJwo60siQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhE7-009AUf-2x; Thu, 04 May 2023 22:15:03 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhE5-009ASO-0N for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:02 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-64115eef620so15684570b3a.1 for ; Thu, 04 May 2023 15:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238499; x=1685830499; 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=aOpu4K0AbTK/Q+LJp4KPhDC1e5615vKmnF8Avzjqp1E=; b=AtjVbUDuDhuC3T5VTZajscYw/VEjMbUiZ2X5khp5ctkS+27M1j/InYQ5Dwvm/plnmd krdbBv8nVdEof2X0yL/YrwWPzFZVjFX99rqofGl1oH4jqhbFnFmnoLtQFzOtxTTSUQ8z KlY7Tr7uge6pyOt+bCScYMrb0Elk2S6F8xzAw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238499; x=1685830499; 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=aOpu4K0AbTK/Q+LJp4KPhDC1e5615vKmnF8Avzjqp1E=; b=BFLGIJne+C2EXqt1VQ+d2Vc+Vg+b4em67QheWcRVDEIf5sWM7xTn3UpmKI5FFnUtvn 8heWw0rd7lbaM4yQo6NK3l+VhNJlMKOkIgVpeDodhixFJMsOtwekDWboN7he/Xdb/bjB 4UjFmTs5HE3dxeexAm2eFFdvTQDob2VDF13mENq2yIeuIp6EyM5AVwplWDE15g9vePS0 wGyZs+cZNURpxfgYURv67SmYsLohPLV9VKogo7+OQDjeXpjKDlk6VzvotEq2MxEiew9b Chvr/eNDi6SFcd9+mJDTiwOmsUkG1bcd/52gGHmgf7i7FC7Twyjr83fNa5/tWJYHqb0Q HqGQ== X-Gm-Message-State: AC+VfDwGHXsEdwxEqJn7I1rhIvqRqgpzWnSOyqYFHNAH4VFzB/E5iDGc CuNVX0xS8uAUq5LY0jJ5GvxETg== X-Google-Smtp-Source: ACHHUZ6/nKe5trCUHnOhrXovtrUyQ0CQn+r16BvPpklIKc+6VPGovlM2nNhX9qvrY/8nVCSqNXN/Lw== X-Received: by 2002:a05:6a00:8086:b0:634:c34f:e214 with SMTP id eh6-20020a056a00808600b00634c34fe214mr3971422pfb.10.1683238499411; Thu, 04 May 2023 15:14:59 -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.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:14:58 -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 05/17] watchdog/hardlockup: Rename touch_nmi_watchdog() to touch_hardlockup_watchdog() Date: Thu, 4 May 2023 15:13:37 -0700 Message-ID: <20230504151100.v4.5.I4e47cbfa1bb2ebbcdb5ca16817aa2887f15dc82c@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_151501_164965_0F445DF2 X-CRM114-Status: GOOD ( 20.15 ) 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 In preparation for the buddy hardlockup detector, rename touch_nmi_watchdog() to touch_hardlockup_watchdog() to make it clear that it will touch whatever hardlockup detector is configured. We'll add a #define for the old name (touch_nmi_watchdog) so that we don't have to touch every piece of code referring to the old name. Ideally this change would also rename the arch_touch_nmi_watchdog(), but that is harder since arch_touch_nmi_watchdog() is exported with EXPORT_SYMBOL() and thus is ABI. Add a comment next to the call to hopefully alleviate some of the confusion here. Signed-off-by: Douglas Anderson --- Changes in v4: - ("Rename touch_nmi_watchdog() to ...") new for v4. include/linux/nmi.h | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 454fe99c4874..35d09d70f394 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -125,18 +125,35 @@ void watchdog_nmi_disable(unsigned int cpu); void lockup_detector_reconfigure(void); /** - * touch_nmi_watchdog - restart NMI watchdog timeout. + * touch_hardlockup_watchdog - manually pet the hardlockup watchdog. * - * If the architecture supports the NMI watchdog, touch_nmi_watchdog() - * may be used to reset the timeout - for code which intentionally - * disables interrupts for a long time. This call is stateless. + * If we support detecting hardlockups, touch_hardlockup_watchdog() may be + * used to pet the watchdog (reset the timeout) - for code which + * intentionally disables interrupts for a long time. This call is stateless. */ -static inline void touch_nmi_watchdog(void) +static inline void touch_hardlockup_watchdog(void) { + /* + * Pass on to the hardlockup detector selected via CONFIG_. Note that + * the hardlockup detector may not be arch-specific nor using NMIs, + * but arch_touch_nmi_watchdog() is exported with EXPORT_SYMBOL() and + * is thus ABI. + */ arch_touch_nmi_watchdog(); + + /* + * Touching the hardlock detector implcitily pets the + * softlockup detector too + */ touch_softlockup_watchdog(); } +/* + * It's encouraged for code to refer to the new name, but allow the old + * name as well. + */ +#define touch_nmi_watchdog touch_hardlockup_watchdog + /* * Create trigger_all_cpu_backtrace() out of the arch-provided * base function. Return whether such support was available, From patchwork Thu May 4 22:13:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231881 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 0B2F8C77B73 for ; Thu, 4 May 2023 22:16:17 +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=j1G4DSX30bkFnROfFleH5rBvuqzel5WfeObkFBFSRSI=; b=UtN06dksjeZ8iL CMr2vj8QJr6CDqdWDYGfh6c97821vC/s+15P2/PHjTcRmHTjFHmE1XkEn06SNCB1ywBXsWucxmgOS eytek9G/ceQnMqr7STwGPK3ojNYshsRrlAK/lUs5TiXm8nsr7y7/VXrAQE116EdDw/1pi+KNygTCP 7w8t5NviBRq6SWj14bjxiVmEJVs4UcAmhpsDrX6St6h+pIPD1tJ+Bv6jpquKgI4ATYU2087/65Z2x 6sfWWszUoJgWviH20fIXo09RBb5iluCkQGxQdZPN5J96TpEKY+MHjtbt1P7Ubc4Q7wSDzHCaPVS+F DdKJYDeOdx8tUvYje7Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhEA-009AVi-0E; Thu, 04 May 2023 22:15:06 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhE7-009ATr-01 for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:04 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6434e263962so899290b3a.2 for ; Thu, 04 May 2023 15:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238502; x=1685830502; 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=RmIxJPekTd3YSHhbOlyX0tABIcXrA8wUlcyJjL8J4yQ=; b=XghDg2TCZRLfsm0pg3t2dOS6WXD92qSyP75Giq2LPAc1TQRJUwjVc8WoFsZ9i61+Ls 9jn+XNY0ZrUzTAUtZQy4my/7m5YjKtfMgdMdyny/AVYcTRzUKLJ/imSY9n4niC8CurRW pYuxkyCnGQpDj6HG+89zoS5hVZV9cKllwuSmI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238502; x=1685830502; 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=RmIxJPekTd3YSHhbOlyX0tABIcXrA8wUlcyJjL8J4yQ=; b=a8VVK3cDPlsIwkJcr+PHCVUrWolRmgrDSHwgwn7SkuaO65GVOqqJbeciHzJaOVMiPL wIhODO0hrBPo8XfsMMJ1kx0YK3MevV/m37sRoPi1PXHdi5+FW6aNFDdcGDngIEq1Td8P 2ilMX3Q7MynCq1bNiLMqhrXJzT7ZANuKhTTRnTWVlXBg2PCFSoaMhlad5bOCacJwi0Ep x5w3xlBbqJNKX5RDXFabZUoLu+0HDJ0SQG2gsrKf2nOje7pzrFj+Ifm4HFC7TDf9vd0x umimfJeXkgs5XSrX/x7vW/t+LQq8x9GRz0eg/sXMgZCmoSywC3f+sEUlF87SBqYgJ8W9 v8Zg== X-Gm-Message-State: AC+VfDzygZ/JLnnqYKIMeBaBmGz1nJQ3JXuJ9Df0YAPjWMnPGja92ckj A9m5yekd5L3SM3SgLVmObsOhwA== X-Google-Smtp-Source: ACHHUZ4OEU35K3+sSCEyiMl0QxsV/WrmtTjX4ONPjO2qeVS0NTr5bhnPpyCKmHdt3oXalTjYAknA7Q== X-Received: by 2002:a05:6a00:1881:b0:63b:8afe:a4dc with SMTP id x1-20020a056a00188100b0063b8afea4dcmr5365992pfh.30.1683238502557; Thu, 04 May 2023 15:15:02 -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.14.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:01 -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 06/17] watchdog/perf: Rename watchdog_hld.c to watchdog_perf.c Date: Thu, 4 May 2023 15:13:38 -0700 Message-ID: <20230504151100.v4.6.Ice803cb078d0e15fb2cbf49132f096ee2bd4199d@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_151503_058447_2DC55669 X-CRM114-Status: GOOD ( 16.74 ) 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 The code currently in "watchdog_hld.c" is for detecting hardlockups using perf, as evidenced by the line in the Makefile that only compiles this file if CONFIG_HARDLOCKUP_DETECTOR_PERF is defined. Rename the file to prepare for the buddy hardlockup detector, which doesn't use perf. It could be argued that the new name makes it less obvious that this is a hardlockup detector. While true, it's not hard to remember that the "perf" detector is always a hardlockup detector and it's nice not to have names that are too convoluted. Signed-off-by: Douglas Anderson Acked-by: Nicholas Piggin --- Changes in v4: - ("Rename watchdog_hld.c to watchdog_perf.c") new for v4. kernel/Makefile | 2 +- kernel/{watchdog_hld.c => watchdog_perf.c} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename kernel/{watchdog_hld.c => watchdog_perf.c} (99%) diff --git a/kernel/Makefile b/kernel/Makefile index 10ef068f598d..406ccccc4dd3 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -91,7 +91,7 @@ obj-$(CONFIG_FAIL_FUNCTION) += fail_function.o obj-$(CONFIG_KGDB) += debug/ obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o -obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o +obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_perf.o obj-$(CONFIG_SECCOMP) += seccomp.o obj-$(CONFIG_RELAY) += relay.o obj-$(CONFIG_SYSCTL) += utsname_sysctl.o diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_perf.c similarity index 99% rename from kernel/watchdog_hld.c rename to kernel/watchdog_perf.c index 96b717205952..c3d8ceb149da 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_perf.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Detect hard lockups on a system + * Detect hard lockups on a system using perf * * started by Don Zickus, Copyright (C) 2010 Red Hat, Inc. * From patchwork Thu May 4 22:13: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: 13231896 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 662B1C77B73 for ; Thu, 4 May 2023 23:16:28 +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=7G6SBgSBdLzVaYlUgUPkGmXAbU0kQ3B2mVU0IinnPCc=; b=fhNHd9iyJfg78z y8i5UXaB2eyp0KVtB/e5NF+ISD+jrjgRl1i9XNeuqnPAFB5OSoQdiug01zjLsv1dUHI74VZZB1CLD itVucmUoKunPOKHbshk4udG7JUqYSJMWYWLfsIxOyqBze1i72B32CAvYTLy+Rh0IE49gmbIrTlFUd Jhrz6VCvf1U1RsRcCGRFjZlDTBdsrts2SpSIicZTFothHB6J+f8qti9OTpuevHpmNIUCAugpRtaA8 /EIvPgB5GOH/fw9S+7bp6rTpCErWcyTuGpzzTbjlFxbg5jT+e2VrjDxBrf0iCv1cRF+Zt74CdRAS2 feG4QCC6Or3HozPPNtmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puiAu-009JPJ-2z; Thu, 04 May 2023 23:15:48 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEA-009ASO-0M for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:08 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-64115eef620so15685148b3a.1 for ; Thu, 04 May 2023 15:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238506; x=1685830506; 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=xpsfA6UKB47krdPEGD/PrzVbXvpRWznF4QQZA2MqbCU=; b=Z0Cg9qHletOFAvqqVmZw7+26EFSWZpwbZiJS2V2FzLapfu8jT4QeFu5W5+Xv1jW0Oq GuoA3ZwWRVBan5ARtRKt+4DdoQDQBVFcxWi+ugzNZIgxtDb+wtJKzKidIFwdlM1tvBKd TTJJddtrSqAKaOI+ubOmwuYJysH9mu4yCN9nw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238506; x=1685830506; 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=xpsfA6UKB47krdPEGD/PrzVbXvpRWznF4QQZA2MqbCU=; b=Gu+GGILLYq5thxB3+yYnaNc1fkP5B8lGf+HZAguCFGJnUX7Mv5+yTESjBKKQeOdsN8 LtRg+APAkz1dK+WBxgBZirKVcIC2BMlJyt9H9Av/C6dwUEzlDfuVRfUY8N46sQY1LljY r9Fm76ybrSCsKG75HlIVFeQCwW8TC9UK5GZ63Mw1o2Ir2SP885Eg0A84VLiGdhgPwZch oPava1y3YzlUTg9ffzomG0RQ6ILQ0TbKHN2+A9pmvZQglNsHiUoqWcJjYa3/RGR+/XdG iYxJ37TKAQKASstDDD2nXQP8CIorjESsT8M614wB547jtDyK5tBB2lb58LlYJHbfytCx /HTA== X-Gm-Message-State: AC+VfDxZ4yyXENktSo7niNpTc4DzGwoMFQyHlqRac/SCUez28wFNEQnW h6XZkDz1qeYRRkByZnohqCBsSA== X-Google-Smtp-Source: ACHHUZ64Z5QeW0ZZuBfj8VjVBHEXIEO7+gyHgZ2DgxLg3p6tdlwuBFv++p3xyyGQU6N9iOTo3WaeRQ== X-Received: by 2002:a05:6a20:938b:b0:f2:2185:8575 with SMTP id x11-20020a056a20938b00b000f221858575mr3718625pzh.23.1683238505737; Thu, 04 May 2023 15:15:05 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:04 -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 07/17] watchdog/hardlockup: Move perf hardlockup checking/panic to common watchdog.c Date: Thu, 4 May 2023 15:13:39 -0700 Message-ID: <20230504151100.v4.7.Id4133d3183e798122dc3b6205e7852601f289071@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_151506_159960_3DD410DD X-CRM114-Status: GOOD ( 33.86 ) 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 The perf hardlockup detector works by looking at interrupt counts and seeing if they change from run to run. The interrupt counts are managed by the common watchdog code via its watchdog_timer_fn(). Currently the API between the perf detector and the common code is a function: is_hardlockup(). When the hard lockup detector sees that function return true then it handles printing out debug info and inducing a panic if necessary. Let's change the API a little bit in preparation for the buddy hardlockup detector. The buddy hardlockup detector wants to print nearly the same debug info and have nearly the same panic behavior. That means we want to move all that code to the common file. For now, the code in the common file will only be there if the perf hardlockup detector is enabled, but eventually it will be selected by a common config. Right now, this _just_ moves the code from the perf detector file to the common file and changes the names. It doesn't make the changes that the buddy hardlockup detector will need and doesn't do any style cleanups. A future patch will do cleanup to make it more obvious what changed. With the above, we no longer have any callers of is_hardlockup() outside of the "watchdog.c" file, so we can remove it from the header, make it static, move it to the same "#ifdef" block as our new watchdog_hardlockup_check(), and rename it to make it obvious it's just for hardlockup detectors. While doing this, it can be noted that even if no hardlockup detectors were configured the existing code used to still have the code for counting/checking "hrtimer_interrupts" even if the perf hardlockup detector wasn't configured. We didn't need to do that, so move all the "hrtimer_interrupts" counting to only be there if the perf hardlockup detector is configured as well. This change is expected to be a no-op. Signed-off-by: Douglas Anderson --- Changes in v4: - ("Move perf hardlockup checking/panic ...") new for v4. include/linux/nmi.h | 5 ++- kernel/watchdog.c | 92 +++++++++++++++++++++++++++++++++--------- kernel/watchdog_perf.c | 42 +------------------ 3 files changed, 78 insertions(+), 61 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 35d09d70f394..c6cb9bc5dc80 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -15,7 +15,6 @@ void lockup_detector_init(void); void lockup_detector_soft_poweroff(void); void lockup_detector_cleanup(void); -bool is_hardlockup(void); extern int watchdog_user_enabled; extern int nmi_watchdog_user_enabled; @@ -88,6 +87,10 @@ extern unsigned int hardlockup_panic; static inline void hardlockup_detector_disable(void) {} #endif +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) +void watchdog_hardlockup_check(struct pt_regs *regs); +#endif + #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) # define NMI_WATCHDOG_SYSCTL_PERM 0644 #else diff --git a/kernel/watchdog.c b/kernel/watchdog.c index c705a18b26bf..2d319cdf64b9 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -85,6 +85,78 @@ __setup("nmi_watchdog=", hardlockup_panic_setup); #endif /* CONFIG_HARDLOCKUP_DETECTOR */ +#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) + +static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts); +static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved); +static DEFINE_PER_CPU(bool, hard_watchdog_warn); +static unsigned long hardlockup_allcpu_dumped; + +static bool watchdog_hardlockup_is_lockedup(void) +{ + unsigned long hrint = __this_cpu_read(hrtimer_interrupts); + + if (__this_cpu_read(hrtimer_interrupts_saved) == hrint) + return true; + + __this_cpu_write(hrtimer_interrupts_saved, hrint); + return false; +} + +static void watchdog_hardlockup_interrupt_count(void) +{ + __this_cpu_inc(hrtimer_interrupts); +} + +void watchdog_hardlockup_check(struct pt_regs *regs) +{ + /* check for a hardlockup + * This is done by making sure our timer interrupt + * is incrementing. The timer interrupt should have + * fired multiple times before we overflow'd. If it hasn't + * then this is a good indication the cpu is stuck + */ + if (watchdog_hardlockup_is_lockedup()) { + int this_cpu = smp_processor_id(); + + /* only print hardlockups once */ + if (__this_cpu_read(hard_watchdog_warn) == true) + return; + + pr_emerg("Watchdog detected hard LOCKUP on cpu %d\n", + this_cpu); + print_modules(); + print_irqtrace_events(current); + if (regs) + show_regs(regs); + else + dump_stack(); + + /* + * Perform all-CPU dump only once to avoid multiple hardlockups + * generating interleaving traces + */ + if (sysctl_hardlockup_all_cpu_backtrace && + !test_and_set_bit(0, &hardlockup_allcpu_dumped)) + trigger_allbutself_cpu_backtrace(); + + if (hardlockup_panic) + nmi_panic(regs, "Hard LOCKUP"); + + __this_cpu_write(hard_watchdog_warn, true); + return; + } + + __this_cpu_write(hard_watchdog_warn, false); + return; +} + +#else /* CONFIG_HARDLOCKUP_DETECTOR_PERF */ + +static inline void watchdog_hardlockup_interrupt_count(void) { } + +#endif /* !CONFIG_HARDLOCKUP_DETECTOR_PERF */ + /* * These functions can be overridden if an architecture implements its * own hardlockup detector. @@ -176,8 +248,6 @@ static DEFINE_PER_CPU(unsigned long, watchdog_touch_ts); static DEFINE_PER_CPU(unsigned long, watchdog_report_ts); static DEFINE_PER_CPU(struct hrtimer, watchdog_hrtimer); static DEFINE_PER_CPU(bool, softlockup_touch_sync); -static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts); -static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved); static unsigned long soft_lockup_nmi_warn; static int __init nowatchdog_setup(char *str) @@ -312,22 +382,6 @@ static int is_softlockup(unsigned long touch_ts, } /* watchdog detector functions */ -bool is_hardlockup(void) -{ - unsigned long hrint = __this_cpu_read(hrtimer_interrupts); - - if (__this_cpu_read(hrtimer_interrupts_saved) == hrint) - return true; - - __this_cpu_write(hrtimer_interrupts_saved, hrint); - return false; -} - -static void watchdog_interrupt_count(void) -{ - __this_cpu_inc(hrtimer_interrupts); -} - static DEFINE_PER_CPU(struct completion, softlockup_completion); static DEFINE_PER_CPU(struct cpu_stop_work, softlockup_stop_work); @@ -359,7 +413,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) return HRTIMER_NORESTART; /* kick the hardlockup detector */ - watchdog_interrupt_count(); + watchdog_hardlockup_interrupt_count(); /* kick the softlockup detector */ if (completion_done(this_cpu_ptr(&softlockup_completion))) { diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c index c3d8ceb149da..5f3651b87ee7 100644 --- a/kernel/watchdog_perf.c +++ b/kernel/watchdog_perf.c @@ -20,13 +20,11 @@ #include #include -static DEFINE_PER_CPU(bool, hard_watchdog_warn); static DEFINE_PER_CPU(bool, watchdog_nmi_touch); static DEFINE_PER_CPU(struct perf_event *, watchdog_ev); static DEFINE_PER_CPU(struct perf_event *, dead_event); static struct cpumask dead_events_mask; -static unsigned long hardlockup_allcpu_dumped; static atomic_t watchdog_cpus = ATOMIC_INIT(0); notrace void arch_touch_nmi_watchdog(void) @@ -122,45 +120,7 @@ static void watchdog_overflow_callback(struct perf_event *event, if (!watchdog_check_timestamp()) return; - /* check for a hardlockup - * This is done by making sure our timer interrupt - * is incrementing. The timer interrupt should have - * fired multiple times before we overflow'd. If it hasn't - * then this is a good indication the cpu is stuck - */ - if (is_hardlockup()) { - int this_cpu = smp_processor_id(); - - /* only print hardlockups once */ - if (__this_cpu_read(hard_watchdog_warn) == true) - return; - - pr_emerg("Watchdog detected hard LOCKUP on cpu %d\n", - this_cpu); - print_modules(); - print_irqtrace_events(current); - if (regs) - show_regs(regs); - else - dump_stack(); - - /* - * Perform all-CPU dump only once to avoid multiple hardlockups - * generating interleaving traces - */ - if (sysctl_hardlockup_all_cpu_backtrace && - !test_and_set_bit(0, &hardlockup_allcpu_dumped)) - trigger_allbutself_cpu_backtrace(); - - if (hardlockup_panic) - nmi_panic(regs, "Hard LOCKUP"); - - __this_cpu_write(hard_watchdog_warn, true); - return; - } - - __this_cpu_write(hard_watchdog_warn, false); - return; + watchdog_hardlockup_check(regs); } static int hardlockup_detector_event_create(void) From patchwork Thu May 4 22:13:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231890 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 927B3C77B7C for ; Thu, 4 May 2023 22:41:14 +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=Xlu8F6lMQ/KuMpG85J+yoWtkN5z3sStBqm1XFryq8H8=; b=pgSxglQcyjRJfW Cs9lllPORSO1HrlLDxS5yU5Tn8Jyt6LEs9UABHKZ3O0kUt4vSAINKLipDMWXktORrEr2AgJbRsJGM GqPcZ1pMf9RmW3a/Age5pAhYdYSObL31Qh1vc6ObA25IlZ4Xqdq79oY+mfZ3G1YOPPr+wq6NrjEgd e7KZTZ7haaQ0bElqbBVp1MbMKuOoQTzu8SvQPze5NLQLV4+B2tVYw0tKYcxYCWaJYGFYpof6zBzkW 13yz5XSxZh2vC4kLFcNh3jx9JXEW/cxA5RpjgR2RLypYhmjsvHpra028il+tkrfVrgM8Lo4HROJG4 vOhzWjDWhY9gvznYn2Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhcm-009ENe-16; Thu, 04 May 2023 22:40:32 +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 1puhck-009EMG-3D for linux-arm-kernel@bombadil.infradead.org; Thu, 04 May 2023 22:40:31 +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=OARDe2WGhGJ9YL28VnMtRA2erbfr4XRakwTJsFcap5I=; b=jJ/E4uMjXpLhtPrKrV0d6sBYNq 8FgRXiZh1V0ymaRRTmbZr1XyTJggLsE7ZDgrb/zUvXkJlZu4R0ddy+FCGfyUFytFIapSRvUMugnAf jBPeSa02FIM14+6rtf73GjGgJ/Z25VB7j4/tz9JXp01bDaD+uBnPTB8do3RUIxD9ddQ6bhE3gB+CE 2NCVjEdCfUMIvVOz2tmrJr5IfAWeZ/eSlsebumbyKCLPcYqOasweByAjbmzAxrKM/82BunKYGwbal mWIKRJ48YWVRastCuhwcpyYgjReklgAUa0Pvfk0H5kwq5bxfRHGYoX783uJFh0NXOyI99JXhnps8B 6EJYAETA==; Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEF-001srT-0l for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:14 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6438d95f447so762742b3a.3 for ; Thu, 04 May 2023 15:15:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238509; x=1685830509; 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=OARDe2WGhGJ9YL28VnMtRA2erbfr4XRakwTJsFcap5I=; b=GLyo2ZwV6SkVu4yg4BDy7JLcH5ZAP2+/Qea63V/wdOAwvbUwjlMysbyaZ2Vj0B5Ivh 0GPXL/8FkhlOU43tb+ABkKZjcnWdf+kvyUm0Z0zfqPTn+HG53phy8ghQfqsDqk1tvDdK aPeNvzoOAj5cm8jOtnggXAtEE/QJY2OQ3iXcE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238509; x=1685830509; 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=OARDe2WGhGJ9YL28VnMtRA2erbfr4XRakwTJsFcap5I=; b=fOWlZpmK7nnaWWnGQ2Evqo2ebhFO0ah2h12c6XHF4Wji4OSu3BAluV864k7ddNrl2p WdcjC57YGGAgAC80oa6EZyDmdBeumxBiZ1IpCh/cDoK2kPSUrE4B1I1H+/yyUgVkTn54 zdSnpcuOXNQBAt8grQ/WsyVMJJnZbevpVwDpVOElCxfB8o3ySBNloXlt4KP4SQPzWZmr MBNpcVYGuR1a0w/keYcjEIPhthlWpD1rG/Z/hb59OM4in7GPtFaZkNhE/lRti30QrL4Q P+WuqqjXK0YHf36IVxIsJwWcBUwXJ3iSrmY7wJTyNXTL+rFdK0p6kDy/ZnMueQBcFK3J 8FUg== X-Gm-Message-State: AC+VfDxNRI7Z80ZCt6+I+BIXoD0ozUAUPJeihgIzMQcfpkW2FR2AnZG4 OsiHvz3+QFmyznvsMrsUsEm5EQ== X-Google-Smtp-Source: ACHHUZ6K/GWZgHBRK8tXvn/IygmeZOoqhhON0G5s9GMpGhU7noise7S5Zr5rOpk3+MOxdT0Gz+Ye2Q== X-Received: by 2002:aa7:8885:0:b0:643:74a1:6dbd with SMTP id z5-20020aa78885000000b0064374a16dbdmr4174511pfe.30.1683238508951; Thu, 04 May 2023 15:15:08 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:07 -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 08/17] watchdog/hardlockup: Style changes to watchdog_hardlockup_check() / ..._is_lockedup() Date: Thu, 4 May 2023 15:13:40 -0700 Message-ID: <20230504151100.v4.8.I818492c326b632560b09f20d2608455ecf9d3650@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_231511_844059_BA16E71F X-CRM114-Status: GOOD ( 18.79 ) 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 These are tiny style changes: - Add a blank line before a "return". - Renames two globals to use the "watchdog_hld" prefix. - Store processor id in "unsigned int" rather than "int". - Minor comment rewording. - Use "else" rather than extra returns since it seemed more symmetric. Signed-off-by: Douglas Anderson --- Changes in v4: - ("Style changes to watchdog_hardlockup_check ...") new for v4. kernel/watchdog.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 2d319cdf64b9..f46669c1671d 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -89,8 +89,8 @@ __setup("nmi_watchdog=", hardlockup_panic_setup); static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts); static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved); -static DEFINE_PER_CPU(bool, hard_watchdog_warn); -static unsigned long hardlockup_allcpu_dumped; +static DEFINE_PER_CPU(bool, watchdog_hardlockup_processed); +static unsigned long watchdog_hardlockup_dumped_stacks; static bool watchdog_hardlockup_is_lockedup(void) { @@ -100,6 +100,7 @@ static bool watchdog_hardlockup_is_lockedup(void) return true; __this_cpu_write(hrtimer_interrupts_saved, hrint); + return false; } @@ -110,21 +111,20 @@ static void watchdog_hardlockup_interrupt_count(void) void watchdog_hardlockup_check(struct pt_regs *regs) { - /* check for a hardlockup - * This is done by making sure our timer interrupt - * is incrementing. The timer interrupt should have - * fired multiple times before we overflow'd. If it hasn't + /* + * Check for a hardlockup by making sure the CPU's timer + * interrupt is incrementing. The timer interrupt should have + * fired multiple times before we overflow'd. If it hasn't * then this is a good indication the cpu is stuck */ if (watchdog_hardlockup_is_lockedup()) { - int this_cpu = smp_processor_id(); + unsigned int this_cpu = smp_processor_id(); - /* only print hardlockups once */ - if (__this_cpu_read(hard_watchdog_warn) == true) + /* Only handle hardlockups once. */ + if (__this_cpu_read(watchdog_hardlockup_processed)) return; - pr_emerg("Watchdog detected hard LOCKUP on cpu %d\n", - this_cpu); + pr_emerg("Watchdog detected hard LOCKUP on cpu %d\n", this_cpu); print_modules(); print_irqtrace_events(current); if (regs) @@ -137,18 +137,16 @@ void watchdog_hardlockup_check(struct pt_regs *regs) * generating interleaving traces */ if (sysctl_hardlockup_all_cpu_backtrace && - !test_and_set_bit(0, &hardlockup_allcpu_dumped)) + !test_and_set_bit(0, &watchdog_hardlockup_dumped_stacks)) trigger_allbutself_cpu_backtrace(); if (hardlockup_panic) nmi_panic(regs, "Hard LOCKUP"); - __this_cpu_write(hard_watchdog_warn, true); - return; + __this_cpu_write(watchdog_hardlockup_processed, true); + } else { + __this_cpu_write(watchdog_hardlockup_processed, false); } - - __this_cpu_write(hard_watchdog_warn, false); - return; } #else /* CONFIG_HARDLOCKUP_DETECTOR_PERF */ From patchwork Thu May 4 22:13:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231893 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 CC239C77B7C for ; Thu, 4 May 2023 22:41:22 +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=UoWEVxtNkfaPvb5B8GoEx3ntTTAR9wz/dv34b+gtnN4=; b=ZMzojSFTGym5bI Am441mvFnc5uPfUKh4+WrEjx/Zho5QDsrNvgPDovziau3SpC13ezO0oe7l4hSXacshDH+oMEHtQxI bjtCpPDQcFYIQglhqtmRAJQJavpFljbNzeDMB+lssVzWypvwEmuNeCBPyYa96TWDK9KFKYRQ4CvCv 4hUewqQwZf597astEIr69SXx0KJAp+MpPkUZiXJJlNtinQg6tHw+qcdL4X8WfN3IoPzqvkAgXGdZE iAq88iEpnnVQfmGWymXAc7oFdLHAZnvlXYwFOkhh3XtvIhiNmLdMe9p1UxAvOX9K4irHstoLShNpW ifZ34/+nm7CGmBTq3iRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhcq-009EPk-0r; Thu, 04 May 2023 22:40:36 +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 1puhco-009EOk-1L for linux-arm-kernel@bombadil.infradead.org; Thu, 04 May 2023 22:40:34 +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=Qs9dVqDn19dbFuBLpnSq6u/1X9XncQ7793Pg3nTbXSY=; b=gju8lxbQPc4Ai7VN30r4BbT+7C tRt2ZAcpjHALvGoq8GCZaGF5GFAZB/uJrsXqCigSkYUOMrdXY38D2sWm1KH85wVy2cmL0XIgp/EK9 d3OuSvLevWVvK02rphHXr9YBKWQ/KyxWYS5adXLCLQXurfeTBalPrhvaeXWkB3LKAxKVZKosCUBY3 pk9yqWkxNoaLQCdS2UtwkVMI5Z8aweH9H1KvJ7GXIHbB4/izEnr87r8pzBryPejHsf9veiyKmZ1Wc bZ5Z9d8mGogMtmJv4Cu68GHIKPGqvqX32vaiYl4kAK/bTbqr0DVWGDlqNPP90iNTqVSy+oDsp/Jzc hfuk3mPg==; Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEI-001srn-0q for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:17 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6434e40394eso862484b3a.1 for ; Thu, 04 May 2023 15:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238512; x=1685830512; 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=Qs9dVqDn19dbFuBLpnSq6u/1X9XncQ7793Pg3nTbXSY=; b=YJROINNmnTriLPHEMGRffEEU5u5jgOZI+OjH5ib5+xogbKCty4xGU/gxTjvwZlF0Wq Y41ByV3ME3y2zIqQvZlfm5TvuytZulDOsfyDEiZk5uPDq5w5r51Z0+JrQfSi+OMn98zN vTuEboyeGfy9khGK+oRTXwvq0syqveXf6UD30= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238512; x=1685830512; 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=Qs9dVqDn19dbFuBLpnSq6u/1X9XncQ7793Pg3nTbXSY=; b=N3Ez9GVWeBpPCRmzBSX8eL5DBg/mMHc/xm2JCAb4iUt/Bh7SQUHbj4ECliO7Lp2wMt 3S/e8ZtkJAoncJNpfV6yO+16mmCAEQkAqiiIuyQXsiVUgRO4UQI+76ObpREFTHpapwTx aCJbQM+SKWZt54o5aJUKBRjeQw0fbGB6qTgkS2i8UIhCdmnBdew4B0gZOinZm6jiKSh9 eFUYpw/bi0n5xmRFAtl6Z1nlfh/CBkZeolW6RpkTIcn0XAOyUAMIb0jtT9vau4nnj2GQ WF+OGf0Q21Nmmf1IXceoOXlDxT4PoA5L7FedLagPv2s4rV7bgDg9IO2Xh0R34bckUQfM 7mGA== X-Gm-Message-State: AC+VfDxm/l3b8gMsGdk3wSztRuABPo5JlwQ1UpNOn/aQOPXvYSQ9A2iE s7mcXhQnPWmfLm0vOwnG/jUVhg== X-Google-Smtp-Source: ACHHUZ4Ssrt4fd2DGpbw/dz7xZl+zekrUKqrX4nrV4w3MwOPjKkeowMi5feC+Af+mzM8p4SVwo3IHQ== X-Received: by 2002:a05:6a00:2284:b0:643:9b40:103e with SMTP id f4-20020a056a00228400b006439b40103emr1621714pfe.30.1683238512076; Thu, 04 May 2023 15:15:12 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:11 -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 09/17] watchdog/hardlockup: Add a "cpu" param to watchdog_hardlockup_check() Date: Thu, 4 May 2023 15:13:41 -0700 Message-ID: <20230504151100.v4.9.I3a7d4dd8c23ac30ee0b607d77feb6646b64825c0@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_231514_777579_FA1403FC X-CRM114-Status: GOOD ( 22.68 ) 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 In preparation for the buddy hardlockup detector where the CPU checking for lockup might not be the currently running CPU, add a "cpu" parameter to watchdog_hardlockup_check(). Signed-off-by: Douglas Anderson --- Changes in v4: - ("Add a "cpu" param to watchdog_hardlockup_check()") new for v4. include/linux/nmi.h | 2 +- kernel/watchdog.c | 47 ++++++++++++++++++++++++++++-------------- kernel/watchdog_perf.c | 2 +- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index c6cb9bc5dc80..2c9ea1ba285c 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -88,7 +88,7 @@ static inline void hardlockup_detector_disable(void) {} #endif #if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) -void watchdog_hardlockup_check(struct pt_regs *regs); +void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs); #endif #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index f46669c1671d..367bea0167a5 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -92,14 +92,14 @@ static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved); static DEFINE_PER_CPU(bool, watchdog_hardlockup_processed); static unsigned long watchdog_hardlockup_dumped_stacks; -static bool watchdog_hardlockup_is_lockedup(void) +static bool watchdog_hardlockup_is_lockedup(unsigned int cpu) { - unsigned long hrint = __this_cpu_read(hrtimer_interrupts); + unsigned long hrint = per_cpu(hrtimer_interrupts, cpu); - if (__this_cpu_read(hrtimer_interrupts_saved) == hrint) + if (per_cpu(hrtimer_interrupts_saved, cpu) == hrint) return true; - __this_cpu_write(hrtimer_interrupts_saved, hrint); + per_cpu(hrtimer_interrupts_saved, cpu) = hrint; return false; } @@ -109,7 +109,7 @@ static void watchdog_hardlockup_interrupt_count(void) __this_cpu_inc(hrtimer_interrupts); } -void watchdog_hardlockup_check(struct pt_regs *regs) +void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs) { /* * Check for a hardlockup by making sure the CPU's timer @@ -117,35 +117,50 @@ void watchdog_hardlockup_check(struct pt_regs *regs) * fired multiple times before we overflow'd. If it hasn't * then this is a good indication the cpu is stuck */ - if (watchdog_hardlockup_is_lockedup()) { + if (watchdog_hardlockup_is_lockedup(cpu)) { unsigned int this_cpu = smp_processor_id(); + struct cpumask backtrace_mask = *cpu_online_mask; /* Only handle hardlockups once. */ - if (__this_cpu_read(watchdog_hardlockup_processed)) + if (per_cpu(watchdog_hardlockup_processed, cpu)) return; - pr_emerg("Watchdog detected hard LOCKUP on cpu %d\n", this_cpu); + pr_emerg("Watchdog detected hard LOCKUP on cpu %d\n", cpu); print_modules(); print_irqtrace_events(current); - if (regs) + if (regs) { show_regs(regs); - else - dump_stack(); + cpumask_clear_cpu(cpu, &backtrace_mask); + } else { + /* + * If the locked up CPU is different than the CPU we're + * running on then we'll try to backtrace the CPU that + * locked up and then exclude it from later backtraces. + * If that fails or if we're running on the locked up + * CPU, just do a normal backtrace. + */ + if (cpu != this_cpu && trigger_single_cpu_backtrace(cpu)) { + cpumask_clear_cpu(cpu, &backtrace_mask); + } else { + dump_stack(); + cpumask_clear_cpu(this_cpu, &backtrace_mask); + } + } /* - * Perform all-CPU dump only once to avoid multiple hardlockups - * generating interleaving traces + * Perform multi-CPU dump only once to avoid multiple + * hardlockups generating interleaving traces */ if (sysctl_hardlockup_all_cpu_backtrace && !test_and_set_bit(0, &watchdog_hardlockup_dumped_stacks)) - trigger_allbutself_cpu_backtrace(); + trigger_cpumask_backtrace(&backtrace_mask); if (hardlockup_panic) nmi_panic(regs, "Hard LOCKUP"); - __this_cpu_write(watchdog_hardlockup_processed, true); + per_cpu(watchdog_hardlockup_processed, cpu) = true; } else { - __this_cpu_write(watchdog_hardlockup_processed, false); + per_cpu(watchdog_hardlockup_processed, cpu) = false; } } diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c index 5f3651b87ee7..9be90b2a2ea7 100644 --- a/kernel/watchdog_perf.c +++ b/kernel/watchdog_perf.c @@ -120,7 +120,7 @@ static void watchdog_overflow_callback(struct perf_event *event, if (!watchdog_check_timestamp()) return; - watchdog_hardlockup_check(regs); + watchdog_hardlockup_check(smp_processor_id(), regs); } static int hardlockup_detector_event_create(void) From patchwork Thu May 4 22:13:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231887 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 A2715C7EE21 for ; Thu, 4 May 2023 22:41:06 +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=+e0CF6roh3x5V0JBcczJ9OVNEoxIJD+UY+AKSkQW/Dg=; b=nE+fpHRPbcbXtc ubg45PG16DuS7jCNExoo59C8XbUfXig8Gs5MRVUhVX7+mWTj0lRZtw/egvQLTChTEHjrAO5uZWO99 iUFC7xi4GKkY0cigJomtONeoy09ClKhJNvgsXFQF70x9C4uUuKEMhYIjU1I/IPEHdgZig11trXGtx t0ZMvRSMjbDfBgJXXhHAx7TfRuhIKZy5J1efu8/g6I+g2yFi8Iu8oJ/yfd7NDDwJ69Gxbkg96pRnU ppz4eMnSCSZttSMMw3jU2SNnOMZdHwBT/eAzkdDMGO8TzxfZLypfpkop5fW10OjPPLLbPNMqVnHRa RuN65y1O0mnUsBN25nEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhcY-009EGz-1j; Thu, 04 May 2023 22:40:18 +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 1puhcW-009EFv-1m for linux-arm-kernel@bombadil.infradead.org; Thu, 04 May 2023 22:40:16 +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=TUknF6ajnI+moT8P8i/ZCNk2tv65O4bG3/LdBCmIAIk=; b=g1fodbKT0OVQkcwOePaeujZ9y8 KiCJier7UnWt7ycPWxHXUnl2oMMbgt4Jv2sXGZb5gpGOrsfGrkrqQY1JOB05lsFdhWFR0NWwn8gGk simClDf4SUwvRGwrFv1CeBC0MIwYJSJXsHnwi7vtPfM7ginDGRZbQ3aC5m7Jo1FSIUqtuIs8ofUvK EicmyFRO3F3INy8TGiA+KdcUcu1ze36cIXHiZkIpY3zdTvuaG7/2Uj0PCh8x88IRSEXmG3sa6zpc5 kakwRWu51XYVDo5K4nNPMOktNoaDv8Ij63W6KhhMhcp6VRkFskADqY3xvMS5ePbPoWFJXiG0sIZ+N ptf3HN8Q==; Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEM-001ss9-08 for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:24 +0000 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-643912bca6fso891304b3a.0 for ; Thu, 04 May 2023 15:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238515; x=1685830515; 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=TUknF6ajnI+moT8P8i/ZCNk2tv65O4bG3/LdBCmIAIk=; b=Fdqp591+Bc0n5LUOuZ+jw9voBFFuPd7of8525iR+iiRO9Xj3fHv6nKNTGTpP5EaqDU EzdXgrpZWBW3vYibWNS6iTCW6bJ2XbAL2UppoxvxeWowhQLXgcQ4I+FoXqCP9LO8Znal rLiqN5QqWtizpZvWHG6Tqu3Wto5zDTHGStQnw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238515; x=1685830515; 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=TUknF6ajnI+moT8P8i/ZCNk2tv65O4bG3/LdBCmIAIk=; b=XU6svOEkNNPrsOdoUoHau5kvfY4DRYjEJCLJpkKVrKarsc8iHiG6Hn704sIqPGHbSw yjzF8b1ZDPYtf/UgsqWT2rMdD91RA9CPJ350QNyJjnNl7HRJ9JuRTRbY81dtfUu+snJs d6/DptpgW8I/lz//MMaNXMyYMX9a9TXwNPZxnQSCwqpr/uo3FfUGPNqfRXwP9C/lOTIr rAd+ikQT4aDGQqsMgNo6MwnRZeOeDTo24/4iKuGlkDS8VNeKdaA0cMsiVVHJZxIxxaD2 wLMGeTqB19L/KWWBcusxOnFNg0fLi/WSj6pZb3+OtbmUX/0Z0FsJIxyW5eAyfW9x3IJ4 HMNA== X-Gm-Message-State: AC+VfDyYShJhnNsoJ9Vpd5wf9m+GHUQwDfnIKZiGzyxEhyZL/pipXgSe apRx/LgOporm6DSnRz1UTdrTPw== X-Google-Smtp-Source: ACHHUZ74QoZiaoJdwRc3XVsG97oTLnm9/4CdtL0i/W46ZYWiOKXfp/f5jJlYmEEJ5QQG/1COaksDoQ== X-Received: by 2002:a05:6a00:1954:b0:63b:7ae0:fde9 with SMTP id s20-20020a056a00195400b0063b7ae0fde9mr4369313pfk.20.1683238515243; Thu, 04 May 2023 15:15:15 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:14 -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 10/17] watchdog/hardlockup: Move perf hardlockup watchdog petting to watchdog.c Date: Thu, 4 May 2023 15:13:42 -0700 Message-ID: <20230504151100.v4.10.I00dfd6386ee00da25bf26d140559a41339b53e57@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_231518_576759_D06DD1BD X-CRM114-Status: GOOD ( 21.80 ) 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 In preparation for the buddy hardlockup detector, which wants the same petting logic as the current perf hardlockup detector, move the code to watchdog.c. While doing this, rename the global variable to match others nearby. The arch_touch_nmi_watchdog() function is not renamed since that is exported with "EXPORT_SYMBOL" and is thus ABI. Currently the code in watchdog.c is guarded by CONFIG_HARDLOCKUP_DETECTOR_PERF, which makes this change seem silly. However, a future patch will change this. NOTE: there is a slight side effect to this change, though from code analysis I believe it to be a beneficial one. Specifically the perf hardlockup detector will now do check the "timestamp" before clearing any watchdog pets. Previously the order was reversed. With the old order if the watchdog perf event was firing super fast then it would also be clearing existing watchdog pets super fast. The new behavior of handling super-fast perf before clearing watchdog pets seems better. Signed-off-by: Douglas Anderson --- Changes in v4: - ("Move perf hardlockup watchdog petting to watchdog.c") new for v4. include/linux/nmi.h | 5 +++-- kernel/watchdog.c | 19 +++++++++++++++++++ kernel/watchdog_perf.c | 19 ------------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 2c9ea1ba285c..94ff84e1c8ec 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -88,7 +88,10 @@ static inline void hardlockup_detector_disable(void) {} #endif #if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) +void arch_touch_nmi_watchdog(void); void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs); +#elif !defined(CONFIG_HAVE_NMI_WATCHDOG) +static inline void arch_touch_nmi_watchdog(void) { } #endif #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR) @@ -98,7 +101,6 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs); #endif #if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) -extern void arch_touch_nmi_watchdog(void); extern void hardlockup_detector_perf_stop(void); extern void hardlockup_detector_perf_restart(void); extern void hardlockup_detector_perf_disable(void); @@ -113,7 +115,6 @@ 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; } -static inline void arch_touch_nmi_watchdog(void) {} # else static inline int hardlockup_detector_perf_init(void) { return 0; } # endif diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 367bea0167a5..9c17090611f2 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -90,8 +90,22 @@ __setup("nmi_watchdog=", hardlockup_panic_setup); static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts); static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved); static DEFINE_PER_CPU(bool, watchdog_hardlockup_processed); +static DEFINE_PER_CPU(bool, watchdog_hardlockup_touch); static unsigned long watchdog_hardlockup_dumped_stacks; +notrace void arch_touch_nmi_watchdog(void) +{ + /* + * Using __raw here because some code paths have + * preemption enabled. If preemption is enabled + * then interrupts should be enabled too, in which + * case we shouldn't have to worry about the watchdog + * going off. + */ + raw_cpu_write(watchdog_hardlockup_touch, true); +} +EXPORT_SYMBOL(arch_touch_nmi_watchdog); + static bool watchdog_hardlockup_is_lockedup(unsigned int cpu) { unsigned long hrint = per_cpu(hrtimer_interrupts, cpu); @@ -111,6 +125,11 @@ static void watchdog_hardlockup_interrupt_count(void) void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs) { + if (__this_cpu_read(watchdog_hardlockup_touch)) { + __this_cpu_write(watchdog_hardlockup_touch, false); + return; + } + /* * Check for a hardlockup by making sure the CPU's timer * interrupt is incrementing. The timer interrupt should have diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c index 9be90b2a2ea7..547917ebd5d3 100644 --- a/kernel/watchdog_perf.c +++ b/kernel/watchdog_perf.c @@ -20,26 +20,12 @@ #include #include -static DEFINE_PER_CPU(bool, watchdog_nmi_touch); static DEFINE_PER_CPU(struct perf_event *, watchdog_ev); static DEFINE_PER_CPU(struct perf_event *, dead_event); static struct cpumask dead_events_mask; static atomic_t watchdog_cpus = ATOMIC_INIT(0); -notrace void arch_touch_nmi_watchdog(void) -{ - /* - * Using __raw here because some code paths have - * preemption enabled. If preemption is enabled - * then interrupts should be enabled too, in which - * case we shouldn't have to worry about the watchdog - * going off. - */ - raw_cpu_write(watchdog_nmi_touch, true); -} -EXPORT_SYMBOL(arch_touch_nmi_watchdog); - #ifdef CONFIG_HARDLOCKUP_CHECK_TIMESTAMP static DEFINE_PER_CPU(ktime_t, last_timestamp); static DEFINE_PER_CPU(unsigned int, nmi_rearmed); @@ -112,11 +98,6 @@ static void watchdog_overflow_callback(struct perf_event *event, /* Ensure the watchdog never gets throttled */ event->hw.interrupts = 0; - if (__this_cpu_read(watchdog_nmi_touch) == true) { - __this_cpu_write(watchdog_nmi_touch, false); - return; - } - if (!watchdog_check_timestamp()) return; From patchwork Thu May 4 22:13:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231891 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 D54ADC7EE21 for ; Thu, 4 May 2023 22:41:14 +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=rMjh+d9UtEpC8RXzMxHzOoVLB1yroiKxO8BTG/kMV1w=; b=nYQFyp/4GVpe6M Q5BJ3FemY1VDjW4l0wN0/iLiWfk5/SgXXY1GcUBiTb3+FjKT83Z7oL/T9uHpNIWRsh4QhcZNDS6gz BMyP/zQ47YsoQjBjx5iUiZRIEG20//dxxAjVaMXJRtf9ggJKN4p8m1M+mcHQqCyIHH0vJU5DAeX/C WYDxMAMFlDyxVsNBqG0DnnlaF0UOVUpQ0qAoDpPIMyQxKotR5MDBNAvsR+5CP3/laZWdwbP7rkwPA iPWbIZ0SnuxWrckMFu9nUo0miLHaTCGlnIPMfqEX+k6Su2fVI5FRR7YlBr5uiNsaDehH3jnifYdtz BVp8ERPz/RKUntJMITHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhce-009EJg-3C; Thu, 04 May 2023 22:40:25 +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 1puhcb-009EI6-1j for linux-arm-kernel@bombadil.infradead.org; Thu, 04 May 2023 22:40:21 +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=R+qgr9NPJGRKeZ2d/dxWaM/f3ro5RZR07kizkKPd5wY=; b=XVyZ16hK1ecb/691hz1m2zBlGa gM3zp97wr1GmSw8tW796F+LH9/GuI7au6m8jH1XFzP6/1iDUpPZAmLgiMxGkcE8kqvs32EFr5Z+4X TDKcN8rbLLwT1QEei81fwz9cQDbC6FfyUHMiiQ8KtGbOCkDxVGbP7ogskJ1WeHgx6Sq8Qn79QVM8P ZEhMfKKZSwHyFFaVuPDqQcBUPMOu3uPshbiEJzS+k48kwlRBwDVL5egqOGlyGqINvcHmusbY+M2Qn FgOw7DH8SnACvLE4LRNtgYrudH+p+B/44bjiteHXmXDJd6ahHhUx09xyAUCMo/Qxtrm61Mzko9Pgm MUlicccQ==; Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEO-001st9-2X for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:16:46 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-643846c006fso1253812b3a.0 for ; Thu, 04 May 2023 15:15:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238518; x=1685830518; 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=R+qgr9NPJGRKeZ2d/dxWaM/f3ro5RZR07kizkKPd5wY=; b=EuICYhk97DSFRkZuW9CQpMK+vzmqJIxZBFAC3weye10VIHwkOLuKXcH4zdUO2fkh8u tGu+f6LTbBWuYZyA0HooKjohl6C2ifP5WYxBn4WOmnUNQjIM9zA1mmXi22Xy4lCawOZQ mixx3An4IDYGxL6auK7sNaZOmwAzxobXmXc3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238518; x=1685830518; 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=R+qgr9NPJGRKeZ2d/dxWaM/f3ro5RZR07kizkKPd5wY=; b=RI/S69PlBcpunYVIhdyBXiA2UqrVUEBYLwfBFn1NF2AfkDYu7a6xJHPD5UET3DqC+A WrcSs/jBEUFRDwBQol7hKSxI9X7vtH42E7f6ymq7wn/xfK/XIk9n1sWUarOr/lxTXOQv A88NcD4aiGEhMs+b32UuIXTTb4dw5ElJyJ9lZrJhj/l19NtrztG0S7ZUfmua0DHNMUYV xrdJLgrMLLiKWvwXhAZLdLEPZrzHZQB+IWZwVnWeorV9oJ9pHM6K0Lk0tAm+0tOijkdl 9CJPkFDWTYS2gMFzVxuOhVbd4WxXDiRbgPb4J8UK42A3Y+8Tig0tJ64zVBN9+u2d0ebu hoEA== X-Gm-Message-State: AC+VfDywfb5dh4ceeJ5txgClGPzQK9NMfFKS0ge+idMDunrL2zbAK9qo 4qdEqDqQ0VwH7lBs0RQD+FN5AA== X-Google-Smtp-Source: ACHHUZ4FP/GToLc9ozedaHHVtkAACNvi5upQAH/t/Q1DA+8Ihx3C0ZU6i5LxTt5j1LEokyObXVEXWw== X-Received: by 2002:a05:6a00:230b:b0:63d:2d7d:b6f2 with SMTP id h11-20020a056a00230b00b0063d2d7db6f2mr4429958pfh.4.1683238518527; Thu, 04 May 2023 15:15:18 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:17 -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 11/17] watchdog/hardlockup: Rename some "NMI watchdog" constants/function Date: Thu, 4 May 2023 15:13:43 -0700 Message-ID: <20230504151100.v4.11.I91f7277bab4bf8c0cb238732ed92e7ce7bbd71a6@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_231521_495665_FEC49B9E X-CRM114-Status: GOOD ( 24.66 ) 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 Do a search and replace of: - NMI_WATCHDOG_ENABLED => HARD_WATCHDOG_ENABLED - watchdog_nmi_ => watchdog_hardlockup_ Then update a few comments near where names were changed. This is specifically to make it less confusing when we want to introduce the buddy hardlockup detector, which isn't using NMIs. Signed-off-by: Douglas Anderson --- Changes in v4: - ("Rename some "NMI watchdog" constants/function ...") new for v4. arch/powerpc/include/asm/nmi.h | 4 +- arch/powerpc/kernel/watchdog.c | 12 ++--- arch/powerpc/platforms/pseries/mobility.c | 4 +- arch/sparc/kernel/nmi.c | 4 +- include/linux/nmi.h | 14 +++--- kernel/watchdog.c | 60 +++++++++++------------ kernel/watchdog_perf.c | 2 +- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/arch/powerpc/include/asm/nmi.h b/arch/powerpc/include/asm/nmi.h index c3c7adef74de..43bfd4de868f 100644 --- a/arch/powerpc/include/asm/nmi.h +++ b/arch/powerpc/include/asm/nmi.h @@ -5,10 +5,10 @@ #ifdef CONFIG_PPC_WATCHDOG extern void arch_touch_nmi_watchdog(void); long soft_nmi_interrupt(struct pt_regs *regs); -void watchdog_nmi_set_timeout_pct(u64 pct); +void watchdog_hardlockup_set_timeout_pct(u64 pct); #else static inline void arch_touch_nmi_watchdog(void) {} -static inline void watchdog_nmi_set_timeout_pct(u64 pct) {} +static inline void watchdog_hardlockup_set_timeout_pct(u64 pct) {} #endif #ifdef CONFIG_NMI_IPI diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c index dbcc4a793f0b..27d1f0dba5b3 100644 --- a/arch/powerpc/kernel/watchdog.c +++ b/arch/powerpc/kernel/watchdog.c @@ -438,7 +438,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) { int cpu = smp_processor_id(); - if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED)) + if (!(watchdog_enabled & HARD_WATCHDOG_ENABLED)) return HRTIMER_NORESTART; if (!cpumask_test_cpu(cpu, &watchdog_cpumask)) @@ -479,7 +479,7 @@ static void start_watchdog(void *arg) return; } - if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED)) + if (!(watchdog_enabled & HARD_WATCHDOG_ENABLED)) return; if (!cpumask_test_cpu(cpu, &watchdog_cpumask)) @@ -546,7 +546,7 @@ static void watchdog_calc_timeouts(void) wd_timer_period_ms = watchdog_thresh * 1000 * 2 / 5; } -void watchdog_nmi_stop(void) +void watchdog_hardlockup_stop(void) { int cpu; @@ -554,7 +554,7 @@ void watchdog_nmi_stop(void) stop_watchdog_on_cpu(cpu); } -void watchdog_nmi_start(void) +void watchdog_hardlockup_start(void) { int cpu; @@ -566,7 +566,7 @@ void watchdog_nmi_start(void) /* * Invoked from core watchdog init. */ -int __init watchdog_nmi_probe(void) +int __init watchdog_hardlockup_probe(void) { int err; @@ -582,7 +582,7 @@ int __init watchdog_nmi_probe(void) } #ifdef CONFIG_PPC_PSERIES -void watchdog_nmi_set_timeout_pct(u64 pct) +void watchdog_hardlockup_set_timeout_pct(u64 pct) { pr_info("Set the NMI watchdog timeout factor to %llu%%\n", pct); WRITE_ONCE(wd_timeout_pct, pct); diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 643d309d1bd0..9475388235a3 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -758,7 +758,7 @@ static int pseries_migrate_partition(u64 handle) goto out; if (factor) - watchdog_nmi_set_timeout_pct(factor); + watchdog_hardlockup_set_timeout_pct(factor); ret = pseries_suspend(handle); if (ret == 0) { @@ -774,7 +774,7 @@ static int pseries_migrate_partition(u64 handle) pseries_cancel_migration(handle, ret); if (factor) - watchdog_nmi_set_timeout_pct(0); + watchdog_hardlockup_set_timeout_pct(0); out: vas_migration_handler(VAS_RESUME); diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c index 5dcf31f7e81f..9d9e29b75c43 100644 --- a/arch/sparc/kernel/nmi.c +++ b/arch/sparc/kernel/nmi.c @@ -282,7 +282,7 @@ __setup("nmi_watchdog=", setup_nmi_watchdog); * sparc specific NMI watchdog enable function. * Enables watchdog if it is not enabled already. */ -void watchdog_nmi_enable(unsigned int cpu) +void watchdog_hardlockup_enable(unsigned int cpu) { if (atomic_read(&nmi_active) == -1) { pr_warn("NMI watchdog cannot be enabled or disabled\n"); @@ -303,7 +303,7 @@ void watchdog_nmi_enable(unsigned int cpu) * sparc specific NMI watchdog disable function. * Disables watchdog if it is not disabled already. */ -void watchdog_nmi_disable(unsigned int cpu) +void watchdog_hardlockup_disable(unsigned int cpu) { if (atomic_read(&nmi_active) == -1) pr_warn_once("NMI watchdog cannot be enabled or disabled\n"); diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 94ff84e1c8ec..4ff48f189ab1 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -75,9 +75,9 @@ static inline void reset_hung_task_detector(void) { } * handled differently because its value is not boolean, and the lockup * detectors are 'suspended' while 'watchdog_thresh' is equal zero. */ -#define NMI_WATCHDOG_ENABLED_BIT 0 +#define HARD_WATCHDOG_ENABLED_BIT 0 #define SOFT_WATCHDOG_ENABLED_BIT 1 -#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT) +#define HARD_WATCHDOG_ENABLED (1 << HARD_WATCHDOG_ENABLED_BIT) #define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT) #if defined(CONFIG_HARDLOCKUP_DETECTOR) @@ -120,11 +120,11 @@ static inline int hardlockup_detector_perf_init(void) { return 0; } # endif #endif -void watchdog_nmi_stop(void); -void watchdog_nmi_start(void); -int watchdog_nmi_probe(void); -void watchdog_nmi_enable(unsigned int cpu); -void watchdog_nmi_disable(unsigned int cpu); +void watchdog_hardlockup_stop(void); +void watchdog_hardlockup_start(void); +int watchdog_hardlockup_probe(void); +void watchdog_hardlockup_enable(unsigned int cpu); +void watchdog_hardlockup_disable(unsigned int cpu); void lockup_detector_reconfigure(void); diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 9c17090611f2..8e11b2b69e2c 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -193,40 +193,40 @@ static inline void watchdog_hardlockup_interrupt_count(void) { } * These functions can be overridden if an architecture implements its * own hardlockup detector. * - * watchdog_nmi_enable/disable can be implemented to start and stop when + * watchdog_hardlockup_enable/disable can be implemented to start and stop when * softlockup watchdog start and stop. The arch must select the * SOFTLOCKUP_DETECTOR Kconfig. */ -void __weak watchdog_nmi_enable(unsigned int cpu) +void __weak watchdog_hardlockup_enable(unsigned int cpu) { hardlockup_detector_perf_enable(); } -void __weak watchdog_nmi_disable(unsigned int cpu) +void __weak watchdog_hardlockup_disable(unsigned int cpu) { hardlockup_detector_perf_disable(); } -/* Return 0, if a NMI watchdog is available. Error code otherwise */ -int __weak __init watchdog_nmi_probe(void) +/* Return 0, if a hardlockup watchdog is available. Error code otherwise */ +int __weak __init watchdog_hardlockup_probe(void) { return hardlockup_detector_perf_init(); } /** - * watchdog_nmi_stop - Stop the watchdog for reconfiguration + * watchdog_hardlockup_stop - Stop the watchdog for reconfiguration * * The reconfiguration steps are: - * watchdog_nmi_stop(); + * watchdog_hardlockup_stop(); * update_variables(); - * watchdog_nmi_start(); + * watchdog_hardlockup_start(); */ -void __weak watchdog_nmi_stop(void) { } +void __weak watchdog_hardlockup_stop(void) { } /** - * watchdog_nmi_start - Start the watchdog after reconfiguration + * watchdog_hardlockup_start - Start the watchdog after reconfiguration * - * Counterpart to watchdog_nmi_stop(). + * Counterpart to watchdog_hardlockup_stop(). * * The following variables have been updated in update_variables() and * contain the currently valid configuration: @@ -234,13 +234,13 @@ void __weak watchdog_nmi_stop(void) { } * - watchdog_thresh * - watchdog_cpumask */ -void __weak watchdog_nmi_start(void) { } +void __weak watchdog_hardlockup_start(void) { } /** * lockup_detector_update_enable - Update the sysctl enable bit * - * Caller needs to make sure that the NMI/perf watchdogs are off, so this - * can't race with watchdog_nmi_disable(). + * Caller needs to make sure that the hard watchdogs are off, so this + * can't race with watchdog_hardlockup_disable(). */ static void lockup_detector_update_enable(void) { @@ -248,7 +248,7 @@ static void lockup_detector_update_enable(void) if (!watchdog_user_enabled) return; if (nmi_watchdog_available && nmi_watchdog_user_enabled) - watchdog_enabled |= NMI_WATCHDOG_ENABLED; + watchdog_enabled |= HARD_WATCHDOG_ENABLED; if (soft_watchdog_user_enabled) watchdog_enabled |= SOFT_WATCHDOG_ENABLED; } @@ -552,8 +552,8 @@ static void watchdog_enable(unsigned int cpu) /* Initialize timestamp */ update_touch_ts(); /* Enable the perf event */ - if (watchdog_enabled & NMI_WATCHDOG_ENABLED) - watchdog_nmi_enable(cpu); + if (watchdog_enabled & HARD_WATCHDOG_ENABLED) + watchdog_hardlockup_enable(cpu); } static void watchdog_disable(unsigned int cpu) @@ -563,11 +563,11 @@ static void watchdog_disable(unsigned int cpu) WARN_ON_ONCE(cpu != smp_processor_id()); /* - * Disable the perf event first. That prevents that a large delay - * between disabling the timer and disabling the perf event causes - * the perf NMI to detect a false positive. + * Disable the hardlockup detector first. That prevents that a large + * delay between disabling the timer and disabling the hardlockup + * detector causes a false positive. */ - watchdog_nmi_disable(cpu); + watchdog_hardlockup_disable(cpu); hrtimer_cancel(hrtimer); wait_for_completion(this_cpu_ptr(&softlockup_completion)); } @@ -623,7 +623,7 @@ int lockup_detector_offline_cpu(unsigned int cpu) static void __lockup_detector_reconfigure(void) { cpus_read_lock(); - watchdog_nmi_stop(); + watchdog_hardlockup_stop(); softlockup_stop_all(); set_sample_period(); @@ -631,7 +631,7 @@ static void __lockup_detector_reconfigure(void) if (watchdog_enabled && watchdog_thresh) softlockup_start_all(); - watchdog_nmi_start(); + watchdog_hardlockup_start(); cpus_read_unlock(); /* * Must be called outside the cpus locked section to prevent @@ -672,9 +672,9 @@ static __init void lockup_detector_setup(void) static void __lockup_detector_reconfigure(void) { cpus_read_lock(); - watchdog_nmi_stop(); + watchdog_hardlockup_stop(); lockup_detector_update_enable(); - watchdog_nmi_start(); + watchdog_hardlockup_start(); cpus_read_unlock(); } void lockup_detector_reconfigure(void) @@ -731,10 +731,10 @@ static void proc_watchdog_update(void) * * caller | table->data points to | 'which' * -------------------|----------------------------|-------------------------- - * proc_watchdog | watchdog_user_enabled | NMI_WATCHDOG_ENABLED | + * proc_watchdog | watchdog_user_enabled | HARD_WATCHDOG_ENABLED | * | | SOFT_WATCHDOG_ENABLED * -------------------|----------------------------|-------------------------- - * proc_nmi_watchdog | nmi_watchdog_user_enabled | NMI_WATCHDOG_ENABLED + * proc_nmi_watchdog | nmi_watchdog_user_enabled | HARD_WATCHDOG_ENABLED * -------------------|----------------------------|-------------------------- * proc_soft_watchdog | soft_watchdog_user_enabled | SOFT_WATCHDOG_ENABLED */ @@ -768,7 +768,7 @@ static int proc_watchdog_common(int which, struct ctl_table *table, int write, int proc_watchdog(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { - return proc_watchdog_common(NMI_WATCHDOG_ENABLED|SOFT_WATCHDOG_ENABLED, + return proc_watchdog_common(HARD_WATCHDOG_ENABLED|SOFT_WATCHDOG_ENABLED, table, write, buffer, lenp, ppos); } @@ -780,7 +780,7 @@ int proc_nmi_watchdog(struct ctl_table *table, int write, { if (!nmi_watchdog_available && write) return -ENOTSUPP; - return proc_watchdog_common(NMI_WATCHDOG_ENABLED, + return proc_watchdog_common(HARD_WATCHDOG_ENABLED, table, write, buffer, lenp, ppos); } @@ -944,7 +944,7 @@ void __init lockup_detector_init(void) cpumask_copy(&watchdog_cpumask, housekeeping_cpumask(HK_TYPE_TIMER)); - if (!watchdog_nmi_probe()) + if (!watchdog_hardlockup_probe()) nmi_watchdog_available = true; lockup_detector_setup(); watchdog_sysctl_init(); diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c index 547917ebd5d3..aadc52b79f5b 100644 --- a/kernel/watchdog_perf.c +++ b/kernel/watchdog_perf.c @@ -215,7 +215,7 @@ void __init hardlockup_detector_perf_restart(void) lockdep_assert_cpus_held(); - if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED)) + if (!(watchdog_enabled & HARD_WATCHDOG_ENABLED)) return; for_each_online_cpu(cpu) { From patchwork Thu May 4 22:13:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231892 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 E9BF3C7EE23 for ; Thu, 4 May 2023 22:41:16 +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=/9jeVUgBsUv3JCdNfBcDZTbPwRSVWz2QrlgeghbyUYQ=; b=diRpJ8wHt5Wgzv ut0ozmUVeCu6skNGU39E5GrclbtEH7LFUXNs1ouqYyvJBEAYkTuKBoI15G+6OXlTBr0P5WPX5rxbF qWbDfD8UjGO+IcFUiJAoM8jveSSg4Hnbe1HUupH3JOwVF4jTmzAg/X5F/YzQHuMySx18625wOOlq7 5kB3ibsYx6PlBK5Ed9OuC3GjVVTa+dYPd/T084rogOe2+mqML/fH/xrwPM40aG1ceru1tfNAHCrlL PP1t3IKqt7bxWN/MFn0UWS+FP4QtYgw1SkPFb23pwfZm1g+m/ynrMpJrBbaxyn/DJdlAcQ4hRbqaG OAKJldAU+aGGgrT0Qfvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhcj-009EM8-2w; Thu, 04 May 2023 22:40:29 +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 1puhch-009EL1-2b for linux-arm-kernel@bombadil.infradead.org; Thu, 04 May 2023 22:40:27 +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=EpNx2mefmmTFSIK86nVDDorYanqvx1+R+XQHbD6HO+g=; b=gFyjipwWbLdGWbZ8scObj/Rg8n XBeT5dM+au5B99+UQkH6amwEoCni/jxorFr3SmzBng+MTNsyXDcXNPq/KZu/S1DDMl5MVhqglJbfn 485a/fR6LQQjmx9B/zevxZlHCkPYnbJLwCbZ8kgsPE7sVey4j/Pn4924IegggitP4ojrsMfEOhooP 507WzSKY6YmhBIwE/tdOSSC/BeG3d/MJ4GIJHXHr+yq2Tny9OlDELb8a2X23NfF4jto6I/WHBTO4V eFUOq4Mw9Vwx3SyfsMGwTcNAdekVyGliCvH9ATs72lasG3MFo59WeonFaeE3c3v4WuG15t/tLYS4b CIYuTG7Q==; Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEQ-001sta-2P for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:29 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-64389a44895so999965b3a.1 for ; Thu, 04 May 2023 15:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238521; x=1685830521; 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=EpNx2mefmmTFSIK86nVDDorYanqvx1+R+XQHbD6HO+g=; b=WPcSR3R7jjK9WrSlZYb1jvNciRB2tdefqvLGeYiNPDqqWmjVz76xSEIkx9VYfhmfMR hY1BRmupeZu5pqlCKLwiWpnysWXfjKKqOEd3mfitJulaCUffZuMC9LYQGtee8IH2dMLT euN8Ii5incOonQ2VMHl1cexqG3i6r/ETrbuH4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238521; x=1685830521; 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=EpNx2mefmmTFSIK86nVDDorYanqvx1+R+XQHbD6HO+g=; b=LX1VGqd62O/Prnm0MBHkC9/tN1BkeuMfBDbVXwMg+tUYi3PE9bNw/zqWjuZS0GL/Ib jdkarwOSe9ZdD3cTuJZ93jwCzUg33mB/DuzRZ1T9stnoG6oCqAZBYUcH1ub85Eeey58Z exa9QY54JXOilTaJJP9bdiV7TTWN0ZCJ+sOrWxut4ubBZBDsWi8ApSZ1oWXZUMLkAkoZ bQredy+kZr5UYwk2siVGJCpIf5te2YVgJ2k1rLK506T2Z/hPJOoUQ7hjI1q62DTwuWJe 4umskdx1B9bOKZJlb5pxtJnWR3CWezAgCjYXFJu/kg17D6l/V+++jfyo0h+0m2SFM7Je gCzQ== X-Gm-Message-State: AC+VfDzwzY4TN6AdgsnTToQIaCH/GrbiHoJDeDRkafkh2UwijNHD/EwV vE7/CZ86jfwlBaGho4Rh4dZ3ww== X-Google-Smtp-Source: ACHHUZ5AX06YNKlkJIQ1gYhAYjAuz3cGg3jKF0Ccmbxhyk2anQXzj3z0TcEAc0/o771Fvgq/6YT5Uw== X-Received: by 2002:a05:6a00:2352:b0:63f:158a:6e7b with SMTP id j18-20020a056a00235200b0063f158a6e7bmr5043905pfj.6.1683238521355; Thu, 04 May 2023 15:15:21 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:20 -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 12/17] watchdog/hardlockup: Have the perf hardlockup use __weak functions more cleanly Date: Thu, 4 May 2023 15:13:44 -0700 Message-ID: <20230504151100.v4.12.I847d9ec852449350997ba00401d2462a9cb4302b@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_231523_464416_F5BF8041 X-CRM114-Status: GOOD ( 22.39 ) 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 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. Signed-off-by: Douglas Anderson --- Changes in v4: - ("Have the perf hardlockup use __weak ...") new for v4. include/linux/nmi.h | 10 ---------- kernel/watchdog.c | 30 ++++++++++++++++++------------ kernel/watchdog_perf.c | 20 ++++++++++++++------ 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 4ff48f189ab1..094a0e7ed97d 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -103,21 +103,11 @@ static inline void arch_touch_nmi_watchdog(void) { } #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); diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 8e11b2b69e2c..e21896a0a9d5 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -190,27 +190,33 @@ static inline void watchdog_hardlockup_interrupt_count(void) { } #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; } /** diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c index aadc52b79f5b..a55a6eab1b3a 100644 --- a/kernel/watchdog_perf.c +++ b/kernel/watchdog_perf.c @@ -132,10 +132,14 @@ static int hardlockup_detector_event_create(void) } /** - * 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(void) } /** - * 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_restart(void) } /** - * 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(); From patchwork Thu May 4 22:13:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231884 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 A7922C77B7C for ; Thu, 4 May 2023 22:17:47 +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=3ZY7jXaUMCTxaCBvYiWhn7tnjfcGbYYFVpEeM9g+R5Q=; b=Rk7jZ93VoTGik1 SvcZxsDXxST+RZ79o8cAaAhzrLG6VgoO6TpPIG9GiulrGNKJYZoqV+Nvu1ufI/WbjDMrq9t/voRWE VWG/Y/CGPfMLfN1W2lIKdT5wj3Ikm8CU9y7gofc7Wemfjcd0aiCZg/LWzMu0A0jrQgFFCGr4r/0Dp 9FFrFuSJxCgbhInexPM9UUaR9l/spZhQDsq5nWO6BESqmDRXSvQdL4NkY9QYQjSAn2GsfgGsB5JVO 9RHRky9ROp9U7PUSDYBRlFQVtGKYZfMd9CCZ8BYQteQikVHdpjX4/ppp99vVKeyAi5ubmD7+UMGEh ba1KQEKer2ccPn54gSXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhEh-009Ajs-1P; Thu, 04 May 2023 22:15:39 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEa-009Af5-2o for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:37 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-518d325b8a2so911686a12.0 for ; Thu, 04 May 2023 15:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238525; x=1685830525; 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=W+IwiO6BkZ386rQ6tL2riT/uUs/ukO+qpqxYGZg6Wtg=; b=RChb5tdEiUErPRm6Am0LrV9QKD9AKFEMsEq8ugriWkS2t2zfoJlG8fWH0vFeo/bhvt Y1YxG83D08cWbF978ljkScvrm24zk31mBCEdISAP0n58kvInAzGB3QVSrQ/R04/ezM5S 547+ba/9aeEKVDXEKb1QgKyc6+agJHBDd3cyY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238525; x=1685830525; 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=W+IwiO6BkZ386rQ6tL2riT/uUs/ukO+qpqxYGZg6Wtg=; b=DptcyMQM2iGS12maKFpjXVuOcVfvtDI/xlH1cL8QtFlrEkkYSBrv8pfaMmlFLuWRwq 6GwC8KUaafFlQrWdW9BPmC/g8G5OImZ5YQmjQ4jjBRRPRtkEJrYh0YLbSSMlxwYCQFMV s/IzL8No8D35IWlXyNDUlDBMFQ34dWOgu5Yi5L3rNVLRLbKkacFsuPF333EOWdUZSJht PDD7K+L0hY3fmSd+2iFvNmK2gm/HU1p8FewoiVEFoU6FU8XNo2sdJUrRnSob37OjV5Zi UEiVjCBJ65DGK0ZcTtd0ucnfoHizHq/csZvMG3kLo2v6kntcWgwlKTa9EkDZ/z+jO9Hh fw3g== X-Gm-Message-State: AC+VfDyd3LSTRSRVp96IQsvdPj+oOBylcb7mPuF+Mw7pVPIA39ZmxoVT kDC5tIcDEj3rYIgKZ9ZNCNSWww== X-Google-Smtp-Source: ACHHUZ6AuMOi7MOxZ52sSloOqCaLgLbh3Pvjc9+HvZIsFIUXihxHsWDuBIFX2bu4Qb79AtBjV1TAVg== X-Received: by 2002:a05:6a20:1604:b0:f6:5a75:7d44 with SMTP id l4-20020a056a20160400b000f65a757d44mr4856999pzj.12.1683238524979; Thu, 04 May 2023 15:15:24 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:24 -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 , Colin Cross , Douglas Anderson Subject: [PATCH v4 13/17] watchdog/hardlockup: detect hard lockups using secondary (buddy) CPUs Date: Thu, 4 May 2023 15:13:45 -0700 Message-ID: <20230504151100.v4.13.I6bf789d21d0c3d75d382e7e51a804a7a51315f2c@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_151532_916215_EA20427E X-CRM114-Status: GOOD ( 47.40 ) 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 From: Colin Cross Implement a hardlockup detector that doesn't doesn't need any extra arch-specific support code to detect lockups. Instead of using something arch-specific we will use the buddy system, where each CPU watches out for another one. Specifically, each CPU will use its softlockup hrtimer to check that the next CPU is processing hrtimer interrupts by verifying that a counter is increasing. NOTE: unlike the other hard lockup detectors, the buddy one can't easily show what's happening on the CPU that locked up just by doing a simple backtrace. It relies on some other mechanism in the system to get information about the locked up CPUs. This could be support for NMI backtraces like [1], it could be a mechanism for printing the PC of locked CPUs at panic time like [2] / [3], or it could be something else. Even though that means we still rely on arch-specific code, this arch-specific code seems to often be implemented even on architectures that don't have a hardlockup detector. This style of hardlockup detector originated in some downstream Android trees and has been rebased on / carried in ChromeOS trees for quite a long time for use on arm and arm64 boards. Historically on these boards we've leveraged mechanism [2] / [3] to get information about hung CPUs, but we could move to [1]. Although the original motivation for the buddy system was for use on systems without an arch-specific hardlockup detector, it can still be useful to use even on systems that _do_ have an arch-specific hardlockup detector. On x86, for instance, there is a 24-part patch series [4] in progress switching the arch-specific hard lockup detector from a scarce perf counter to a less-scarce hardware resource. Potentially the buddy system could be a simpler alternative to free up the perf counter but still get hard lockup detection. Overall, pros (+) and cons (-) of the buddy system compared to an arch-specific hardlockup detector (which might be implemented using perf): + The buddy system is usable on systems that don't have an arch-specific hardlockup detector, like arm32 and arm64 (though it's being worked on for arm64 [5]). + The buddy system may free up scarce hardware resources. + If a CPU totally goes out to lunch (can't process NMIs) the buddy system could still detect the problem (though it would be unlikely to be able to get a stack trace). + The buddy system uses the same timer function to pet the hardlockup detector on the running CPU as it uses to detect hardlockups on other CPUs. Compared to other hardlockup detectors, this means it generates fewer interrupts and thus is likely better able to let CPUs stay idle longer. - If all CPUs are hard locked up at the same time the buddy system can't detect it. - If we don't have SMP we can't use the buddy system. - The buddy system needs an arch-specific mechanism (possibly NMI backtrace) to get info about the locked up CPU. [1] https://lore.kernel.org/r/20230419225604.21204-1-dianders@chromium.org [2] https://issuetracker.google.com/172213129 [3] https://docs.kernel.org/trace/coresight/coresight-cpu-debug.html [4] https://lore.kernel.org/lkml/20230301234753.28582-1-ricardo.neri-calderon@linux.intel.com/ [5] https://lore.kernel.org/linux-arm-kernel/20220903093415.15850-1-lecopzer.chen@mediatek.com/ Signed-off-by: Colin Cross Signed-off-by: Matthias Kaehlcke Signed-off-by: Guenter Roeck Signed-off-by: Tzung-Bi Shih Signed-off-by: Douglas Anderson --- This patch has been rebased in ChromeOS kernel trees many times, and each time someone had to do work on it they added their Signed-off-by. I've included those here. I've also left the author as Colin Cross since the core code is still his, even if it's now been reorganized a lot. Changes in v4: - Reworked atop a whole pile of cleanups, as suggested by Petr. Changes in v3: - Added a note in commit message about the effect on idle. - Cleaned up commit message pros/cons to be complete sentences. - More cpu => CPU (in Kconfig and comments). - No code changes other than comments. Changes in v2: - No code changes. - Reworked description and Kconfig based on v1 discussion. - cpu => CPU (in commit message). include/linux/nmi.h | 9 +++- kernel/Makefile | 1 + kernel/watchdog.c | 29 +++++++++---- kernel/watchdog_buddy.c | 93 +++++++++++++++++++++++++++++++++++++++++ lib/Kconfig.debug | 52 +++++++++++++++++++++-- 5 files changed, 173 insertions(+), 11 deletions(-) create mode 100644 kernel/watchdog_buddy.c diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 094a0e7ed97d..90aa33317b4c 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -87,8 +87,9 @@ extern unsigned int hardlockup_panic; static inline void hardlockup_detector_disable(void) {} #endif -#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) +#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER) void arch_touch_nmi_watchdog(void); +void watchdog_hardlockup_touch_cpu(unsigned int cpu); void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs); #elif !defined(CONFIG_HAVE_NMI_WATCHDOG) static inline void arch_touch_nmi_watchdog(void) { } @@ -118,6 +119,12 @@ void watchdog_hardlockup_disable(unsigned int cpu); void lockup_detector_reconfigure(void); +#ifdef CONFIG_HARDLOCKUP_DETECTOR_BUDDY +void watchdog_buddy_check_hardlockup(unsigned long hrtimer_interrupts); +#else +static inline void watchdog_buddy_check_hardlockup(unsigned long hrtimer_interrupts) {} +#endif + /** * touch_hardlockup_watchdog - manually pet the hardlockup watchdog. * diff --git a/kernel/Makefile b/kernel/Makefile index 406ccccc4dd3..3f4f7975a8b8 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -91,6 +91,7 @@ obj-$(CONFIG_FAIL_FUNCTION) += fail_function.o obj-$(CONFIG_KGDB) += debug/ obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o +obj-$(CONFIG_HARDLOCKUP_DETECTOR_BUDDY) += watchdog_buddy.o obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_perf.o obj-$(CONFIG_SECCOMP) += seccomp.o obj-$(CONFIG_RELAY) += relay.o diff --git a/kernel/watchdog.c b/kernel/watchdog.c index e21896a0a9d5..678d55172ef4 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -85,7 +85,7 @@ __setup("nmi_watchdog=", hardlockup_panic_setup); #endif /* CONFIG_HARDLOCKUP_DETECTOR */ -#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF) +#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER) static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts); static DEFINE_PER_CPU(unsigned long, hrtimer_interrupts_saved); @@ -106,6 +106,14 @@ notrace void arch_touch_nmi_watchdog(void) } EXPORT_SYMBOL(arch_touch_nmi_watchdog); +void watchdog_hardlockup_touch_cpu(unsigned int cpu) +{ + per_cpu(watchdog_hardlockup_touch, cpu) = true; + + /* Match with smp_rmb() in watchdog_hardlockup_check() */ + smp_wmb(); +} + static bool watchdog_hardlockup_is_lockedup(unsigned int cpu) { unsigned long hrint = per_cpu(hrtimer_interrupts, cpu); @@ -118,13 +126,16 @@ static bool watchdog_hardlockup_is_lockedup(unsigned int cpu) return false; } -static void watchdog_hardlockup_interrupt_count(void) +static unsigned long watchdog_hardlockup_interrupt_count(void) { - __this_cpu_inc(hrtimer_interrupts); + return __this_cpu_inc_return(hrtimer_interrupts); } void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs) { + /* Match with smp_wmb() in watchdog_hardlockup_touch_cpu() */ + smp_rmb(); + if (__this_cpu_read(watchdog_hardlockup_touch)) { __this_cpu_write(watchdog_hardlockup_touch, false); return; @@ -183,11 +194,11 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs) } } -#else /* CONFIG_HARDLOCKUP_DETECTOR_PERF */ +#else /* CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER */ -static inline void watchdog_hardlockup_interrupt_count(void) { } +static inline unsigned long watchdog_hardlockup_interrupt_count(void) { return 0; } -#endif /* !CONFIG_HARDLOCKUP_DETECTOR_PERF */ +#endif /* !CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER */ /* * These functions can be overridden based on the configured hardlockdup detector. @@ -446,12 +457,16 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) struct pt_regs *regs = get_irq_regs(); int duration; int softlockup_all_cpu_backtrace = sysctl_softlockup_all_cpu_backtrace; + unsigned long hrtimer_interrupts; if (!watchdog_enabled) return HRTIMER_NORESTART; /* kick the hardlockup detector */ - watchdog_hardlockup_interrupt_count(); + hrtimer_interrupts = watchdog_hardlockup_interrupt_count(); + + /* test for hardlockups */ + watchdog_buddy_check_hardlockup(hrtimer_interrupts); /* kick the softlockup detector */ if (completion_done(this_cpu_ptr(&softlockup_completion))) { diff --git a/kernel/watchdog_buddy.c b/kernel/watchdog_buddy.c new file mode 100644 index 000000000000..fee45af2e5bd --- /dev/null +++ b/kernel/watchdog_buddy.c @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include + +static cpumask_t __read_mostly watchdog_cpus; + +static unsigned int watchdog_next_cpu(unsigned int cpu) +{ + cpumask_t cpus = watchdog_cpus; + unsigned int next_cpu; + + next_cpu = cpumask_next(cpu, &cpus); + if (next_cpu >= nr_cpu_ids) + next_cpu = cpumask_first(&cpus); + + if (next_cpu == cpu) + return nr_cpu_ids; + + return next_cpu; +} + +int __init watchdog_hardlockup_probe(void) +{ + return 0; +} + +void watchdog_hardlockup_enable(unsigned int cpu) +{ + unsigned int next_cpu; + + /* + * The new CPU will be marked online before the hrtimer interrupt + * gets a chance to run on it. If another CPU tests for a + * hardlockup on the new CPU before it has run its the hrtimer + * interrupt, it will get a false positive. Touch the watchdog on + * the new CPU to delay the check for at least 3 sampling periods + * to guarantee one hrtimer has run on the new CPU. + */ + watchdog_hardlockup_touch_cpu(cpu); + + /* + * We are going to check the next CPU. Our watchdog_hrtimer + * need not be zero if the CPU has already been online earlier. + * Touch the watchdog on the next CPU to avoid false positive + * if we try to check it in less then 3 interrupts. + */ + next_cpu = watchdog_next_cpu(cpu); + if (next_cpu < nr_cpu_ids) + watchdog_hardlockup_touch_cpu(next_cpu); + + cpumask_set_cpu(cpu, &watchdog_cpus); +} + +void watchdog_hardlockup_disable(unsigned int cpu) +{ + unsigned int next_cpu = watchdog_next_cpu(cpu); + + /* + * Offlining this CPU will cause the CPU before this one to start + * checking the one after this one. If this CPU just finished checking + * the next CPU and updating hrtimer_interrupts_saved, and then the + * previous CPU checks it within one sample period, it will trigger a + * false positive. Touch the watchdog on the next CPU to prevent it. + */ + if (next_cpu < nr_cpu_ids) + watchdog_hardlockup_touch_cpu(next_cpu); + + cpumask_clear_cpu(cpu, &watchdog_cpus); +} + +void watchdog_buddy_check_hardlockup(unsigned long hrtimer_interrupts) +{ + unsigned int next_cpu; + + /* + * Test for hardlockups every 3 samples. The sample period is + * watchdog_thresh * 2 / 5, so 3 samples gets us back to slightly over + * watchdog_thresh (over by 20%). + */ + if (hrtimer_interrupts % 3 != 0) + return; + + /* check for a hardlockup on the next CPU */ + next_cpu = watchdog_next_cpu(smp_processor_id()); + if (next_cpu >= nr_cpu_ids) + return; + + watchdog_hardlockup_check(next_cpu, NULL); +} diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 39d1d93164bd..a80f6b8a21eb 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1025,10 +1025,55 @@ config BOOTPARAM_SOFTLOCKUP_PANIC Say N if unsure. -config HARDLOCKUP_DETECTOR_PERF +# Both the "perf" and "buddy" hardlockup detectors count hrtimer +# interrupts. This config enables functions managing this common code. +config HARDLOCKUP_DETECTOR_COUNTS_HRTIMER bool select SOFTLOCKUP_DETECTOR +config HARDLOCKUP_DETECTOR_PERF + bool + depends on HAVE_HARDLOCKUP_DETECTOR_PERF + select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER + +config HARDLOCKUP_DETECTOR_BUDDY + bool + depends on SMP + select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER + +# For hardlockup detectors you can have one directly provided by the arch +# or use a "non-arch" one. If you're using a "non-arch" one that is +# further divided the perf hardlockup detector (which, confusingly, needs +# arch-provided perf support) and the buddy hardlockup detector (which just +# needs SMP). In either case, using the "non-arch" code conflicts with +# the NMI watchdog code (which is sometimes used directly and sometimes used +# by the arch-provided hardlockup detector). +config HAVE_HARDLOCKUP_DETECTOR_NON_ARCH + bool + depends on (HAVE_HARDLOCKUP_DETECTOR_PERF || SMP) && !HAVE_NMI_WATCHDOG + default y + +config HARDLOCKUP_DETECTOR_PREFER_BUDDY + bool "Prefer the buddy CPU hardlockup detector" + depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH && HAVE_HARDLOCKUP_DETECTOR_PERF && SMP + help + Say Y here to prefer the buddy hardlockup detector over the perf one. + + With the buddy detector, each CPU uses its softlockup hrtimer + to check that the next CPU is processing hrtimer interrupts by + verifying that a counter is increasing. + + This hardlockup detector is useful on systems that don't have + an arch-specific hardlockup detector or if resources needed + for the hardlockup detector are better used for other things. + +# This will select the appropriate non-arch hardlockdup detector +config HARDLOCKUP_DETECTOR_NON_ARCH + bool + depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH + select HARDLOCKUP_DETECTOR_BUDDY if !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY + select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY + # # Enables a timestamp based low pass filter to compensate for perf based # hard lockup detection which runs too fast due to turbo modes. @@ -1043,9 +1088,10 @@ config HARDLOCKUP_CHECK_TIMESTAMP config HARDLOCKUP_DETECTOR bool "Detect Hard Lockups" depends on DEBUG_KERNEL && !S390 - depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_ARCH + depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH || HAVE_HARDLOCKUP_DETECTOR_ARCH select LOCKUP_DETECTOR - select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF + select HARDLOCKUP_DETECTOR_NON_ARCH if HAVE_HARDLOCKUP_DETECTOR_NON_ARCH + help Say Y here to enable the kernel to act as a watchdog to detect hard lockups. 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"); From patchwork Thu May 4 22:13:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231889 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 BF79FC7EE26 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=+S86iBoiUU2Yn2UADcGuNncSF+GZGsU1YYQYIaKeEsU=; b=oZghUICY/JzzzL ALuk26XLQCoaHFvzplxTcUEPRnh4glR1L2dJHXGkjGbS5ViScO6KMPJEwGx+lOHZ2GjHeQcT9oKk8 e0/TzpK/ZTzPA0qDH2V9vgv6m+/OUuSS0l8dEx6bd97ZYuOpMcOetNcGSFqixWgILH0Zm3F+QWye5 ZvL9m1qCn6R+MAYH0qWNb3xrtHSFdJdRkdKsbNPxsdw0apgAPIxJZV4az3DnwP7H/3Axmt3VxRY2G LrJCANCbUO6tw+ixFrnq522KoDdnmRWJqrk22S0eP8uQTH4zxBLFusWIV1uSR5KF4wHjPjmOcmbM/ gEfyVyr5P8OYhxMwClgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhcW-009EG3-2T; Thu, 04 May 2023 22:40:16 +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 1puhcV-009EFF-03 for linux-arm-kernel@bombadil.infradead.org; Thu, 04 May 2023 22:40:15 +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=Cb+ov5fy8GT79FMmcyf1ZMUm58eKGi3E0UeboMl9k0k=; b=BBitqiM7KW/TCV8WZoKlq4BAXC 764kuhbBK292SlrAbGCGXzrmymQn7nnN/FeNkRrhyNIwcJjDUz/rboyBkKT/2vJs8d6y93mc0weR7 jyFPBOVcE+f+gAL37feoxpIU4pZi3vIpFbssKazyDegSDcTHQQDpT/t1wC9szIBivP2OdQJoT8Z+t 3Blq/uqP3xfTBuplDik4q6HEXidvgbtRHEn6esEVCq7zuZzTcJaPUkoR5ifseSVKbxqqWTKnUrELD oumyx16Af5UftTO/hbtr5qv8SFyl2FE4l1f1YCvVzKYLnjxJ6Rp/vIjdIBNTmYjZm1dpuKucfeyxg /wXe4Dig==; Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEa-001sup-2F for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:35 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-64395e741fcso969508b3a.2 for ; Thu, 04 May 2023 15:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238531; x=1685830531; 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=Cb+ov5fy8GT79FMmcyf1ZMUm58eKGi3E0UeboMl9k0k=; b=CjMBjXb4dakIH/Hz1W+AbgyxL0xcYhy7OZZf09KX3sDf9yAF4rhCtWuKzwEhAs+5/i hEzlyTV4xhw3Mp/uMdYzUq9UGSlBG4bqWtY9NWExnwuQfYOMW8tNfC51A60DvQW7afZn h/GwPSH86KKBgViH3tcM+m/6e9fAaR1bB8IPk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238531; x=1685830531; 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=Cb+ov5fy8GT79FMmcyf1ZMUm58eKGi3E0UeboMl9k0k=; b=SKCOCnMjUwjPK2kL9yGxAWhAS70LkzxBhO7PVymccxh+M9ol2gS1O3EOEFtl15jbz+ xGBghZcqWvIcSUjwFGe7z13Al/Etv+jn5qIuQoltP4/6TWmgjYGZZ7bZqm5oKxbbypnE NqGzsgYUEqWa9azEjSVsZR1zbm7wtvvHqri/HZl30w4i1t+dc5e+atqcKU51JGlnCC+o O7i9NPA45p+42GbRx/8lAAjHk2ofcMPRYWR3A4tj4GyNYEdsSIsyQr/ACVCGllqIdv53 8l8fyIuq1CVD49o6xKlZqQByW4wXAFPnhI2qXDUN8FZaDrBsfZwLYEJMAowH04524Mxv w71Q== X-Gm-Message-State: AC+VfDzB9Jll41wulYxSQXoANUhPlf16YvLmo2WKmqtIZwRSid1Bk0rT JBIkvcRnwqQhQsAwW/ZKmxFsiQ== X-Google-Smtp-Source: ACHHUZ4X6wdGMyW/UcCstp1VEpR79rnk9KRzJXDwHbVx8n04QbMhxm2ST+x4EIRRDKqxPh/P32rORQ== X-Received: by 2002:a05:6a00:80f:b0:5a8:8535:18b with SMTP id m15-20020a056a00080f00b005a88535018bmr4857970pfk.11.1683238531276; Thu, 04 May 2023 15:15:31 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:30 -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 15/17] watchdog/perf: Adapt the watchdog_perf interface for async model Date: Thu, 4 May 2023 15:13:47 -0700 Message-ID: <20230504151100.v4.15.If4ad5dd5d09fb1309cebf8bcead4b6a5a7758ca7@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_231533_041371_D2FAE47A X-CRM114-Status: GOOD ( 33.39 ) 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 From: Lecopzer Chen When lockup_detector_init()->watchdog_hardlockup_probe(), PMU may be not ready yet. E.g. on arm64, PMU is not ready until device_initcall(armv8_pmu_driver_init). And it is deeply integrated with the driver model and cpuhp. Hence it is hard to push this initialization before smp_init(). But it is easy to take an opposite approach and try to initialize the watchdog once again later. The delayed probe is called using workqueues. It need to allocate memory and must be proceed in a normal context. The delayed probe is able to use if watchdog_hardlockup_probe() returns non-zero which means the return code returned when PMU is not ready yet. Provide an API - lockup_detector_retry_init() for anyone who needs to delayed init lockup detector if they had ever failed at lockup_detector_init(). The original assumption is: nobody should use delayed probe after lockup_detector_check() which has __init attribute. That is, anyone uses this API must call between lockup_detector_init() and lockup_detector_check(), and the caller must have __init attribute Reviewed-by: Petr Mladek Co-developed-by: Pingfan Liu Signed-off-by: Pingfan Liu Signed-off-by: Lecopzer Chen Suggested-by: Petr Mladek Signed-off-by: Douglas Anderson --- I yanked this patch from the mailing lists [1] into my series just to make it easier to avoid conflicts between my series and the one adding the arm64 perf hardlockup detector, in case someone wanted to test them both together. As part of making this match with my series, I resolved a few conflicts and did a few renames. I also fixed the kernel test robot yell [2] by providing a dummy implementation of the retry function if CONFIG_LOCKUP_DETECTOR wasn't defined. That led me to move the definition of the function and sanitize the name of the function to match others around it. This patch makes less sense without the patches to add support for the arm64 perf hardlockup detector. Thus, I've put it at the end of the series. I removed the "kernel test robot" tag since that didn't really make sense. Presumably the robot found a problem on a previous version of the patch, but that's not normally a reason to add the Reported-by. [1] https://lore.kernel.org/r/20220903093415.15850-5-lecopzer.chen@mediatek.com/ [2] https://lore.kernel.org/r/202209050639.jDaWd49E-lkp@intel.com/ Changes in v4: - Pulled ("Adapt the watchdog_hld interface ...") into my series for v4. include/linux/nmi.h | 2 ++ kernel/watchdog.c | 67 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 9caea5ba494d..3cacc5fc16b9 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -13,6 +13,7 @@ #ifdef CONFIG_LOCKUP_DETECTOR void lockup_detector_init(void); +void lockup_detector_retry_init(void); void lockup_detector_soft_poweroff(void); void lockup_detector_cleanup(void); @@ -34,6 +35,7 @@ extern int sysctl_hardlockup_all_cpu_backtrace; #else /* CONFIG_LOCKUP_DETECTOR */ static inline void lockup_detector_init(void) { } +static inline void lockup_detector_retry_init(void) { } static inline void lockup_detector_soft_poweroff(void) { } static inline void lockup_detector_cleanup(void) { } #endif /* !CONFIG_LOCKUP_DETECTOR */ diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 678d55172ef4..55471634d932 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -211,7 +211,13 @@ void __weak watchdog_hardlockup_enable(unsigned int cpu) { } void __weak watchdog_hardlockup_disable(unsigned int cpu) { } -/* Return 0, if a hardlockup watchdog is available. Error code otherwise */ +/* + * Watchdog-detector specific API. + * + * Return 0 when hardlockup watchdog is available, negative value otherwise. + * Note that the negative value means that a delayed probe might + * succeed later. + */ int __weak __init watchdog_hardlockup_probe(void) { /* @@ -957,6 +963,62 @@ static void __init watchdog_sysctl_init(void) #define watchdog_sysctl_init() do { } while (0) #endif /* CONFIG_SYSCTL */ +static void __init lockup_detector_delay_init(struct work_struct *work); +static bool allow_lockup_detector_init_retry __initdata; + +static struct work_struct detector_work __initdata = + __WORK_INITIALIZER(detector_work, lockup_detector_delay_init); + +static void __init lockup_detector_delay_init(struct work_struct *work) +{ + int ret; + + ret = watchdog_hardlockup_probe(); + if (ret) { + pr_info("Delayed init of the lockup detector failed: %d\n", ret); + pr_info("Hard watchdog permanently disabled\n"); + return; + } + + allow_lockup_detector_init_retry = false; + + nmi_watchdog_available = true; + lockup_detector_setup(); +} + +/* + * lockup_detector_retry_init - retry init lockup detector if possible. + * + * Retry hardlockup detector init. It is useful when it requires some + * functionality that has to be initialized later on a particular + * platform. + */ +void __init lockup_detector_retry_init(void) +{ + /* Must be called before late init calls */ + if (!allow_lockup_detector_init_retry) + return; + + schedule_work(&detector_work); +} + +/* + * Ensure that optional delayed hardlockup init is proceed before + * the init code and memory is freed. + */ +static int __init lockup_detector_check(void) +{ + /* Prevent any later retry. */ + allow_lockup_detector_init_retry = false; + + /* Make sure no work is pending. */ + flush_work(&detector_work); + + return 0; + +} +late_initcall_sync(lockup_detector_check); + void __init lockup_detector_init(void) { if (tick_nohz_full_enabled()) @@ -967,6 +1029,9 @@ void __init lockup_detector_init(void) if (!watchdog_hardlockup_probe()) nmi_watchdog_available = true; + else + allow_lockup_detector_init_retry = true; + lockup_detector_setup(); watchdog_sysctl_init(); } From patchwork Thu May 4 22:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231886 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 5AC4AC77B7C for ; Thu, 4 May 2023 22:41:03 +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=MX1MZnCUIRkMnt8qXc0x14nXpB6G6Vr3FliKnUqX9d4=; b=Q+5xBmUnAjz750 RJ7KKiSgGW2nS9IPRlNbnwtUfS5nKonNeKvnVYzPGz5wfExVPlPdeSHjICzHcqtDu/mt9ePXbUIxN ZSX6qqgO18nwmXbmPsLb7QRmFU3bo0ZkgVQeB1BWCPFZGlRLzHVwp0GQFS0zyVA+z+rmZvncWqinZ 18L5HbuZ4OpqBfCCYZbGLVeaegOTtfQVobw3dUe+FWyGNwHXoS8gon8ZCuEXcoYXoHxBJjhlxyLVB iQDCIu3JrHXeW8awG/Efm6UWAGAyAeFsi+4IKDBTaB1k+Tib6O5GIi9VvjSgI6uLxGxzL4Hw2H4EB 4ybMg3EoDccY8XUfjpyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhcU-009EFV-2C; Thu, 04 May 2023 22:40:14 +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 1puhcS-009EEy-2u for linux-arm-kernel@bombadil.infradead.org; Thu, 04 May 2023 22:40:13 +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=RCs/9iBvrEyNVZzCTd/A2GImby0Xt44Wx/SBN2PNOfk=; b=PQOu557JX+o4zHxLQzA1KqOWGb +sisbS4AIk5JaKCd2uFWkS2lxifROEucy7mDmdN+i/9o2esZpswjEYNvQYry1J0d14k82/zPaVg+T MQmCVF/OdS4PYpUZU7Zqwr7A8ZDBN9FEGxgqPCZlPsOVe18V9BoRU4nllZYKXYTrZb89u7lOQqy2y +HOBJODmPyr/72heKuYlcQMcNyZxRGD5GtDYeItcTF/PPwFg4hOK2CLZV6EQNBDDJSJ5L0kSy7h+o 2XHQ1J9NmkjQPfwvJ1uXT6E9pWFmRzzSA97feJ77SbcnMBXJvwIpXj5ajG5h+Kh3uL4d1bEMXUk22 ksjyMo/w==; Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEe-001svN-14 for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:41 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-64384c6797eso995545b3a.2 for ; Thu, 04 May 2023 15:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238534; x=1685830534; 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=RCs/9iBvrEyNVZzCTd/A2GImby0Xt44Wx/SBN2PNOfk=; b=oDB8u/9LgZXTgfCbjSWldZ8zjTY8Hxa2hGJSeLMG4PHF6mKOyi8FbO3jLxusmGF0cQ afxWbKqAVpaGKTTc1cRHpYz45IHwPP4EFUDxE9jllcihicq1oXwWm5EFpEeyS4LQQXP9 it00pvupIn6NVZAAmhwrwR73a1tsmKRuebldI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238534; x=1685830534; 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=RCs/9iBvrEyNVZzCTd/A2GImby0Xt44Wx/SBN2PNOfk=; b=cfvVlJve92ic0CN7GqOjEXr+GIrYhuBUaIHDqt2H6u3gEOnux80nTA5rAGZi+Ux8Eo d0BRg1NoSbkiidAITsW4oETZIAiiO3aiTnWihWVuPyqPxiXyhDb8OYBN1t4LPPGc+8Fv uaV6U4/ONpU724ql50yCYOJCNbjj+rWLhe8mwOYpPEQKVEBRSWPItXIjQ6ShQLymMycV ksVdhMWMK3CaQ7RdAozHWiMP4tshEbHJEPz6jLumA0XkqmIoCpu9Sn9RHjO9WMQ/fyIg mLb6fgmbhIcBOkg03FbpOHacM1RH7FBxCiXn7BUGXc0RQ+7Tffz/cn6CgCFPkN+nORRJ bLsQ== X-Gm-Message-State: AC+VfDyzaOm3plvIVMxBAPwlg2UtQkzVb6q9Hysqhw2gq1y4y5+xxhPV NJOa6n5uSSN9N2WgIPIkb1hFtg== X-Google-Smtp-Source: ACHHUZ4bjw0v8Xh/Woiy1NQGEjRjWjT2i7Xc46n+u6XewoR1B1k66XrwvIaSaiBkKMffZjH8lkWATQ== X-Received: by 2002:a05:6a00:c94:b0:643:cb0:2bbe with SMTP id a20-20020a056a000c9400b006430cb02bbemr4970419pfv.15.1683238534258; Thu, 04 May 2023 15:15:34 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:33 -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 16/17] arm64: add hw_nmi_get_sample_period for preparation of lockup detector Date: Thu, 4 May 2023 15:13:48 -0700 Message-ID: <20230504151100.v4.16.Ia9d02578e89c3f44d3cb12eec8b0176603c8ab2f@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_231539_243053_F7BA9833 X-CRM114-Status: GOOD ( 21.75 ) 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 From: Lecopzer Chen Set safe maximum CPU frequency to 5 GHz in case a particular platform doesn't implement cpufreq driver. Although, architecture doesn't put any restrictions on maximum frequency but 5 GHz seems to be safe maximum given the available Arm CPUs in the market which are clocked much less than 5 GHz. On the other hand, we can't make it much higher as it would lead to a large hard-lockup detection timeout on parts which are running slower (eg. 1GHz on Developerbox) and doesn't possess a cpufreq driver. Co-developed-by: Sumit Garg Signed-off-by: Sumit Garg Co-developed-by: Pingfan Liu Signed-off-by: Pingfan Liu Signed-off-by: Lecopzer Chen Signed-off-by: Douglas Anderson --- I yanked this patch from the mailing lists [1] into my series just to make it easier to avoid conflicts between my series and the one adding the arm64 perf hardlockup detector, in case someone wanted to test them both together. The only change I made here was to remove an extra blank line that checkpatch complained about. As mentioned in the cover letter, I'm not really expecting this patch to land together with the patches for the buddy detector. I included it with my series simply for convenience of testing both series together. NOTE: the previous patch posted by Lecopzer pointed to Sumit's patch [2] in the commit text but provided no context. I moved it to this "after the cut" note. [1] https://lore.kernel.org/r/20220903093415.15850-6-lecopzer.chen@mediatek.com/ [2] http://lore.kernel.org/linux-arm-kernel/1610712101-14929-1-git-send-email-sumit.garg@linaro.org Changes in v4: - Pulled ("add hw_nmi_get_sample_period for ...") into my series for v4. arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/watchdog_hld.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 arch/arm64/kernel/watchdog_hld.c diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index ceba6792f5b3..f8e2645406a4 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o +obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_CPU_PM) += sleep.o suspend.o obj-$(CONFIG_CPU_IDLE) += cpuidle.o diff --git a/arch/arm64/kernel/watchdog_hld.c b/arch/arm64/kernel/watchdog_hld.c new file mode 100644 index 000000000000..2401eb1b7e55 --- /dev/null +++ b/arch/arm64/kernel/watchdog_hld.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +/* + * Safe maximum CPU frequency in case a particular platform doesn't implement + * cpufreq driver. Although, architecture doesn't put any restrictions on + * maximum frequency but 5 GHz seems to be safe maximum given the available + * Arm CPUs in the market which are clocked much less than 5 GHz. On the other + * hand, we can't make it much higher as it would lead to a large hard-lockup + * detection timeout on parts which are running slower (eg. 1GHz on + * Developerbox) and doesn't possess a cpufreq driver. + */ +#define SAFE_MAX_CPU_FREQ 5000000000UL // 5 GHz +u64 hw_nmi_get_sample_period(int watchdog_thresh) +{ + unsigned int cpu = smp_processor_id(); + unsigned long max_cpu_freq; + + max_cpu_freq = cpufreq_get_hw_max_freq(cpu) * 1000UL; + if (!max_cpu_freq) + max_cpu_freq = SAFE_MAX_CPU_FREQ; + + return (u64)max_cpu_freq * watchdog_thresh; +} From patchwork Thu May 4 22:13:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13231883 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 383BBC77B73 for ; Thu, 4 May 2023 22:17:24 +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=uSb/Cx4oADh+9jM/v9ZrVX2YRXX3brDP5lLDiJXNcao=; b=IsVOy+N+Og01k+ ZCyliE/hcx/stAxfuGYT+SICpR3uP/ZFcfV57iKOUBsbi2zG1/qt8bkiqSJHSVxKlxPg6GQeJu2da mhOQIsZQS1srO3MTDs1UG7oHmO4l7waJk9rNQ51cgZju11YVh6/xIV8lkNHaXDDBoWprL/2tBqIo8 SzoVyg4lc36wuFHCs2sk32FUsl2ZkpOndNmDU18544h0b+nIvEX+n2tGJ7MXAfTnr3iRBweySW6LI JNev+CtwO4IOXH2TzPezuvJu2FYLOtbaH2b+ih8MHevAp2w7c5Xo2fKB34veD/L8pAHC6o3BRy8pV EairvstQVF3p0WMMSxlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1puhEo-009Amu-22; Thu, 04 May 2023 22:15:46 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1puhEj-009AjH-2U for linux-arm-kernel@lists.infradead.org; Thu, 04 May 2023 22:15:45 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-63b5ce4f069so1213454b3a.1 for ; Thu, 04 May 2023 15:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683238537; x=1685830537; 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=Rx1vfeyE3TRvVHLtc8wjeQXsVXDN6U5WvEYHnvnsZiQ=; b=GrXsJ9B6lpVddvHVF4LE//sAxHKEwPqS+Lrmy5FZm5C+BBxcMf/KBnQ2Kz0ToqXupC stkOTuW3TG4O8WK+889znwTdd4mpmXVLRAtVy4QbnUMBEfL9e2VkXE8ZF2uB8RqfGrwM V5WHNLrECfzPUJD69+fwMyXpFWfAfGK902akM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683238537; x=1685830537; 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=Rx1vfeyE3TRvVHLtc8wjeQXsVXDN6U5WvEYHnvnsZiQ=; b=EXRmJCft5hN4MIjLbHgqzNiW5TamXdy0Q9fNNBBIz5YZxmKK/J1vo+DTQn/eYSeNS9 9ENAMucDjzgKoUB0woO830ozS5HdjaI6vEgEoPeOUiSyhTsqodOLU4ukCjFcfY8Vd5cz 0K5qdCG0UxkSXykAI97F+8sTRmpTYfVau1dOt5M3rghCZEz7M7AzuHfSJdWmPCkXjbih QUBXvtkjbHTiz7hFtFp6aQ81jMyi8qdUuxADZY/kDkvDJAcDKGNZMfgeg/PahD6aRGgj 9Fx3gGDRE6FkkhlYGMNBliMeYKf6yeZW/RcaGXpn1mie0dAe9QCQExSVSN9d6gWru55Y 1ocA== X-Gm-Message-State: AC+VfDwrHBckcXAt+O9ftnf8shURi76XrHs8kqCrV8o4rv6uTRps52// 3weRqGo14CkvQAWS7DaIfgL7Jg== X-Google-Smtp-Source: ACHHUZ5OyqHQkkk5eV4OQnbvYXBWIDTEw9i7oDzC+q4tZkWV0tXI752A7bILgADyxN7Wq0liTZgOEg== X-Received: by 2002:a05:6a00:23d0:b0:639:9089:798e with SMTP id g16-20020a056a0023d000b006399089798emr4377726pfc.19.1683238537495; Thu, 04 May 2023 15:15:37 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 15:15:36 -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 17/17] arm64: Enable perf events based hard lockup detector Date: Thu, 4 May 2023 15:13:49 -0700 Message-ID: <20230504151100.v4.17.Ia44852044cdcb074f387e80df6b45e892965d4a1@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_151541_811649_0F843B58 X-CRM114-Status: GOOD ( 28.88 ) 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 With the recent feature added to enable perf events to use pseudo NMIs as interrupts on platforms which support GICv3 or later, its now been possible to enable hard lockup detector (or NMI watchdog) on arm64 platforms. So enable corresponding support. One thing to note here is that normally lockup detector is initialized just after the early initcalls but PMU on arm64 comes up much later as device_initcall(). To cope with that, override arch_perf_nmi_is_available() to let the watchdog framework know PMU not ready, and inform the framework to re-initialize lockup detection once PMU has been initialized. Co-developed-by: Sumit Garg Signed-off-by: Sumit Garg Co-developed-by: Pingfan Liu Signed-off-by: Pingfan Liu Signed-off-by: Lecopzer Chen Signed-off-by: Douglas Anderson --- I yanked this patch from the mailing lists [1] into my series just to make it easier to avoid conflicts between my series and the one adding the arm64 perf hardlockup detector, in case someone wanted to test them both together. As part of making this match with my series, I needed to resolve conflicts with the patch ("watchdog/hardlockup: Have the perf hardlockup use __weak functions more cleanly"). This makes ${SUBJECT} patch now depend on the patch ("watchdog/perf: Add a weak function for an arch to detect if perf can use NMIs"). As talked about in that patch, there may be better alternatives to accomplish the same thing. As mentioned in the cover letter, I'm not really expecting this patch to land together with the patches for the buddy detector. I included it with my series simply for convenience of testing both series together. NOTE: the previous patch posted by Lecopzer pointed to Sumit's patch [2] in the commit text but provided no context. I moved it to this "after the cut" note. [1] https://lore.kernel.org/r/20220903093415.15850-7-lecopzer.chen@mediatek.com/ [2] http://lore.kernel.org/linux-arm-kernel/1610712101-14929-1-git-send-email-sumit.garg@linaro.org Changes in v4: - Pulled ("Enable perf events based hard ...") into my series for v4. arch/arm64/Kconfig | 2 ++ arch/arm64/kernel/perf_event.c | 12 ++++++++++-- arch/arm64/kernel/watchdog_hld.c | 12 ++++++++++++ drivers/perf/arm_pmu.c | 5 +++++ include/linux/perf/arm_pmu.h | 2 ++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 1023e896d46b..4ee9f3a7bc7a 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -197,12 +197,14 @@ config ARM64 select HAVE_FUNCTION_ERROR_INJECTION select HAVE_FUNCTION_GRAPH_TRACER select HAVE_GCC_PLUGINS + select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI select HAVE_HW_BREAKPOINT if PERF_EVENTS select HAVE_IOREMAP_PROT select HAVE_IRQ_TIME_ACCOUNTING select HAVE_KVM select HAVE_NMI select HAVE_PERF_EVENTS + select HAVE_PERF_EVENTS_NMI if ARM64_PSEUDO_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_PREEMPT_DYNAMIC_KEY diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index dde06c0f97f3..732bc5d76cb1 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -23,6 +23,7 @@ #include #include #include +#include /* ARMv8 Cortex-A53 specific event types. */ #define ARMV8_A53_PERFCTR_PREF_LINEFILL 0xC2 @@ -1396,10 +1397,17 @@ static struct platform_driver armv8_pmu_driver = { static int __init armv8_pmu_driver_init(void) { + int ret; + if (acpi_disabled) - return platform_driver_register(&armv8_pmu_driver); + ret = platform_driver_register(&armv8_pmu_driver); else - return arm_pmu_acpi_probe(armv8_pmuv3_pmu_init); + ret = arm_pmu_acpi_probe(armv8_pmuv3_pmu_init); + + if (!ret) + lockup_detector_retry_init(); + + return ret; } device_initcall(armv8_pmu_driver_init) diff --git a/arch/arm64/kernel/watchdog_hld.c b/arch/arm64/kernel/watchdog_hld.c index 2401eb1b7e55..dcd25322127c 100644 --- a/arch/arm64/kernel/watchdog_hld.c +++ b/arch/arm64/kernel/watchdog_hld.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include +#include /* * Safe maximum CPU frequency in case a particular platform doesn't implement @@ -22,3 +24,13 @@ 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/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 15bd1e34a88e..7b9caa502d33 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -687,6 +687,11 @@ static int armpmu_get_cpu_irq(struct arm_pmu *pmu, int cpu) return per_cpu(hw_events->irq, cpu); } +bool arm_pmu_irq_is_nmi(void) +{ + return has_nmi; +} + /* * PMU hardware loses all context when a CPU goes offline. * When a CPU is hotplugged back in, since some hardware registers are diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 525b5d64e394..5b00f5cb4cf9 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -171,6 +171,8 @@ 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);