Message ID | cca346b5c87693499e630291d78fb0bf12c24290.1676358308.git.jpoimboe@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2811649wrn; Mon, 13 Feb 2023 23:11:05 -0800 (PST) X-Google-Smtp-Source: AK7set8/42GuIJWAT1A+EOX2I3+agqLY1yb1K27KpAPrfCx3Csbd+oekGrloYLynDEdhivatEGKu X-Received: by 2002:a05:600c:4494:b0:3de:b1ec:7f95 with SMTP id e20-20020a05600c449400b003deb1ec7f95mr1123917wmo.18.1676358665516; Mon, 13 Feb 2023 23:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676358665; cv=none; d=google.com; s=arc-20160816; b=DkwoWC2qfvGTBikWJUZhOFAJ/UwzXnFgF1ifU5UTJiTPy73vVy8GVskrr3+s7eTs1M pZ19f9ID9Z+Dt38wL2/+jPWcbczwQwJibrQZWLG4R0Ibr4P6bO6lVOUaTZkCFl1fHQWf x8DA4IwS1ZJcpBwWqaEJq2MbE7jiFfEUujujfbpkjsD2rJ1oxLISyTbWhtNhsI+yr6JH 9wa+mcHnxqiRxB/HI5m2PlPekQhncUo8gM9N7XsQptNaqwFTmw6EDzMC+Oj8m4IS6KfZ knJJvb0HZ/pTOdBPXTAxdNwMc48fkCs6I4gC9k8vY2yj/lUZLf7KMlsAkOTEAOMDFFM5 qVeQ== 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=WpL96GrgsIPC+elDp+CDmyklbSK1HL5Z8MkZOej5/Uw=; b=l7ogEFPtVSUTdya8zCnWEzw6SpBGKYlHL9DI8NCSGjfhpBTQTI29R9MY5MZNCNifue RFiFBbMLPMAAakwR6bhkvN7NCDBGgMnUkxbcTNi8aYVfITlkudHW8BwvxikT0dXzjBz7 fcI0pPYizQWTdfMvSNSTy0zIbMZWbo9ZKK8odtC8xGyub63cd8t1ECXDDjkwnoDqscAc 3Y+Yi0hn9iqperslXWYPaOjpjt3t0W60Y0zMD1Ac+zIWftWFPhoLnyMXMxfZVENMiIFu zk50g7+DtSjltfRoIkVltx6q1O/RihPg7sfzRmTR/4jqbM3DRYSDejYlgTbs2e4jQ9Ov +x7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ihibyp4i; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bh12-20020a05600c3d0c00b003e115a05f41si12823803wmb.65.2023.02.13.23.10.42; Mon, 13 Feb 2023 23:11:05 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=ihibyp4i; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232041AbjBNHJW (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Tue, 14 Feb 2023 02:09:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231939AbjBNHHp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Feb 2023 02:07:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D62D1DBBB; Mon, 13 Feb 2023 23:07:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6EA1561483; Tue, 14 Feb 2023 07:07:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BC09C4339C; Tue, 14 Feb 2023 07:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676358443; bh=Vz9pacmD2uWnKtGE9AgzwIGUED4qhPPVsYwwh31r10c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ihibyp4ipYh7lQbANFcsUTiHup0xNx5JMQ/c4E3q5yGId+1gTQii/DTVSUWTsOltw IqvTEQrOFzi2eFo294/k7bZhA6LANgcvqyIA6iJgUKc3l8XDMyd8GBQE+AIh601ofR Qc3xpRS1OEc1oUgLhUfbdhFWnImGAZlRDONcTJ/AUMAJRMW7eT2YlrHDa/yyWvyexc X6uQrIyw5EWPq7+6xku9zrDlYBy8ZUaQ+gxoKXgdd3pvsLjc6WJXXE5XCSZlHYHxoY 0KvkA5welRNTeqfi984yl9rKlVPjqPnNJdmII0J45bsDxbkD1Y+8mlhaPORYaSNPw7 yJswjRO+Y9qRw== From: Josh Poimboeuf <jpoimboe@kernel.org> To: linux-kernel@vger.kernel.org Cc: jgross@suse.com, richard.henderson@linaro.org, ink@jurassic.park.msu.ru, mattst88@gmail.com, linux-alpha@vger.kernel.org, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, guoren@kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, loongarch@lists.linux.dev, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, tsbogend@alpha.franken.de, linux-mips@vger.kernel.org, jiaxun.yang@flygoat.com, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, linuxppc-dev@lists.ozlabs.org, ysato@users.sourceforge.jp, dalias@libc.org, linux-sh@vger.kernel.org, davem@davemloft.net, sparclinux@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, chris@zankel.net, jcmvbkbc@gmail.com, linux-xtensa@linux-xtensa.org, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, paulmck@kernel.org Subject: [PATCH v2 19/24] xtensa/cpu: Make sure cpu_die() doesn't return Date: Mon, 13 Feb 2023 23:05:53 -0800 Message-Id: <cca346b5c87693499e630291d78fb0bf12c24290.1676358308.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <cover.1676358308.git.jpoimboe@kernel.org> References: <cover.1676358308.git.jpoimboe@kernel.org> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: <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?1757789464101883993?= X-GMAIL-MSGID: =?utf-8?q?1757789464101883993?= |
Series |
cpu,sched: Mark arch_cpu_idle_dead() __noreturn
|
|
Commit Message
Josh Poimboeuf
Feb. 14, 2023, 7:05 a.m. UTC
cpu_die() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit
failure mode and avoids undefined behavior like falling off the edge of
the function into whatever code happens to be next.
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
arch/xtensa/kernel/smp.c | 2 ++
1 file changed, 2 insertions(+)
Comments
Hi Josh, On 14/2/23 08:05, Josh Poimboeuf wrote: > cpu_die() doesn't return. Make that more explicit with a BUG(). > > BUG() is preferable to unreachable() because BUG() is a more explicit > failure mode and avoids undefined behavior like falling off the edge of > the function into whatever code happens to be next. > > Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> > --- > arch/xtensa/kernel/smp.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > index 4dc109dd6214..7bad78495536 100644 > --- a/arch/xtensa/kernel/smp.c > +++ b/arch/xtensa/kernel/smp.c Can you update the documentation along? Currently we have: /* * Called from the idle thread for the CPU which has been shutdown. * * Note that we disable IRQs here, but do not re-enable them * before returning to the caller. This is also the behaviour * of the other hotplug-cpu capable cores, so presumably coming * out of idle fixes this. */ > @@ -341,6 +341,8 @@ void __ref cpu_die(void) > __asm__ __volatile__( > " movi a2, cpu_restart\n" > " jx a2\n"); > + > + BUG(); > } > > #endif /* CONFIG_HOTPLUG_CPU */
On Tue, Feb 14, 2023 at 08:55:32AM +0100, Philippe Mathieu-Daudé wrote: > Hi Josh, > > On 14/2/23 08:05, Josh Poimboeuf wrote: > > cpu_die() doesn't return. Make that more explicit with a BUG(). > > > > BUG() is preferable to unreachable() because BUG() is a more explicit > > failure mode and avoids undefined behavior like falling off the edge of > > the function into whatever code happens to be next. > > > > Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> > > --- > > arch/xtensa/kernel/smp.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c > > index 4dc109dd6214..7bad78495536 100644 > > --- a/arch/xtensa/kernel/smp.c > > +++ b/arch/xtensa/kernel/smp.c > > Can you update the documentation along? Currently we have: > > /* > * Called from the idle thread for the CPU which has been shutdown. > * > * Note that we disable IRQs here, but do not re-enable them > * before returning to the caller. This is also the behaviour > * of the other hotplug-cpu capable cores, so presumably coming > * out of idle fixes this. > */ void __ref cpu_die(void) { idle_task_exit(); local_irq_disable(); __asm__ __volatile__( " movi a2, cpu_restart\n" " jx a2\n"); BUG(); } Hm, not only is the comment wrong, but it seems to be branching to cpu_restart? That doesn't seem right at all. Max/Chris?
On Tue, 14 Feb 2023 10:23:22 -0800 Josh Poimboeuf <jpoimboe@kernel.org> wrote: > void __ref cpu_die(void) > { > idle_task_exit(); > local_irq_disable(); > __asm__ __volatile__( > " movi a2, cpu_restart\n" > " jx a2\n"); > > BUG(); > } > > Hm, not only is the comment wrong, but it seems to be branching to > cpu_restart? That doesn't seem right at all. Agreed, that does not look right at all. -- Steve > > Max/Chris? >
On Tue, Feb 14, 2023 at 10:23 AM Josh Poimboeuf <jpoimboe@kernel.org> wrote: > On Tue, Feb 14, 2023 at 08:55:32AM +0100, Philippe Mathieu-Daudé wrote: > > Can you update the documentation along? Currently we have: > > > > /* > > * Called from the idle thread for the CPU which has been shutdown. > > * > > * Note that we disable IRQs here, but do not re-enable them > > * before returning to the caller. This is also the behaviour > > * of the other hotplug-cpu capable cores, so presumably coming > > * out of idle fixes this. > > */ > > void __ref cpu_die(void) > { > idle_task_exit(); > local_irq_disable(); > __asm__ __volatile__( > " movi a2, cpu_restart\n" > " jx a2\n"); > > BUG(); > } > > Hm, not only is the comment wrong, but it seems to be branching to > cpu_restart? That doesn't seem right at all. Perhaps the name is a bit misleading. The CPU that enters 'cpu_restart' loops there until a call to 'boot_secondary' releases it, after which it goes to '_startup'. So it is a restart, but not immediate.
On Tue, Feb 14, 2023 at 11:48:41AM -0800, Max Filippov wrote: > On Tue, Feb 14, 2023 at 10:23 AM Josh Poimboeuf <jpoimboe@kernel.org> wrote: > > On Tue, Feb 14, 2023 at 08:55:32AM +0100, Philippe Mathieu-Daudé wrote: > > > Can you update the documentation along? Currently we have: > > > > > > /* > > > * Called from the idle thread for the CPU which has been shutdown. > > > * > > > * Note that we disable IRQs here, but do not re-enable them > > > * before returning to the caller. This is also the behaviour > > > * of the other hotplug-cpu capable cores, so presumably coming > > > * out of idle fixes this. > > > */ > > > > void __ref cpu_die(void) > > { > > idle_task_exit(); > > local_irq_disable(); > > __asm__ __volatile__( > > " movi a2, cpu_restart\n" > > " jx a2\n"); > > > > BUG(); > > } > > > > Hm, not only is the comment wrong, but it seems to be branching to > > cpu_restart? That doesn't seem right at all. > > Perhaps the name is a bit misleading. The CPU that enters 'cpu_restart' > loops there until a call to 'boot_secondary' releases it, after which it goes > to '_startup'. So it is a restart, but not immediate. Ah, I see. That sounds similar to what Xen does.
diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c index 4dc109dd6214..7bad78495536 100644 --- a/arch/xtensa/kernel/smp.c +++ b/arch/xtensa/kernel/smp.c @@ -341,6 +341,8 @@ void __ref cpu_die(void) __asm__ __volatile__( " movi a2, cpu_restart\n" " jx a2\n"); + + BUG(); } #endif /* CONFIG_HOTPLUG_CPU */