Message ID | 20230419155341.v8.6.I4baba13e220bdd24d11400c67f137c35f07f82c7@changeid |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp729559vqo; Wed, 19 Apr 2023 16:25:51 -0700 (PDT) X-Google-Smtp-Source: AKy350Y4N6WvfmvP+MIL/Y9h3xGnJ1z4ECxKqGhtvzzN8xex2jaKK2MpR8czkoM5HQTW7awc6AAw X-Received: by 2002:a05:6a00:1945:b0:63d:2910:5c8b with SMTP id s5-20020a056a00194500b0063d29105c8bmr4580571pfk.29.1681946751390; Wed, 19 Apr 2023 16:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681946751; cv=none; d=google.com; s=arc-20160816; b=UwKLROY90YnJAFB2e5SacyXgIGsZv+SjIoNjvIch9CE2kWnBdIy50JsKv5M6wlZjwV EmFWdRiO0Xue5WPHm41jftxD9+jghl5VtpH7AakVmmCEpMJciV1rXPgWvm1h07tR4fwi adMZiZy3vm5NM9en9FllrxQ1qwLys+ykZ5SEV72kPgz6RdN8foN92eKyPbzWtg0THTeS lRJqINBwxCF72Tj+FtLKqHYCOL1glZgxxJgtaeE5nUt0nqFvwtONPmdr11pgG0qKrqpN qSjR9DkGpodkflUl0NKKkquD3QjRMgH4GI8HUS3mOUI6eFNlfK3ROCEe5vlBGmTrUqU9 qG5A== 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=LAvgM/34n0JSYhh4m4RBiwXsllZsYs4Vm4Z5FlxDAmU=; b=zMIMU33H+iGpiQ7zDTk4CYRFLtMqi0JA5bD+0H5/OGX4E/u6FWQtdkPVujUju30mYX GFAQmq2pwxiYj9YunXkKLhkKVCe494KmKuzrF0Y/y9Kt4kKzVtf/kiBaiZRzLp5OYskh WvX7WuUGjv60gVOmFk84DFv3Es7vIcmLs3rGPTSxgIBrZKvBsxf3jYgM0C0Mmm5wOBtt qdwd8jHFXJ80z6K/myCqmkXj3sB2fN3vPj8Ov4Il3UZxvXUo0UgitXd29u3X/BKW0mlV Wd5Nnen/tj1Nj+evnHIsDpHMMKCT7uNVv7C/2SRLcEyCUH3lBU9Z0LIlVI8/LHLC8HSL tsmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=na1XodKz; 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 e13-20020a056a0000cd00b0063d1f93cc4fsi7900554pfj.291.2023.04.19.16.25.38; Wed, 19 Apr 2023 16:25:51 -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=na1XodKz; 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 S233605AbjDSW5k (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Wed, 19 Apr 2023 18:57:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233539AbjDSW5U (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 19 Apr 2023 18:57:20 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F409359C for <linux-kernel@vger.kernel.org>; Wed, 19 Apr 2023 15:57:15 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5144a9c11c7so305955a12.2 for <linux-kernel@vger.kernel.org>; Wed, 19 Apr 2023 15:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681945035; x=1684537035; 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=LAvgM/34n0JSYhh4m4RBiwXsllZsYs4Vm4Z5FlxDAmU=; b=na1XodKzWaW2Z6wPGGKRe2iz49sCLIx47dGIaumaf/glZ+STubFDyQ2ys5ORZkrctf OB6zllbubw5lW84ZgxLPkfIlj8eehdM7wa7uzlUOFC6PZ4MtmJu0+GNyytMFGKPRxPpc brH7JrALzbYRHB7bOwxZCAaopLhqvJNyA7mI8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681945035; x=1684537035; 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=LAvgM/34n0JSYhh4m4RBiwXsllZsYs4Vm4Z5FlxDAmU=; b=kwVEbH+5zdkj5gOu9B0YRsVS/Bv4yrcVPCWwgcXIlNzZiLvdlMbxehcQidFlCOqw/v yVkS8++Qt7mrBqjtekXXdLapCBMRthzFikEXbRgOaC8M8ahW1Fvr4nTczP+0aJN1JHrQ 3l9dlYtsiZQXkDJ2e3VJ6GIQPOVCxgOg6Ufss8dZq/s5fsKsAK26qdaMyDlCPqfhWCz8 VsMluEBJMSDoTGa8ofLNAbmd41/l88AkL4q6Av43/kW75v8zQzNBkz9pSQN/hE1qGO2t nVIUGLsi/g/R8i02NM4wQ8RktGHXBiMTdExigvjHS8VqNeKHocdfS2z/KrPvjSYLGPhM iblQ== X-Gm-Message-State: AAQBX9cDOXf2SMn6q9ypFIUOrv5snRkTIlmXTkQT0W1HHUTLV6xLyGW5 I/OcNj67OQK9Yg9/yAu6lU26Qg== X-Received: by 2002:a17:90a:4142:b0:247:19c5:aa3d with SMTP id m2-20020a17090a414200b0024719c5aa3dmr4050436pjg.36.1681945035028; Wed, 19 Apr 2023 15:57:15 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8b1:fa03:670e:b784]) by smtp.gmail.com with ESMTPSA id h15-20020a17090aea8f00b00246ea338c96sm1847101pjz.53.2023.04.19.15.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:57:14 -0700 (PDT) From: Douglas Anderson <dianders@chromium.org> To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Sumit Garg <sumit.garg@linaro.org>, Daniel Thompson <daniel.thompson@linaro.org>, Marc Zyngier <maz@kernel.org>, Mark Rutland <mark.rutland@arm.com> Cc: ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, Chen-Yu Tsai <wens@csie.org>, Masayoshi Mizuma <msys.mizuma@gmail.com>, Peter Zijlstra <peterz@infradead.org>, Ard Biesheuvel <ardb@kernel.org>, "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>, linux-arm-kernel@lists.infradead.org, Stephen Boyd <swboyd@chromium.org>, Lecopzer Chen <lecopzer.chen@mediatek.com>, Thomas Gleixner <tglx@linutronix.de>, linux-perf-users@vger.kernel.org, Douglas Anderson <dianders@chromium.org>, Frederic Weisbecker <frederic@kernel.org>, "Gautham R. Shenoy" <gautham.shenoy@amd.com>, Ingo Molnar <mingo@kernel.org>, linux-kernel@vger.kernel.org Subject: [PATCH v8 06/10] arm64: idle: Tag the arm64 idle functions as __cpuidle Date: Wed, 19 Apr 2023 15:56:00 -0700 Message-ID: <20230419155341.v8.6.I4baba13e220bdd24d11400c67f137c35f07f82c7@changeid> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230419225604.21204-1-dianders@chromium.org> References: <20230419225604.21204-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 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,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763648996658286331?= X-GMAIL-MSGID: =?utf-8?q?1763648996658286331?= |
Series |
arm64: Add framework to turn an IPI as NMI
|
|
Commit Message
Doug Anderson
April 19, 2023, 10:56 p.m. UTC
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
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
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(-)
Comments
On Wed, Apr 19, 2023 at 03:56:00PM -0700, Douglas Anderson wrote: > 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 As a heads-up, this is only going to work in the trivial case where a CPU is within the default cpu_do_idle(), and not for anything using PSCI cpu_suspend() (which I'd *really* hope is the common case). That doesn't get inlined, and the invocation is shared with other SMCCC users, so we probably need more work there if culling idle backtraces is important. I'm not averse to this change itself. Mark. > Signed-off-by: Douglas Anderson <dianders@chromium.org> > --- > > 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 > -- > 2.40.0.634.g4ca3ef3211-goog >
Hi, On Wed, May 10, 2023 at 9:43 AM Mark Rutland <mark.rutland@arm.com> wrote: > > On Wed, Apr 19, 2023 at 03:56:00PM -0700, Douglas Anderson wrote: > > 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 > > As a heads-up, this is only going to work in the trivial case where a CPU is > within the default cpu_do_idle(), and not for anything using PSCI > cpu_suspend() (which I'd *really* hope is the common case). Thanks for the review and the heads up! Right. It only catches shallow idle. Specifically this was the stack trace when it was "caught" on a sc7180-trogdor device: cpu_do_idle+0x94/0x98 psci_enter_idle_state+0x58/0x70 cpuidle_enter_state+0xb8/0x260 cpuidle_enter+0x44/0x5c do_idle+0x188/0x30c ... I checked in kgdb and saw that "psci_enter_idle_state()" had "idx" as 0, which makes sense since __CPU_PM_CPU_IDLE_ENTER will directly call cpu_do_idle() when idx is 0. I agree that it doesn't catch every case. Certainly it's not too hard to see a CPU here: 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 ... ...and kgdb showed "idx" was 3. That being said, catching some of the cases is better than catching none of the cases. ;-) In reality, I've seen cases where it catches most CPUs. For instance, running soon after bootup on my sc7180-trogdor device: echo HARDLOCKUP > /sys/kernel/debug/provoke-crash/DIRECT ...and then having the "buddy" hardlockup detector [1] catch the crash caught all of the CPUs other than the one that was locked up and the one that detected it. Specifically: NMI backtrace for cpu 2 skipped: idling at cpu_do_idle+0x94/0x98 NMI backtrace for cpu 1 skipped: idling at cpu_do_idle+0x94/0x98 NMI backtrace for cpu 0 skipped: idling at cpu_do_idle+0x94/0x98 NMI backtrace for cpu 3 skipped: idling at cpu_do_idle+0x94/0x98 NMI backtrace for cpu 4 skipped: idling at cpu_do_idle+0x94/0x98 NMI backtrace for cpu 7 skipped: idling at cpu_do_idle+0x94/0x98 I haven't analyzed it, but I guess it's possible that when the buddy hardlockup detector triggers that other CPUs are more likely to be in a shallow idle? Certainly I seem to catch a lot more CPUs in a shallow idle in buddy lockup reports... [1] https://lore.kernel.org/r/20230504221349.1535669-1-dianders@chromium.org > That doesn't get inlined, and the invocation is shared with other SMCCC users, > so we probably need more work there if culling idle backtraces is important. At this point I'd say that we should just take the low hanging fruit (this patch). If someone later wants to try to do better they can. > I'm not averse to this change itself. Any chance you'd be willing to give any tags to it? :-P Do you need me to add any of the above caveats to the commit message? I also certainly wouldn't object to this patch landing even if others aren't ready. It has no dependencies on any other patches and just makes the debug messages prettier in some cases. -Doug
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