From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0CFA53AF for ; Wed, 15 Feb 2023 13:09:34 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6F7ABFEC; Wed, 15 Feb 2023 05:10:16 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.89.142]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8797A3F663; Wed, 15 Feb 2023 05:09:26 -0800 (PST) Date: Wed, 15 Feb 2023 13:09:21 +0000 From: Mark Rutland To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Cc: Josh Poimboeuf , linux-kernel@vger.kernel.org, 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: Re: [PATCH v2 04/24] arm64/cpu: Mark cpu_die() __noreturn Message-ID: References: <14274f04-2991-95bd-c29b-07e86e8755c1@linaro.org> Precedence: bulk X-Mailing-List: loongarch@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <14274f04-2991-95bd-c29b-07e86e8755c1@linaro.org> On Tue, Feb 14, 2023 at 09:13:08AM +0100, Philippe Mathieu-Daudé wrote: > On 14/2/23 08:05, Josh Poimboeuf wrote: > > cpu_die() doesn't return. Annotate it as such. By extension this also > > makes arch_cpu_idle_dead() noreturn. > > > > Signed-off-by: Josh Poimboeuf > > --- > > arch/arm64/include/asm/smp.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h > > index fc55f5a57a06..5733a31bab08 100644 > > --- a/arch/arm64/include/asm/smp.h > > +++ b/arch/arm64/include/asm/smp.h > > @@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask) > > extern int __cpu_disable(void); > > extern void __cpu_die(unsigned int cpu); > > -extern void cpu_die(void); > > +extern void __noreturn cpu_die(void); > > extern void cpu_die_early(void); > > Shouldn't cpu_operations::cpu_die() be declared noreturn first? The cpu_die() function ends with a BUG(), and so does not return, even if a cpu_operations::cpu_die() function that it calls erroneously returned. We *could* mark cpu_operations::cpu_die() as noreturn, but I'd prefer that we did not so that the compiler doesn't optimize away the BUG() which is there to catch such erroneous returns. That said, could we please add __noreturn to the implementation of cpu_die() in arch/arm64/kernel/smp.c? i.e. the fixup below. With that fixup: Acked-by: Mark Rutland Mark. ---->8---- diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf695..a98a76f7c1c6 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -361,7 +361,7 @@ void __cpu_die(unsigned int cpu) * Called from the idle thread for the CPU which has been shutdown. * */ -void cpu_die(void) +void __noreturn cpu_die(void) { unsigned int cpu = smp_processor_id(); const struct cpu_operations *ops = get_cpu_ops(cpu); From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 F2FAAC636D4 for ; Wed, 15 Feb 2023 13:10:40 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PGz334tRxz3f45 for ; Thu, 16 Feb 2023 00:10:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=arm.com (client-ip=217.140.110.172; helo=foss.arm.com; envelope-from=mark.rutland@arm.com; receiver=) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lists.ozlabs.org (Postfix) with ESMTP id 4PGz2T0zPZz3c6d for ; Thu, 16 Feb 2023 00:10:06 +1100 (AEDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6F7ABFEC; Wed, 15 Feb 2023 05:10:16 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.89.142]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8797A3F663; Wed, 15 Feb 2023 05:09:26 -0800 (PST) Date: Wed, 15 Feb 2023 13:09:21 +0000 From: Mark Rutland To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: Re: [PATCH v2 04/24] arm64/cpu: Mark cpu_die() __noreturn Message-ID: References: <14274f04-2991-95bd-c29b-07e86e8755c1@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <14274f04-2991-95bd-c29b-07e86e8755c1@linaro.org> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: juri.lelli@redhat.com, dalias@libc.org, linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, peterz@infradead.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, x86@kernel.org, jiaxun.yang@flygoat.com, linux-mips@vger.kernel.org, bsegall@google.com, jcmvbkbc@gmail.com, guoren@kernel.org, hpa@zytor.com, sparclinux@vger.kernel.org, kernel@xen0n.name, will@kernel.org, vschneid@redhat.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, ysato@users.sourceforge.jp, chenhuacai@kernel.org, linux@armlinux.org.uk, linux-csky@vger.kernel.org, dietmar.eggemann@arm.com, mingo@redhat.com, bcm-kernel-feedback-list@broadcom.com, mgorman@suse.de, mattst88@gmail.com, linux-xtensa@linux-xtensa.org, paulmck@kernel.org, richard.henderson@linaro.org, npiggin@gmail.com, ink@jurassic.park.msu.ru, rostedt@goodmis.org, loongarch@lists.linux.dev, tglx@linutronix.de, Josh Poimboeuf , linux-arm-kernel@lists.infradead.org, jgross@suse.com, chris@zankel.net, tsbogend@alpha.fran ken.de, bristot@redhat.com, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, bp@alien8.de, linuxppc-dev@lists.ozlabs.org, davem@davemloft.net Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, Feb 14, 2023 at 09:13:08AM +0100, Philippe Mathieu-Daudé wrote: > On 14/2/23 08:05, Josh Poimboeuf wrote: > > cpu_die() doesn't return. Annotate it as such. By extension this also > > makes arch_cpu_idle_dead() noreturn. > > > > Signed-off-by: Josh Poimboeuf > > --- > > arch/arm64/include/asm/smp.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h > > index fc55f5a57a06..5733a31bab08 100644 > > --- a/arch/arm64/include/asm/smp.h > > +++ b/arch/arm64/include/asm/smp.h > > @@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask) > > extern int __cpu_disable(void); > > extern void __cpu_die(unsigned int cpu); > > -extern void cpu_die(void); > > +extern void __noreturn cpu_die(void); > > extern void cpu_die_early(void); > > Shouldn't cpu_operations::cpu_die() be declared noreturn first? The cpu_die() function ends with a BUG(), and so does not return, even if a cpu_operations::cpu_die() function that it calls erroneously returned. We *could* mark cpu_operations::cpu_die() as noreturn, but I'd prefer that we did not so that the compiler doesn't optimize away the BUG() which is there to catch such erroneous returns. That said, could we please add __noreturn to the implementation of cpu_die() in arch/arm64/kernel/smp.c? i.e. the fixup below. With that fixup: Acked-by: Mark Rutland Mark. ---->8---- diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf695..a98a76f7c1c6 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -361,7 +361,7 @@ void __cpu_die(unsigned int cpu) * Called from the idle thread for the CPU which has been shutdown. * */ -void cpu_die(void) +void __noreturn cpu_die(void) { unsigned int cpu = smp_processor_id(); const struct cpu_operations *ops = get_cpu_ops(cpu); From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Rutland Date: Wed, 15 Feb 2023 13:09:21 +0000 Subject: Re: [PATCH v2 04/24] arm64/cpu: Mark cpu_die() __noreturn Message-Id: List-Id: References: <14274f04-2991-95bd-c29b-07e86e8755c1@linaro.org> In-Reply-To: <14274f04-2991-95bd-c29b-07e86e8755c1@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Cc: Josh Poimboeuf , linux-kernel@vger.kernel.org, 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 On Tue, Feb 14, 2023 at 09:13:08AM +0100, Philippe Mathieu-Daud=C3=A9 wrote: > On 14/2/23 08:05, Josh Poimboeuf wrote: > > cpu_die() doesn't return. Annotate it as such. By extension this also > > makes arch_cpu_idle_dead() noreturn. > >=20 > > Signed-off-by: Josh Poimboeuf > > --- > > arch/arm64/include/asm/smp.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > >=20 > > diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h > > index fc55f5a57a06..5733a31bab08 100644 > > --- a/arch/arm64/include/asm/smp.h > > +++ b/arch/arm64/include/asm/smp.h > > @@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const = struct cpumask *mask) > > extern int __cpu_disable(void); > > extern void __cpu_die(unsigned int cpu); > > -extern void cpu_die(void); > > +extern void __noreturn cpu_die(void); > > extern void cpu_die_early(void); >=20 > Shouldn't cpu_operations::cpu_die() be declared noreturn first? The cpu_die() function ends with a BUG(), and so does not return, even if a cpu_operations::cpu_die() function that it calls erroneously returned. We *could* mark cpu_operations::cpu_die() as noreturn, but I'd prefer that = we did not so that the compiler doesn't optimize away the BUG() which is there= to catch such erroneous returns. That said, could we please add __noreturn to the implementation of cpu_die(= ) in arch/arm64/kernel/smp.c? i.e. the fixup below. With that fixup: Acked-by: Mark Rutland Mark. ---->8---- diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf695..a98a76f7c1c6 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -361,7 +361,7 @@ void __cpu_die(unsigned int cpu) * Called from the idle thread for the CPU which has been shutdown. * */ -void cpu_die(void) +void __noreturn cpu_die(void) { unsigned int cpu =3D smp_processor_id(); const struct cpu_operations *ops =3D get_cpu_ops(cpu); From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Rutland Subject: Re: [PATCH v2 04/24] arm64/cpu: Mark cpu_die() __noreturn Date: Wed, 15 Feb 2023 13:09:21 +0000 Message-ID: References: <14274f04-2991-95bd-c29b-07e86e8755c1@linaro.org> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <14274f04-2991-95bd-c29b-07e86e8755c1@linaro.org> List-ID: Content-Type: text/plain; charset="iso-8859-1" To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Cc: Josh Poimboeuf , linux-kernel@vger.kernel.org, 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. On Tue, Feb 14, 2023 at 09:13:08AM +0100, Philippe Mathieu-Daud=C3=A9 wrote: > On 14/2/23 08:05, Josh Poimboeuf wrote: > > cpu_die() doesn't return. Annotate it as such. By extension this also > > makes arch_cpu_idle_dead() noreturn. > >=20 > > Signed-off-by: Josh Poimboeuf > > --- > > arch/arm64/include/asm/smp.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > >=20 > > diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h > > index fc55f5a57a06..5733a31bab08 100644 > > --- a/arch/arm64/include/asm/smp.h > > +++ b/arch/arm64/include/asm/smp.h > > @@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const = struct cpumask *mask) > > extern int __cpu_disable(void); > > extern void __cpu_die(unsigned int cpu); > > -extern void cpu_die(void); > > +extern void __noreturn cpu_die(void); > > extern void cpu_die_early(void); >=20 > Shouldn't cpu_operations::cpu_die() be declared noreturn first? The cpu_die() function ends with a BUG(), and so does not return, even if a cpu_operations::cpu_die() function that it calls erroneously returned. We *could* mark cpu_operations::cpu_die() as noreturn, but I'd prefer that = we did not so that the compiler doesn't optimize away the BUG() which is there= to catch such erroneous returns. That said, could we please add __noreturn to the implementation of cpu_die(= ) in arch/arm64/kernel/smp.c? i.e. the fixup below. With that fixup: Acked-by: Mark Rutland Mark. ---->8---- diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ffc5d76cf695..a98a76f7c1c6 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -361,7 +361,7 @@ void __cpu_die(unsigned int cpu) * Called from the idle thread for the CPU which has been shutdown. * */ -void cpu_die(void) +void __noreturn cpu_die(void) { unsigned int cpu =3D smp_processor_id(); const struct cpu_operations *ops =3D get_cpu_ops(cpu);