From patchwork Thu Jun 1 21:31: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: 102200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp627980vqr; Thu, 1 Jun 2023 14:39:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CwUnNvJZV8/jE7XTi8vVA7qNATrBwl2oH/HdTxigcVPnD0sslgtthD+xrl5dBG31lx5EM X-Received: by 2002:a05:6358:9103:b0:125:9f49:b1b9 with SMTP id q3-20020a056358910300b001259f49b1b9mr6665285rwq.12.1685655547616; Thu, 01 Jun 2023 14:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685655547; cv=none; d=google.com; s=arc-20160816; b=dik11NMD2KSKf2jpMpKgXOyhNM2uVvStXGPiPD2jm9Kc2tkAdEse/whq4Beudmx+4x HBQpY+D+rZzfEf3Y7vAhv8Ty+Ld1FqcOKxkIPJudJ+yfqQf/MI89QzYn1+tyT1Bm8NfD Hff4VKeGL4ZRVWXF9LaqW5FZeMRpfcdEvlGMgcNYAkjDSHi55rTvdoYwoFmcklYTNwag DdaZ76h8baj6IoRyZmeAWGAnW71TCAASZlYeRoMRkZPI9ztkuglrQx6y9B1QcYifQJv0 fjewdfqz3sGg6pPf5exxKDg5wMut8WV//4qHtIUu8gaIgb4AhhloWnVBnAkUeDTKWG7D JWug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HjRakdb30yszASmxf/wTOyUnLRsbS0tBSqMyHI/mgmg=; b=GTzEjiEfP/k5Zxm7T9TTCt9KO24Y4uF7+8kQL0o03g/mPrJfkoNRRaOcSQ8pZ7uanv rGWMczC8naDozTp4uayDC8iHC1/flv/gYSpPtBFmrt5f2hlVHs0IfrvpeEGrty2qJ+ss +Xe1iFkdFeQhph+bGr5qzDfXcqOUjGvVEkqZth3hNfW0Fk/DKLRwU6u6F6V9q1LchvoZ lX0WHIUtKsXc3526zQ2TTBiT2pGJfcRBKq2WEPedOdCMpby2K7xR/6dGUVVjTjvc5Qfl b2NITHietHB85bZ+1rDLHnF1EBQ3F228pwFKOtz/3P7Yigab1x8tBMQ/ji/B8vZkj5yH SzSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BuG16Cgs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i189-20020a639dc6000000b0053fb3c97be6si3349518pgd.838.2023.06.01.14.38.56; Thu, 01 Jun 2023 14:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BuG16Cgs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232809AbjFAVhM (ORCPT + 99 others); Thu, 1 Jun 2023 17:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232401AbjFAVhJ (ORCPT ); Thu, 1 Jun 2023 17:37:09 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB6E19B for ; Thu, 1 Jun 2023 14:37:08 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-65292f79456so414788b3a.2 for ; Thu, 01 Jun 2023 14:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655427; x=1688247427; 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=HjRakdb30yszASmxf/wTOyUnLRsbS0tBSqMyHI/mgmg=; b=BuG16CgsJZuRqklwqhtraGtO9mDBkjKRduhSYXiCHYmDshIggjlraGD2H9A4z6yorm wBu2dEQorFkxnRHLq3Cn+M+LkZWex3ajMYBEgSEujM238OkqShSG0aa2MrkveBlrCXC5 p6NW7FtAcuIScDFj5KSELcmbgvEEVbSabk3PI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655427; x=1688247427; 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=HjRakdb30yszASmxf/wTOyUnLRsbS0tBSqMyHI/mgmg=; b=i9Kd6y9nYYJi94gxAISYewPWIy5HSmm33S2QV8Q3RLEzO7lWH4Yrbn2BtQdXshMOwH +KAb9zHKYqSwyIG1jlkCvLnPbPNGRi09ixmjsR8c1xDpNl2RchKA9zAxqVrgJpfNgaoG 1HttAbunsSW6bXL0Enn/F28/1jYPkf2DmnGAqKVVT4uesfuG/hQsnf94hOrW3CJznI+y g+hvpa3yrH8oaaH0qpDtmrR1OzZpXAWCKEkaTu9jeHnk/wkSuda9ldJ4rBv5kp2o7hod 47+V9+D5YmQuK1WzYHqW72auoUda+dS79TKnLa0fcjyGb9RFSL2ACLZ1xvT7nmJl8okn Ccug== X-Gm-Message-State: AC+VfDzSANHt6dZc74+pkklc4rBd9gyJXwvuNicZK6ePs8/hKHSGOuKu FLR5OR3k7tngwyQrCkiiO8DkLW3Y0IzUkvOpLgs= X-Received: by 2002:a05:6a21:1647:b0:111:6a14:7d0 with SMTP id no7-20020a056a21164700b001116a1407d0mr6606398pzb.60.1685655427621; Thu, 01 Jun 2023 14:37:07 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:11b8:2d2:7e02:6bff]) by smtp.gmail.com with ESMTPSA id g22-20020aa78756000000b0064d48d98260sm5319534pfo.156.2023.06.01.14.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:07 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Masayoshi Mizuma , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v9 1/7] irqchip/gic-v3: Enable support for SGIs to act as NMIs Date: Thu, 1 Jun 2023 14:31:45 -0700 Message-ID: <20230601143109.v9.1.I1223c11c88937bd0cbd9b086d4ef216985797302@changeid> X-Mailer: git-send-email 2.41.0.rc2.161.g9c6817b8e7-goog In-Reply-To: <20230601213440.2488667-1-dianders@chromium.org> References: <20230601213440.2488667-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767537951345052849?= X-GMAIL-MSGID: =?utf-8?q?1767537951345052849?= From: Sumit Garg Add support to handle SGIs as pseudo NMIs. As SGIs or IPIs default to a special flow handler: handle_percpu_devid_fasteoi_ipi(), so skip NMI handler update in case of SGIs. Also, enable NMI support prior to gic_smp_init() as allocation of SGIs as IRQs/NMIs happen as part of this routine. Signed-off-by: Sumit Garg Reviewed-by: Masayoshi Mizuma Tested-by: Chen-Yu Tsai Signed-off-by: Douglas Anderson --- (no changes since v1) drivers/irqchip/irq-gic-v3.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 0c6c1af9a5b7..ed37e02d4c5f 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -525,6 +525,7 @@ static u32 gic_get_ppi_index(struct irq_data *d) static int gic_irq_nmi_setup(struct irq_data *d) { struct irq_desc *desc = irq_to_desc(d->irq); + u32 idx; if (!gic_supports_nmi()) return -EINVAL; @@ -542,16 +543,22 @@ static int gic_irq_nmi_setup(struct irq_data *d) return -EINVAL; /* desc lock should already be held */ - if (gic_irq_in_rdist(d)) { - u32 idx = gic_get_ppi_index(d); + switch (get_intid_range(d)) { + case SGI_RANGE: + break; + case PPI_RANGE: + case EPPI_RANGE: + idx = gic_get_ppi_index(d); /* Setting up PPI as NMI, only switch handler for first NMI */ if (!refcount_inc_not_zero(&ppi_nmi_refs[idx])) { refcount_set(&ppi_nmi_refs[idx], 1); desc->handle_irq = handle_percpu_devid_fasteoi_nmi; } - } else { + break; + default: desc->handle_irq = handle_fasteoi_nmi; + break; } gic_irq_set_prio(d, GICD_INT_NMI_PRI); @@ -562,6 +569,7 @@ static int gic_irq_nmi_setup(struct irq_data *d) static void gic_irq_nmi_teardown(struct irq_data *d) { struct irq_desc *desc = irq_to_desc(d->irq); + u32 idx; if (WARN_ON(!gic_supports_nmi())) return; @@ -579,14 +587,20 @@ static void gic_irq_nmi_teardown(struct irq_data *d) return; /* desc lock should already be held */ - if (gic_irq_in_rdist(d)) { - u32 idx = gic_get_ppi_index(d); + switch (get_intid_range(d)) { + case SGI_RANGE: + break; + case PPI_RANGE: + case EPPI_RANGE: + idx = gic_get_ppi_index(d); /* Tearing down NMI, only switch handler for last NMI */ if (refcount_dec_and_test(&ppi_nmi_refs[idx])) desc->handle_irq = handle_percpu_devid_irq; - } else { + break; + default: desc->handle_irq = handle_fasteoi_irq; + break; } gic_irq_set_prio(d, GICD_INT_DEF_PRI); @@ -2001,6 +2015,7 @@ static int __init gic_init_bases(phys_addr_t dist_phys_base, gic_dist_init(); gic_cpu_init(); + gic_enable_nmi_support(); gic_smp_init(); gic_cpu_pm_init(); @@ -2013,8 +2028,6 @@ static int __init gic_init_bases(phys_addr_t dist_phys_base, gicv2m_init(handle, gic_data.domain); } - gic_enable_nmi_support(); - return 0; out_free: From patchwork Thu Jun 1 21:31: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: 102201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp628000vqr; Thu, 1 Jun 2023 14:39:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MssjKlUP6z61V3b2JuJClkvsSTOhOM9AEHnpzdq/jhZGWGfACaSgCRPkHRP5Lwk7DmAHh X-Received: by 2002:a17:902:860c:b0:1ac:8ad0:1707 with SMTP id f12-20020a170902860c00b001ac8ad01707mr708350plo.1.1685655552125; Thu, 01 Jun 2023 14:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685655552; cv=none; d=google.com; s=arc-20160816; b=w8g9fQKTSy3vaMCKmxiKgidoHmY+PYHIk1k3QME6jGmTtqqqDVp4ZtSrp7905mya9r 1Yu/4eGXGBaCVgEWKiVCfHxp9Xfrtxr4bEq1EeaoIvsj+ZsXkakazxdJGMzh+7e/F3Sa CVtG+7mklfi4hNRSar+1ADxwFjGGxz++RJxERoMJ+FHmqFB7KIjJsbRPdklY2dxmDXWq Uy0uzEp1XW9E+hNFzYjhGQOZNJ9Z2/UWAI4c4rpYLY2sh2VK2iUBcm/t7Pl0XI9li6oF gFEzuV85CkBaKwqcTQ/DVSfeLgdNagYeaAgWeJr//+zxQvFlZ5fmvgPaIaKoV3kb8Ros 6Fhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3FwIy9pdxSPLLDGVrHowuSMAgkehvs21QOIs4DuKC6A=; b=clq24pAhnctfZ8KHyx/3wy6SUTSC12vuFKtBJZWZSP+c/sAAecipmFZsem+iXcIf8Y dfkQ4++YfkcW7tdSDIwLeeKlK8AmF+tdO4WGWJ9R/oodTGy5/70GMz2HoNyTGVw3E/hW ymCC74U/m88hW6MVo7M8oh+i8O/2ZjWpdCfmOO2jtRGovd4JheUTocCpQtLaI6/PsyBt U3QUQcjvROapmcWwhw/1pFC8Skv3KxzNTbgPzbWMVLdnkvO7qNnS45Kn4yO/K5TIz/As B/aaHhnXJiqcX4gj/1wOFuAYAlbWt5kLhWJTBC3Q6yaq7oOtVMn8EOM0NqSffzHWFZSO ZTvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MRdCoSuj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020a170903124e00b001a2a4eb10d6si3502485plh.58.2023.06.01.14.38.59; Thu, 01 Jun 2023 14:39:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MRdCoSuj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbjFAVhP (ORCPT + 99 others); Thu, 1 Jun 2023 17:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbjFAVhL (ORCPT ); Thu, 1 Jun 2023 17:37:11 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5248C184 for ; Thu, 1 Jun 2023 14:37:10 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-651ffcc1d3dso610747b3a.3 for ; Thu, 01 Jun 2023 14:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655430; x=1688247430; 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=3FwIy9pdxSPLLDGVrHowuSMAgkehvs21QOIs4DuKC6A=; b=MRdCoSujmCnjjOacpNHectteICFpfTy0Q7HRW6iFcJoXa0fZhuuEBFYooU/G8NXg2X HfAG3gvX2a17Cc1yGXHsw3CBdxIMjz24Xa8DvLZVxCCds24Mumi4TVNGg8ZmNyV/Svls MmHnVj0glIpRBoHcvAP9y7A/SWAwUDBE3yhk0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655430; x=1688247430; 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=3FwIy9pdxSPLLDGVrHowuSMAgkehvs21QOIs4DuKC6A=; b=cAZxwfcXAFllZAtAnINbZeBM6rvIcq8m+s+rrAgWZ+cAKdOhgeohUKyt4iXmliuLwu didABgGHCEMXSnV9lC3ykbcUdG15B7hFbqL83SzZPJ4jRbDlVL894JOeGQNGa8yaoNiF IJ24NzKU+Rzv4mr/A2G7pNLIEIVIA0oDQxKb41Oe5Ocph+d3dVWpUf/N6MTUieigQ44p /2zQauZc5SWJVvmPfaVB4dmbqgHvHnLXlnINWqE28ZwMZVXJLKb8JBgsG2tUlAf467qC uRFM9Ty1mIaldepxyGD91Y+Xu0N6xukC8nUBjGS5NVUL3wGS6sdTJSb2TVDmI1LWVcG/ 0vpg== X-Gm-Message-State: AC+VfDwgIpj1Fo+P8VbMvSuQNCgvm0cg6tGW2tEo5osxAzeBnktbjTBZ WjMNiuU6a0W33YWhBIn3zIE1qw== X-Received: by 2002:a05:6a20:2451:b0:106:c9b7:c92f with SMTP id t17-20020a056a20245100b00106c9b7c92fmr8938270pzc.49.1685655429931; Thu, 01 Jun 2023 14:37:09 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:11b8:2d2:7e02:6bff]) by smtp.gmail.com with ESMTPSA id g22-20020aa78756000000b0064d48d98260sm5319534pfo.156.2023.06.01.14.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:09 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Douglas Anderson , Frederic Weisbecker , "Gautham R. Shenoy" , Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH v9 2/7] arm64: idle: Tag the arm64 idle functions as __cpuidle Date: Thu, 1 Jun 2023 14:31:46 -0700 Message-ID: <20230601143109.v9.2.I4baba13e220bdd24d11400c67f137c35f07f82c7@changeid> X-Mailer: git-send-email 2.41.0.rc2.161.g9c6817b8e7-goog In-Reply-To: <20230601213440.2488667-1-dianders@chromium.org> References: <20230601213440.2488667-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767537956396497283?= X-GMAIL-MSGID: =?utf-8?q?1767537956396497283?= As per the (somewhat recent) comment before the definition of `__cpuidle`, the tag is like `noinstr` but also marks a function so it can be identified by cpu_in_idle(). Let'a add this. After doing this then when we dump stack traces of all processors using nmi_cpu_backtrace() then instead of getting useless backtraces we get things like: NMI backtrace for cpu N skipped: idling at cpu_do_idle+0x94/0x98 NOTE: this patch won't make cpu_in_idle() work perfectly for arm64, but it doesn't hurt and does catch some cases. Specifically an example that wasn't caught in my testing looked like this: gic_cpu_sys_reg_init+0x1f8/0x314 gic_cpu_pm_notifier+0x40/0x78 raw_notifier_call_chain+0x5c/0x134 cpu_pm_notify+0x38/0x64 cpu_pm_exit+0x20/0x2c psci_enter_idle_state+0x48/0x70 cpuidle_enter_state+0xb8/0x260 cpuidle_enter+0x44/0x5c do_idle+0x188/0x30c Signed-off-by: Douglas Anderson Acked-by: Mark Rutland --- Changes in v9: - Added to commit message that this doesn't catch all cases. Changes in v8: - "Tag the arm64 idle functions as __cpuidle" new for v8 arch/arm64/kernel/idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/idle.c b/arch/arm64/kernel/idle.c index c1125753fe9b..05cfb347ec26 100644 --- a/arch/arm64/kernel/idle.c +++ b/arch/arm64/kernel/idle.c @@ -20,7 +20,7 @@ * ensure that interrupts are not masked at the PMR (because the core will * not wake up if we block the wake up signal in the interrupt controller). */ -void noinstr cpu_do_idle(void) +void __cpuidle cpu_do_idle(void) { struct arm_cpuidle_irq_context context; @@ -35,7 +35,7 @@ void noinstr cpu_do_idle(void) /* * This is our default idle handler. */ -void noinstr arch_cpu_idle(void) +void __cpuidle arch_cpu_idle(void) { /* * This should do all the clock switching and wait for interrupt From patchwork Thu Jun 1 21:31: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: 102210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp633842vqr; Thu, 1 Jun 2023 14:53:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5WmVju2v0UCF2Ut33WPqmwgdPGbUjB1/SkvgNZZqbS2IoLFeOfTMfGKk6/oMzMKcoiwpKd X-Received: by 2002:a17:902:c202:b0:1af:e999:a070 with SMTP id 2-20020a170902c20200b001afe999a070mr616005pll.14.1685656383439; Thu, 01 Jun 2023 14:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685656383; cv=none; d=google.com; s=arc-20160816; b=JfOizbb5hrEQWhnWI8fya/Tf63fmX3Fdvy7RtZWaUPHBeqq3n2HRnHZHHkqkkR0iF3 yizbuj1o5hUZ7qBpfh0occXM2P6n+lWf73P+TDEzNQGsJ3loYJUzaQ5jaAZcuqnsAarm aRd0h5J1pI4DxK5cp9CcFivPgXoI9y6rTYbZkV4ksqcjEUMIUVNrayXawKPY+GljM9is 62cuzQDRucMskmcdK2uPGEZnqrhcRINZjyutJjoi2GU9NH+8IQ5ip5S32VGqBRK+3eCU CutA75RsvkTjlVUroV74rXOdsIf7sMM92MlXbbNFzgL9DX6iwQUcek5FpbEanW4nj1OD 5sXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VxngL/nWZ9CvmSVXwg8pkM18NqkUW/hq6cWY9xHbU50=; b=09jAg3fugRdeobtrA7qAY+lqlxs4s5sUVlPPARpMsK5aExTCQSEwIYghC4Ncvfqxw2 LWJYOb+w0nIFGuxa/DLIFVwWqv60B3zfdRJXW6ddJ4Ui9K5E/E1ZdrrtMCtyAEqRAkuW f1mlvNvVt8VoIEJeWXHXoJda/mcaEojEDNYHnYjNJ31JcWBCY1xT9gMw+s8y589cXNEY 8rDifwmSdrtb8pVStO/4fzEZJnzjYPHZ8BRmv/kYd6lGHdSa//AX2cjP8Ht5QMMTQH0t 8ZvR46g0xzvgYwYiY2BjYTEnOjwX46eqQPdnDYLeNiotJ8qqD5qmjXolfBlLZa+g3MPJ /uIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aXtBMJsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020a170902bcc700b001a988a09b6esi3323907pls.252.2023.06.01.14.52.51; Thu, 01 Jun 2023 14:53:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aXtBMJsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232904AbjFAVhU (ORCPT + 99 others); Thu, 1 Jun 2023 17:37:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232836AbjFAVhO (ORCPT ); Thu, 1 Jun 2023 17:37:14 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC6DA19B for ; Thu, 1 Jun 2023 14:37:12 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-652a6cf1918so294693b3a.1 for ; Thu, 01 Jun 2023 14:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655432; x=1688247432; 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=VxngL/nWZ9CvmSVXwg8pkM18NqkUW/hq6cWY9xHbU50=; b=aXtBMJsuEHVcZIKV7cLRpp9gJah5t0XCzX6mPhaAfDBP1dJ5ow0nIMbyHBqXyExXs/ iONAnH757E2JdGKhPAJpJ0T+0at+owiwzn2oTUIqycF0fDPlNwbji/qaAjIXJsOAh/DF EzBp3VrZJfcftxuQAMYGMNArokNyBuLgHVwN8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655432; x=1688247432; 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=VxngL/nWZ9CvmSVXwg8pkM18NqkUW/hq6cWY9xHbU50=; b=SVQn6hBXGRfOonl/DPD7pkHCOaHdr7rPI+wxrCXo7vDj31hsNhbyc9nfrBzAx/gOOv fqZO1sgOOhamnc0Ab2YNSk7yszxUPfivagUr+frPJp1BjIkTirlCDHfFhRuDGbnsR3aS +5dRzDkEbNXoQI+oxI9dRJqLqUnqeTHeD9ch/f0aQzcxP/fU8ns61J2aTQNeSEri14aj EGATVzpGp989JXfB5CHggcRfNZlWzfX6Eu+fGfbPf/IxW024pWd2Rox++FNiX6AM0/E3 UtAKC4yqstTUYBnqgX0c+49pOjRyfNETnnqjQg6vSNomFYKhUtVrOS49pDMFXZ0PUReH 9wkw== X-Gm-Message-State: AC+VfDzgqjB8lS2ll9UGf82A1jcikuEanH/pzz1t/vPnYGk+Mmr8e6b1 4cxNxjYVnT5VQmGj4djmNlbDgw== X-Received: by 2002:a05:6a00:8ca:b0:64c:b45f:fc86 with SMTP id s10-20020a056a0008ca00b0064cb45ffc86mr10767019pfu.17.1685655432123; Thu, 01 Jun 2023 14:37:12 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:11b8:2d2:7e02:6bff]) by smtp.gmail.com with ESMTPSA id g22-20020aa78756000000b0064d48d98260sm5319534pfo.156.2023.06.01.14.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:11 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Douglas Anderson , Andrey Konovalov , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v9 3/7] arm64: Add framework for a debug IPI Date: Thu, 1 Jun 2023 14:31:47 -0700 Message-ID: <20230601143109.v9.3.Ie6c132b96ebbbcddbf6954b9469ed40a6960343c@changeid> X-Mailer: git-send-email 2.41.0.rc2.161.g9c6817b8e7-goog In-Reply-To: <20230601213440.2488667-1-dianders@chromium.org> References: <20230601213440.2488667-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767538827666629328?= X-GMAIL-MSGID: =?utf-8?q?1767538827666629328?= From: Sumit Garg Introduce a framework for an IPI that will be used for debug purposes. The primary use case of this IPI will be to generate stack crawls on other CPUs, but it will also be used to round up CPUs for kgdb. When possible, we try to allocate this debug IPI as an NMI (or a pseudo NMI). If that fails (due to CONFIG, an incompatible interrupt controller, a quirk, missing the "irqchip.gicv3_pseudo_nmi=1" kernel parameter, etc) we fall back to a normal IPI. NOTE: hooking this up for CPU backtrace / kgdb will happen in a future patch, this just adds the framework. Signed-off-by: Sumit Garg Signed-off-by: Douglas Anderson Signed-off-by: Mark Rutland --- I didn't get any feedback from v8 patch #10 [1], but I went ahead and folded it in here anyway since it really simplfies things. If people don't like the fallback to regular IPI, I can also undo it. [1] https://lore.kernel.org/r/20230419155341.v8.10.Ic3659997d6243139d0522fc3afcdfd88d7a5f030@changeid/ Changes in v9: - Fold in v8 patch #10 ("Fallback to a regular IPI if NMI isn't enabled") - Moved header file out of "include" since it didn't need to be there. - Remove arm64_supports_nmi() - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. Changes in v8: - debug_ipi_setup() and debug_ipi_teardown() no longer take cpu param arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/ipi_debug.c | 76 +++++++++++++++++++++++++++++++++++ arch/arm64/kernel/ipi_debug.h | 13 ++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/kernel/ipi_debug.c create mode 100644 arch/arm64/kernel/ipi_debug.h diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index cc22011ab66a..737838f803b7 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -34,7 +34,7 @@ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ cpufeature.o alternative.o cacheinfo.o \ smp.o smp_spin_table.o topology.o smccc-call.o \ syscall.o proton-pack.o idreg-override.o idle.o \ - patching.o + patching.o ipi_debug.o obj-$(CONFIG_COMPAT) += sys32.o signal32.o \ sys_compat.o diff --git a/arch/arm64/kernel/ipi_debug.c b/arch/arm64/kernel/ipi_debug.c new file mode 100644 index 000000000000..b57833e31eaf --- /dev/null +++ b/arch/arm64/kernel/ipi_debug.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Debug IPI support + * + * Copyright (C) 2020 Linaro Limited + * Author: Sumit Garg + */ + +#include +#include +#include + +#include "ipi_debug.h" + +static struct irq_desc *ipi_debug_desc __read_mostly; +static int ipi_debug_id __read_mostly; +static bool is_nmi; + +void arm64_debug_ipi(cpumask_t *mask) +{ + if (WARN_ON_ONCE(!ipi_debug_desc)) + return; + + __ipi_send_mask(ipi_debug_desc, mask); +} + +static irqreturn_t ipi_debug_handler(int irq, void *data) +{ + /* nop, NMI handlers for special features can be added here. */ + + return IRQ_NONE; +} + +void debug_ipi_setup(void) +{ + if (!ipi_debug_desc) + return; + + if (is_nmi) { + if (!prepare_percpu_nmi(ipi_debug_id)) + enable_percpu_nmi(ipi_debug_id, IRQ_TYPE_NONE); + } else { + enable_percpu_irq(ipi_debug_id, IRQ_TYPE_NONE); + } +} + +void debug_ipi_teardown(void) +{ + if (!ipi_debug_desc) + return; + + if (is_nmi) { + disable_percpu_nmi(ipi_debug_id); + teardown_percpu_nmi(ipi_debug_id); + } else { + disable_percpu_irq(ipi_debug_id); + } +} + +void __init set_smp_debug_ipi(int ipi) +{ + int err; + + if (!request_percpu_nmi(ipi, ipi_debug_handler, "IPI", &cpu_number)) { + is_nmi = true; + } else { + err = request_percpu_irq(ipi, ipi_debug_handler, "IPI", &cpu_number); + if (WARN_ON(err)) + return; + + irq_set_status_flags(ipi, IRQ_HIDDEN); + } + + ipi_debug_desc = irq_to_desc(ipi); + ipi_debug_id = ipi; +} diff --git a/arch/arm64/kernel/ipi_debug.h b/arch/arm64/kernel/ipi_debug.h new file mode 100644 index 000000000000..f6011a09282f --- /dev/null +++ b/arch/arm64/kernel/ipi_debug.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_NMI_H +#define __ASM_NMI_H + +#include + +void arm64_debug_ipi(cpumask_t *mask); + +void set_smp_debug_ipi(int ipi); +void debug_ipi_setup(void); +void debug_ipi_teardown(void); + +#endif From patchwork Thu Jun 1 21:31: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: 102208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp632455vqr; Thu, 1 Jun 2023 14:49:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bMnPTmbF8O0kpdjozOqzrMJSMJzer4WvxweR44ik3sHM+d6qx7rVasqPuHutWeAIePO5s X-Received: by 2002:a17:90b:80d:b0:255:b07a:3d55 with SMTP id bk13-20020a17090b080d00b00255b07a3d55mr569747pjb.28.1685656172941; Thu, 01 Jun 2023 14:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685656172; cv=none; d=google.com; s=arc-20160816; b=yqBZ1WysUm4OX/hYUggf/VKNVHRzkyjQ3qKBKxpkWu4r9fzLCdAUWeL4XkEAxt7FxV ReP5/37BDlBRDern5EW2CxBs9vael0gSPLn0NdS5QcIAi/XNfqGGGB/ZqiETXxMthraE iYim8xxSMNg5YWRlJUzVLKFby9/YD9oJqov2muN6QlmefhCxUpje57kDXCdFouESQBqD Rmua6C6Ui8CV27M2LLoYID2ZSo0QE5eDDlUTZNHSTC4kUagRJLYyqknVzvsqFcxGEcVi +9msu+T9A5yE4dkQMiOfUiiEVDCmcDyRM1BSQ77OXhJwpmMa1W9DQZ0wmlPGPa7Ro4G5 lLEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KFbc1DnTsptgPHbVgbrtLnQoZRYq2p52Sq+V7Mil0Po=; b=jl0MAHytpd71AnbjBaWqCx2wMNP8ewzL2+n08Xixf82tm3EY+xHyXFA4Oi+KY5dSPt Bw3jwweKmSXQEvUxaq1rHx4AGbnD00adkpiAkUZTa7CXLTDVS+uKa6ersEMVQyparVKp jD+8SXd7M3q6WOgl0DdCrkMGvT3hB5nL6wHprQHiMmVGjxCfP1HvbtaMj7bCE1Ea2Tc5 4shsjnO5lhMmtnr5H5oQvEXwpiZ0RsEpFm27OvLetRG1bISAFtJWpSOl52RWa1CYhA99 faV9eT3ECnbmoLSi8mSbbssxKXyWin+qCAtv+SEOAmMuYDpK4Q2KM40q4S0aeKbZMuqK 14kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Y+IRG40L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 29-20020a17090a1a5d00b002564870bcb6si1612399pjl.183.2023.06.01.14.49.21; Thu, 01 Jun 2023 14:49:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Y+IRG40L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233066AbjFAVhc (ORCPT + 99 others); Thu, 1 Jun 2023 17:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232836AbjFAVhZ (ORCPT ); Thu, 1 Jun 2023 17:37:25 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBE9B1AB for ; Thu, 1 Jun 2023 14:37:14 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-65299178ac5so448090b3a.1 for ; Thu, 01 Jun 2023 14:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655434; x=1688247434; 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=KFbc1DnTsptgPHbVgbrtLnQoZRYq2p52Sq+V7Mil0Po=; b=Y+IRG40LZKw0u4RWejoPo9t2VThioi9WMya6GxurCgZXecIGTCiWNYFwet6YeXaBL1 s6e2+jx6ksC3geJ2joOYMSft3G8UQ2LyzodMjp70BrhkADj72DmV4KOC7eg1PWGkJS7W bhnuM4cF9tMcOEK2gfzpuj7nrcaJZqp/6IeD0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655434; x=1688247434; 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=KFbc1DnTsptgPHbVgbrtLnQoZRYq2p52Sq+V7Mil0Po=; b=IsOzw/PaQQwrkSNSPE3hnBHZKDwrzySeEAfNk5663Fqw8a7//kRDh1qxgGLTyXHETw 7uuzNVwNgAhICHWdLvlCCIFEKzvZ6kWjjfcAt+3farAgRCX55eleucI9k6cY9cMkpgD5 zDKpPOxh0oDTvdZmtlS/vlm38vY3r4wZnQEZO2DL0ynSc+IXXDYXnTLmvGFROjs5K2K2 DQ4X2gVe3jHNgmQTng0zRfGOcYzLzOdJGbkKBsfKPC/kLnHBta9j/4Xi8/hMR401vMkC LzIbEkdSokWEihWSLIkGhAJMUqhrvvfj2Uej1puFV2e56d96aTBlSlDnpSzchl/sqtSp cDpw== X-Gm-Message-State: AC+VfDzooTBsOdEyPBYwX2IEidBR5mAOaoX1Ng6lgnys7mQhNNsUoVE9 jgnOz/2iaC7xxIMYICoWGI/baA== X-Received: by 2002:a05:6a00:c89:b0:652:7b99:df30 with SMTP id a9-20020a056a000c8900b006527b99df30mr1613289pfv.25.1685655434352; Thu, 01 Jun 2023 14:37:14 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:11b8:2d2:7e02:6bff]) by smtp.gmail.com with ESMTPSA id g22-20020aa78756000000b0064d48d98260sm5319534pfo.156.2023.06.01.14.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:13 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Douglas Anderson , Ben Dooks , Ingo Molnar , Josh Poimboeuf , Valentin Schneider , linux-kernel@vger.kernel.org Subject: [PATCH v9 4/7] arm64: smp: Assign and setup the debug IPI Date: Thu, 1 Jun 2023 14:31:48 -0700 Message-ID: <20230601143109.v9.4.I6d7f7d5fa0aa293c8c3374194947254b93114d37@changeid> X-Mailer: git-send-email 2.41.0.rc2.161.g9c6817b8e7-goog In-Reply-To: <20230601213440.2488667-1-dianders@chromium.org> References: <20230601213440.2488667-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767538607185130609?= X-GMAIL-MSGID: =?utf-8?q?1767538607185130609?= From: Sumit Garg All current arm64 interrupt controllers have at least 8 IPIs. Currently we are only using 7 of them on arm64. Let's use the 8th one as a debug IPI. This uses the new "debug IPI" infrastructure which will try to allocate this IPI as an NMI/pseudo NMI if possible. Signed-off-by: Sumit Garg Signed-off-by: Douglas Anderson --- I could imagine that people object to using up the last free IPI on interrupt controllers with only 8 IPIs. However, it shouldn't be a big deal. If we later need an extra IPI, it shouldn't be too hard to combine some of the existing ones. Presumably we could just get rid of the "crash stop" IPI and have the normal "stop" IPI do the crash if "waiting_for_crash_ipi" is non-zero Changes in v9: - Add a warning if we don't have enough IPIs for the NMI IPI - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. - Update commit description Changes in v8: - debug_ipi_setup() and debug_ipi_teardown() no longer take cpu param arch/arm64/kernel/smp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index edd63894d61e..db019b49d3bd 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -53,6 +53,8 @@ #include +#include "ipi_debug.h" + DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); EXPORT_PER_CPU_SYMBOL(cpu_number); @@ -935,6 +937,8 @@ static void ipi_setup(int cpu) for (i = 0; i < nr_ipi; i++) enable_percpu_irq(ipi_irq_base + i, 0); + + debug_ipi_setup(); } #ifdef CONFIG_HOTPLUG_CPU @@ -947,6 +951,8 @@ static void ipi_teardown(int cpu) for (i = 0; i < nr_ipi; i++) disable_percpu_irq(ipi_irq_base + i); + + debug_ipi_teardown(); } #endif @@ -968,6 +974,11 @@ void __init set_smp_ipi_range(int ipi_base, int n) irq_set_status_flags(ipi_base + i, IRQ_HIDDEN); } + if (n > nr_ipi) + set_smp_debug_ipi(ipi_base + nr_ipi); + else + WARN(1, "Not enough IPIs for NMI IPI\n"); + ipi_irq_base = ipi_base; /* Setup the boot CPU immediately */ From patchwork Thu Jun 1 21:31: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: 102203 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp628729vqr; Thu, 1 Jun 2023 14:40:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+GnfLTGMiBj2r/zkQwvKYX2jxrXEtYavmJFqf5MLDmKD/OKkOJIemCXrP0zwsbMlg25b+ X-Received: by 2002:a17:902:d704:b0:1af:d724:63ed with SMTP id w4-20020a170902d70400b001afd72463edmr487882ply.42.1685655658100; Thu, 01 Jun 2023 14:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685655658; cv=none; d=google.com; s=arc-20160816; b=izawPTc8MG0yAPY04/ifw2DpbQZoJFFLkTgh2xIfzUH4PFagRnDCRaO1qs0rr/1GUQ HbkJNNmLwnAPWyVb1sor+QcXULBJFJEdytUXQFx1I8yShKtkQXZ5pTcVznCLrLYwE3Nj 9F44K9xgHS9V+h/DeTuNslTiePHe3fCpmkIQJE1g6y2SO2Tk4gSONeyFo6xqGE3nv1rT 8yxxjVlKJZGX4id0ceg/qm0cSCrI/0kpFS3ZGduHOQ4bl0Lmy5k0G/+Um6T0THQ6Ckcd /UfGU9Fq4jO1zDXZrh4ciVV4JjlkpQsGDnUc6WTZdShx8TPXi/iKwhWXH2GHZQUWJY80 YYIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9zVBczE5O/mOGSjCuNx2rXBFKme8bX0ZhvLdtMhoiJw=; b=rapuoyj0IQFACZ50d0K/DWSGKGQAZPiH4dxsavVX09+9YFalxbcNTgQ5RCoX++o0bn 3OXCxP8r51CndpjItLZyNF9XvjdGbLIkvqOt0zKOe7SeTmUiHH4kZ3W9H5WHXY9l4hcd Y2fzb5yhyD8vu/YWLRNeValgr/va8j9O9n3estz8P3bAHBX/boVALaMOIF6E1+wKFu7O CZt56Gf6Yx1b5n3XKBKiBGxagJsVeQWhFp7AZlFfFDY9AXMFDhkGq/8QTy+IODwX4Y/E VCZg5UzGoct7vjO/TIrp5DSIaeagsGha37ov3sItKBnpiKJA08cnWvEoIc5xuLkd6HGp OyvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gJtJ5FNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a170903230c00b001b1be1317a2si20518plh.103.2023.06.01.14.40.45; Thu, 01 Jun 2023 14:40:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gJtJ5FNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233077AbjFAVhg (ORCPT + 99 others); Thu, 1 Jun 2023 17:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232932AbjFAVh0 (ORCPT ); Thu, 1 Jun 2023 17:37:26 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 282621AE for ; Thu, 1 Jun 2023 14:37:17 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-65131e85be4so929728b3a.1 for ; Thu, 01 Jun 2023 14:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655436; x=1688247436; 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=9zVBczE5O/mOGSjCuNx2rXBFKme8bX0ZhvLdtMhoiJw=; b=gJtJ5FNgW645QFhWJrwgv+eoPxUDcKJjQ0xUeo56kyURgPks4SkoC2MQNDgXTtkZn7 QpKWQwG1Ny/ElORyKFDpyWZbKE5bj+Wp8fgVBvS+d/n6lwbgm1qW/f/93p6MP2NY714A nlF2KzG2LMv/VRRI6kZ2Dt7zapyMsrojNB0GU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655436; x=1688247436; 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=9zVBczE5O/mOGSjCuNx2rXBFKme8bX0ZhvLdtMhoiJw=; b=EgiiG6afsu+1dL6qy8+rhQKqerhSCxzUnSEUGwWjRt9udq3TKEsfOSyI75mzkimmRC oK4n/exPZsuOTpdghzaRgBpAdAE/gcj59a8R1DLeIw7FBBZAh0OnXWKw5lAZv4F6yHPH +QvTOt6M2ZEi+xYEqMXWc9TF5U0EO52LbrEzzsfsOqdy/NXdnjzbDhRGbga0hHGY4kIl /nNpinaOTzXeS1Z3xRiDLmG37nFoH5BsDfOannPF5MuQa8na3+T6fnkk4QtnW797z6w/ bOC9FIsOZybkkW/GnjMc03QepugSbnS8YwajOBXr/Mo8xHBABPzLh1Efn94IVSLgaAJ1 Xhsg== X-Gm-Message-State: AC+VfDyQ4ZY/deGTe0ufzlmlm1BcN/1TiAygfzukFJkDIb0SwtxqzI72 d+muuZzCreuUGW7Rv55zr7a9yg== X-Received: by 2002:a05:6a00:1797:b0:651:ce88:27f5 with SMTP id s23-20020a056a00179700b00651ce8827f5mr2208089pfg.13.1685655436495; Thu, 01 Jun 2023 14:37:16 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:11b8:2d2:7e02:6bff]) by smtp.gmail.com with ESMTPSA id g22-20020aa78756000000b0064d48d98260sm5319534pfo.156.2023.06.01.14.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:15 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v9 5/7] arm64: ipi_debug: Add support for backtrace using the debug IPI Date: Thu, 1 Jun 2023 14:31:49 -0700 Message-ID: <20230601143109.v9.5.I65981105e1f62550b0316625dd1e599deaf9e1aa@changeid> X-Mailer: git-send-email 2.41.0.rc2.161.g9c6817b8e7-goog In-Reply-To: <20230601213440.2488667-1-dianders@chromium.org> References: <20230601213440.2488667-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767538067411014950?= X-GMAIL-MSGID: =?utf-8?q?1767538067411014950?= From: Sumit Garg Enable arch_trigger_cpumask_backtrace() support on arm64 using the new debug IPI. With this arm64 can now get backtraces in cases where callers of the trigger_xyz_backtrace() class of functions don't check the return code and implement a fallback. One example is `kernel.softlockup_all_cpu_backtrace`. This also allows us to backtrace hard locked up CPUs in cases where the debug IPI is backed by an NMI (or pseudo NMI). Signed-off-by: Sumit Garg Signed-off-by: Douglas Anderson --- Changes in v9: - Added comments that we might not be using NMI always. - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. - arch_trigger_cpumask_backtrace() no longer returns bool Changes in v8: - Removed "#ifdef CONFIG_SMP" since arm64 is always SMP arch/arm64/include/asm/irq.h | 3 +++ arch/arm64/kernel/ipi_debug.c | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h index fac08e18bcd5..be2d103f316e 100644 --- a/arch/arm64/include/asm/irq.h +++ b/arch/arm64/include/asm/irq.h @@ -6,6 +6,9 @@ #include +void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self); +#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace + struct pt_regs; int set_handle_irq(void (*handle_irq)(struct pt_regs *)); diff --git a/arch/arm64/kernel/ipi_debug.c b/arch/arm64/kernel/ipi_debug.c index b57833e31eaf..6984ed507e1f 100644 --- a/arch/arm64/kernel/ipi_debug.c +++ b/arch/arm64/kernel/ipi_debug.c @@ -8,6 +8,7 @@ #include #include +#include #include #include "ipi_debug.h" @@ -24,11 +25,31 @@ void arm64_debug_ipi(cpumask_t *mask) __ipi_send_mask(ipi_debug_desc, mask); } +void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) +{ + /* + * NOTE: though nmi_trigger_cpumask_backtrace has "nmi_" in the name, + * nothing about it truly needs to be backed by an NMI, it's just that + * it's _allowed_ to be called from an NMI. If set_smp_debug_ipi() + * failed to get an NMI (or pseudo-NMI) this will just be backed by a + * regular IPI. + */ + nmi_trigger_cpumask_backtrace(mask, exclude_self, arm64_debug_ipi); +} + static irqreturn_t ipi_debug_handler(int irq, void *data) { - /* nop, NMI handlers for special features can be added here. */ + irqreturn_t ret = IRQ_NONE; + + /* + * NOTE: Just like in arch_trigger_cpumask_backtrace(), we're calling + * a function with "nmi_" in the name but it works fine even if we + * are using a regulaor IPI. + */ + if (nmi_cpu_backtrace(get_irq_regs())) + ret = IRQ_HANDLED; - return IRQ_NONE; + return ret; } void debug_ipi_setup(void) From patchwork Thu Jun 1 21:31:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 102202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp628421vqr; Thu, 1 Jun 2023 14:40:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zTqLxlZ1f0b0Cf8jnWExdTNJKv1vb3M3316E+ldotnIqaD4ATzOv2imOek/sOYS6g2l9i X-Received: by 2002:a05:6a20:394a:b0:10e:457f:2548 with SMTP id r10-20020a056a20394a00b0010e457f2548mr8258233pzg.37.1685655618618; Thu, 01 Jun 2023 14:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685655618; cv=none; d=google.com; s=arc-20160816; b=yFePyu0+3TzEANdlWgBkt9ZpRlVmG6r3vaoie9bZk1m2KJgDy5myM8G2ru311xs0nn +IfImyY0gLRH6/nJgBB6dj+24g1eJoVVsAB8n8XB69AmNe/3DB/LHBcN2mRq43SmmKzL PtGNNyTTmXE2YeD8Hd3HR0vVkGUVSxpX0RqE75G//QS8xG1SE0vbkI7B/PZzBbNAPLIO 0ObcieqgtASt0c+bDlNT7ZM1ywvGhmbZscDLKE/8Nw/N3nYYzHX4Sv/vMp1nFpkQTJlu kJ8wgPec2uOavwPcT6AQHENq4upK+hWDCDTegKwsgLPuCEb+GWFnj+ECT6Qkvs59LdOW HF3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MfGBHBvKGGFx2dApaWUV0FsGkRnAHULREps6A6RYWJ4=; b=puWezl9EnqpHCLmnnWQeVJzjNGoYUuvmg6mwicm0oXGEMgNcjU23LNG+gIeFMjEKi2 rC7DALlr9B7SGu34tDPLGT/6ftbzYjqXJUXKL6wQM+jax5PJvjRrbzV7UicBKDQdEHqX tFqeHM38DbyF2FqWN3qza3UteYHRKFfHKgBkr6bY1hqd0lFFdZcHkYeLIBiJTyZ0GiIe 5EYg0r9x+1KhNicxi6my9XpotNCHvyogHV7JIOBbsaxF+kWJscaocs4llthr+Z7mJ0cu DrzbinbWK3cRgPQMOp0x3amUgoZzMUx8cI7m7wPu67npazHJeVuUIRlmXxu/aKCDN/dV 4v3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AkgOfxeq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i189-20020a639dc6000000b0053fb3c97be6si3349518pgd.838.2023.06.01.14.40.05; Thu, 01 Jun 2023 14:40:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AkgOfxeq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233102AbjFAVhl (ORCPT + 99 others); Thu, 1 Jun 2023 17:37:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232971AbjFAVh1 (ORCPT ); Thu, 1 Jun 2023 17:37:27 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D3B9E40 for ; Thu, 1 Jun 2023 14:37:19 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-52c30fa5271so685699a12.0 for ; Thu, 01 Jun 2023 14:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655439; x=1688247439; 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=MfGBHBvKGGFx2dApaWUV0FsGkRnAHULREps6A6RYWJ4=; b=AkgOfxeqMJ+Uowmkx4hw7IQZ50qdy2xVCPyodSzFbID79vkX/uuep2hjtkAVQf+ZMY 2Ois27dY1aNRlYZc7JAHlkdtHKB/6T3f05uoIAoto3JEclpb7k9RtEHCD6+WC8K9AjHR 0/+O26QCTSXFLaWGDuAgWq5b1oezjD46LgHAY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655439; x=1688247439; 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=MfGBHBvKGGFx2dApaWUV0FsGkRnAHULREps6A6RYWJ4=; b=N7HWJtLG4dL5P1bvft8Bpwy+A9annUOLMGKJWXlILXdsxka3YZxKrHUIzUd4SDECyT /R4ThtXT11aVK278FRcwrhr6ts2V1oix9YYk4NCMfq2TEjo1sOwteQtYQmSMiplTLo7O UnLmqUTwOyXWR0Oy6Go2eWuPkTqDbd2+OPsXw7GFt3aQa4GbUhHlFE3SJjmSbadf2Yns zT2NJwvdYrbv1cZ5ybz7E5vJMzzGnI4LnTs106VHipaR38+zOj79lIOGkmR3A/A5YKLI XXT8twiNeYsBlfAAN8C+dEsEF+nX8aSYFPmaoDJVGn2uomKUSxsqGYoQKk3Kzcobd6/n w7wQ== X-Gm-Message-State: AC+VfDzreSiaq2b3vy3VJGX/tQ6BgY+SUBB/CTXBN/1NpQPPRBsWPb4x IivrW8+wErqOQV/TnzXfFzrYUA== X-Received: by 2002:a05:6a20:1583:b0:10f:759d:c5b2 with SMTP id h3-20020a056a20158300b0010f759dc5b2mr8808767pzj.45.1685655438667; Thu, 01 Jun 2023 14:37:18 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:11b8:2d2:7e02:6bff]) by smtp.gmail.com with ESMTPSA id g22-20020aa78756000000b0064d48d98260sm5319534pfo.156.2023.06.01.14.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:18 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Douglas Anderson , Jason Wessel , linux-kernel@vger.kernel.org Subject: [PATCH v9 6/7] kgdb: Provide a stub kgdb_nmicallback() if !CONFIG_KGDB Date: Thu, 1 Jun 2023 14:31:50 -0700 Message-ID: <20230601143109.v9.6.Ia3aeac89bb6751b682237e76e5ba594318e4b1aa@changeid> X-Mailer: git-send-email 2.41.0.rc2.161.g9c6817b8e7-goog In-Reply-To: <20230601213440.2488667-1-dianders@chromium.org> References: <20230601213440.2488667-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767538026288319908?= X-GMAIL-MSGID: =?utf-8?q?1767538026288319908?= To save architectures from needing to wrap the call in #ifdefs, add a stub no-op version of kgdb_nmicallback(), which returns 1 if it didn't handle anything. Reviewed-by: Daniel Thompson Signed-off-by: Douglas Anderson --- In v9 this is the only kgdb dependency. I'm assuming it could go through the arm64 tree? If that's not a good idea, we could always change the patch ("arm64: kgdb: Roundup cpus using IPI as NMI") not to depend on it by only calling kgdb_nmicallback() if CONFIG_KGDB is not defined. Changes in v9: - Added missing "inline" Changes in v8: - "Provide a stub kgdb_nmicallback() if !CONFIG_KGDB" new for v8 include/linux/kgdb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index 258cdde8d356..76e891ee9e37 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -365,5 +365,6 @@ extern void kgdb_free_init_mem(void); #define dbg_late_init() static inline void kgdb_panic(const char *msg) {} static inline void kgdb_free_init_mem(void) { } +static inline int kgdb_nmicallback(int cpu, void *regs) { return 1; } #endif /* ! CONFIG_KGDB */ #endif /* _KGDB_H_ */ From patchwork Thu Jun 1 21:31:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 102211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp633975vqr; Thu, 1 Jun 2023 14:53:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nAhqIkVFoNcaSdJZpR0Zr+dFu4EqFM7biLI+MfNynHRpZInh+I7UnKUI5/qjrX7p4JOKk X-Received: by 2002:a05:6358:9316:b0:121:4f03:1ef0 with SMTP id x22-20020a056358931600b001214f031ef0mr7237941rwa.19.1685656403879; Thu, 01 Jun 2023 14:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685656403; cv=none; d=google.com; s=arc-20160816; b=XdhzSEXZ2YV5Lqj7ayec11efIgser90f2LMouyhV8g0jp7AYCVBh5Av1VerMfP9n++ qv9nwsRhYzuDP/SI89OoPK3wlwT7bZX2UXZCgn2TKvUnYhBG+uirVMkVGv8R6V52LZzC gyqKf4I1wEDOORaOiZIUjVAj7VUMRwJNoKs3b5Viax6CG7Ovh0V93vismShaTB5jZnQZ JhIeNGtGfdYZ/Vpn8WnAJZ3msTRvWQ7FynG0VFYPhOaZtbB6vSmpTTEY8oCP2TnLOlHv X+K9kW0y1+RhSe3bwi5Wl3YZE0aDCXHESonhUjIEp2hSf4EsICVbdGUp2Vqrs93etRJg ILEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pZEI6Qd7tJdeWnwaS3kN3vC1A5EXJtp5KG07jP5WNyg=; b=bLVVzPLUgGcbM5ZxT92YF7wbf84US44e8veNh0SAq2G8hPWIn2NbQRGaWs03Nx684d J+b0uAWgFVKqiTmC6MwZpiPRBNSnYrYSz9kqGsr/EbeJEVjlo8of6X5SkF34uhUtTy5X s62J8iElw44RqBe3SjBFS4d7VMbWkKcRMYBunGuPKEcAf0kuBrD8ZIiGiT6sYl3qsIA6 wj+Yu8X+SFE+nTh5oNWHyVPCWEy1rHjuhudMBK3A/3WJ4fdtSE3uqMCzyHMHLc/CX9sK wgG7qnY1tw9ijKL9a9jnU8PGVwSML4WY+f6JJcaIcgZ5wtcV6O3t7L4asFFyYKU4awOQ 8Erg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JCAPoe0U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w24-20020a63af18000000b005428f77eff7si416802pge.854.2023.06.01.14.53.11; Thu, 01 Jun 2023 14:53:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JCAPoe0U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233032AbjFAVho (ORCPT + 99 others); Thu, 1 Jun 2023 17:37:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233015AbjFAVh3 (ORCPT ); Thu, 1 Jun 2023 17:37:29 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7725FE54 for ; Thu, 1 Jun 2023 14:37:21 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-64d2c865e4eso1066343b3a.0 for ; Thu, 01 Jun 2023 14:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655440; x=1688247440; 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=pZEI6Qd7tJdeWnwaS3kN3vC1A5EXJtp5KG07jP5WNyg=; b=JCAPoe0UpPAv7b1ZAoftxG1P1Hl0vpy0Cq9P6rzVeNVHhducqeN2ZSZojZbVaWW7dC V/r0eOU8zgusv6UU08goYhmBOTNL9X1E2+EeO3BOcET7CCGt7ad1tSvNoW5LKgBFJ/Sy CFgDlXkaNjTm6x7b8QEVI4t2zoTG++PINUd2E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655440; x=1688247440; 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=pZEI6Qd7tJdeWnwaS3kN3vC1A5EXJtp5KG07jP5WNyg=; b=Kt1LWddZqMO8XxB0zSVUch0ZDWWLbZtIBtostiZTClzkAu+/owP5xMAg9LUSabh/lZ J01RKLCLt8cqAIStHEzK77WcLu2LNAo4Vf8Lp0uomj3jNudlmOdkh5HtxIU1cCVPPhNc uoKhwXEBmOXd1VK0ByCo227pSl3amvA1LBJxRr18foM8U3dZXCB8ti9h1bSUikSsrzM4 qXMWTyzk2pzNrlGvsSDTxDiq6Uz1JZ0ZSmrPT+i6ytzhQOgH/gm6JQl3Mc5wgwW8uptc 8ln6kY/fOusO04SioklYiGqREFzTrtFx8ioqxuIHxX6viTj3sEB+5gZZMPgjg/o7PObM u4dg== X-Gm-Message-State: AC+VfDx+5lGwRTfT9iuYPq2vRZhqYJE6lPRRowHiEF/bMNpn8TAKZObp N/id/yrjiirmzLe4FRN804PGQQ== X-Received: by 2002:a05:6a00:841:b0:643:6aed:3a9 with SMTP id q1-20020a056a00084100b006436aed03a9mr9872210pfk.0.1685655440701; Thu, 01 Jun 2023 14:37:20 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:11b8:2d2:7e02:6bff]) by smtp.gmail.com with ESMTPSA id g22-20020aa78756000000b0064d48d98260sm5319534pfo.156.2023.06.01.14.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:20 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Douglas Anderson , Wei Li , linux-kernel@vger.kernel.org Subject: [PATCH v9 7/7] arm64: kgdb: Roundup cpus using the debug IPI Date: Thu, 1 Jun 2023 14:31:51 -0700 Message-ID: <20230601143109.v9.7.I2ef26d1b3bfbed2d10a281942b0da7d9854de05e@changeid> X-Mailer: git-send-email 2.41.0.rc2.161.g9c6817b8e7-goog In-Reply-To: <20230601213440.2488667-1-dianders@chromium.org> References: <20230601213440.2488667-1-dianders@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767538849356265960?= X-GMAIL-MSGID: =?utf-8?q?1767538849356265960?= From: Sumit Garg Let's use the debug IPI for rounding up CPUs in kgdb. When the debug IPI is backed by an NMI (or pseudo NMI) then this will let us debug even hard locked CPUs. When the debug IPI isn't backed by an NMI then this won't really have any huge benefit but it will still work. Signed-off-by: Sumit Garg Signed-off-by: Douglas Anderson --- Changes in v9: - Remove fallback for when debug IPI isn't available. - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. arch/arm64/kernel/ipi_debug.c | 5 +++++ arch/arm64/kernel/kgdb.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/arch/arm64/kernel/ipi_debug.c b/arch/arm64/kernel/ipi_debug.c index 6984ed507e1f..5794894d94f1 100644 --- a/arch/arm64/kernel/ipi_debug.c +++ b/arch/arm64/kernel/ipi_debug.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -40,6 +41,7 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) static irqreturn_t ipi_debug_handler(int irq, void *data) { irqreturn_t ret = IRQ_NONE; + unsigned int cpu = smp_processor_id(); /* * NOTE: Just like in arch_trigger_cpumask_backtrace(), we're calling @@ -49,6 +51,9 @@ static irqreturn_t ipi_debug_handler(int irq, void *data) if (nmi_cpu_backtrace(get_irq_regs())) ret = IRQ_HANDLED; + if (!kgdb_nmicallback(cpu, get_irq_regs())) + ret = IRQ_HANDLED; + return ret; } diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index 4e1f983df3d1..9c4c47507cd4 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -20,6 +20,8 @@ #include #include +#include "ipi_debug.h" + struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { { "x0", 8, offsetof(struct pt_regs, regs[0])}, { "x1", 8, offsetof(struct pt_regs, regs[1])}, @@ -356,3 +358,15 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) return aarch64_insn_write((void *)bpt->bpt_addr, *(u32 *)bpt->saved_instr); } + +void kgdb_roundup_cpus(void) +{ + struct cpumask mask; + + cpumask_copy(&mask, cpu_online_mask); + cpumask_clear_cpu(raw_smp_processor_id(), &mask); + if (cpumask_empty(&mask)) + return; + + arm64_debug_ipi(&mask); +}