All of lore.kernel.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
	Nathan Chancellor <nathan@kernel.org>,
	llvm@lists.linux.dev, linux-kernel@vger.kernel.org,
	clang-built-linux@googlegroups.com,
	Paul Mackerras <paulus@samba.org>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 2/2] powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto
Date: Thu, 26 Aug 2021 08:47:58 -0500	[thread overview]
Message-ID: <20210826134758.GZ1583@gate.crashing.org> (raw)
In-Reply-To: <3fad8702-278a-d9f9-1882-6958ce570bcc@csgroup.eu>

On Thu, Aug 26, 2021 at 08:37:09AM +0200, Christophe Leroy wrote:
> Le 26/08/2021 à 05:21, Michael Ellerman a écrit :
> >This patch seems to fix it. Not sure if that's just papering over it 
> >though.
> >
> >diff --git a/arch/powerpc/include/asm/bug.h 
> >b/arch/powerpc/include/asm/bug.h
> >index 1ee0f22313ee..75fcb4370d96 100644
> >--- a/arch/powerpc/include/asm/bug.h
> >+++ b/arch/powerpc/include/asm/bug.h
> >@@ -119,7 +119,7 @@ __label_warn_on:					 \
> >  								\
> >  			WARN_ENTRY(PPC_TLNEI " %4, 0",		\
> >  				   BUGFLAG_WARNING | 
> >  				   BUGFLAG_TAINT(TAINT_WARN),	\
> >-				   __label_warn_on, "r" (x));	\
> >+				   __label_warn_on, "r" (!!(x))); \
> >  			break;					\
> >  __label_warn_on:						\
> >  			__ret_warn_on = true;			\
> 
> But for a simple WARN_ON() call:
> 
> void test(unsigned long b)
> {
> 	WARN_ON(b);
> }
> 
> Without your change with GCC you get:
> 
> 00000000000012d0 <.test>:
>     12d0:	0b 03 00 00 	tdnei   r3,0
>     12d4:	4e 80 00 20 	blr
> 
> 
> With the !! change you get:
> 
> 00000000000012d0 <.test>:
>     12d0:	31 23 ff ff 	addic   r9,r3,-1
>     12d4:	7d 29 19 10 	subfe   r9,r9,r3
>     12d8:	0b 09 00 00 	tdnei   r9,0
>     12dc:	4e 80 00 20 	blr

That is because the asm (unlike the builtin) cannot be optimised by the
compiler.


Segher

WARNING: multiple messages have this Message-ID (diff)
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: llvm@lists.linux.dev, linux-kernel@vger.kernel.org,
	Nathan Chancellor <nathan@kernel.org>,
	clang-built-linux@googlegroups.com,
	Paul Mackerras <paulus@samba.org>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 2/2] powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto
Date: Thu, 26 Aug 2021 08:47:58 -0500	[thread overview]
Message-ID: <20210826134758.GZ1583@gate.crashing.org> (raw)
In-Reply-To: <3fad8702-278a-d9f9-1882-6958ce570bcc@csgroup.eu>

On Thu, Aug 26, 2021 at 08:37:09AM +0200, Christophe Leroy wrote:
> Le 26/08/2021 à 05:21, Michael Ellerman a écrit :
> >This patch seems to fix it. Not sure if that's just papering over it 
> >though.
> >
> >diff --git a/arch/powerpc/include/asm/bug.h 
> >b/arch/powerpc/include/asm/bug.h
> >index 1ee0f22313ee..75fcb4370d96 100644
> >--- a/arch/powerpc/include/asm/bug.h
> >+++ b/arch/powerpc/include/asm/bug.h
> >@@ -119,7 +119,7 @@ __label_warn_on:					 \
> >  								\
> >  			WARN_ENTRY(PPC_TLNEI " %4, 0",		\
> >  				   BUGFLAG_WARNING | 
> >  				   BUGFLAG_TAINT(TAINT_WARN),	\
> >-				   __label_warn_on, "r" (x));	\
> >+				   __label_warn_on, "r" (!!(x))); \
> >  			break;					\
> >  __label_warn_on:						\
> >  			__ret_warn_on = true;			\
> 
> But for a simple WARN_ON() call:
> 
> void test(unsigned long b)
> {
> 	WARN_ON(b);
> }
> 
> Without your change with GCC you get:
> 
> 00000000000012d0 <.test>:
>     12d0:	0b 03 00 00 	tdnei   r3,0
>     12d4:	4e 80 00 20 	blr
> 
> 
> With the !! change you get:
> 
> 00000000000012d0 <.test>:
>     12d0:	31 23 ff ff 	addic   r9,r3,-1
>     12d4:	7d 29 19 10 	subfe   r9,r9,r3
>     12d8:	0b 09 00 00 	tdnei   r9,0
>     12dc:	4e 80 00 20 	blr

That is because the asm (unlike the builtin) cannot be optimised by the
compiler.


Segher

  reply	other threads:[~2021-08-26 14:07 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13 16:38 [PATCH v2 1/2] powerpc/bug: Remove specific powerpc BUG_ON() and WARN_ON() on PPC32 Christophe Leroy
2021-04-13 16:38 ` Christophe Leroy
2021-04-13 16:38 ` [PATCH v2 2/2] powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto Christophe Leroy
2021-04-13 16:38   ` Christophe Leroy
2021-08-13  6:19   ` Nicholas Piggin
2021-08-13  6:19     ` Nicholas Piggin
2021-08-15  3:49   ` Michael Ellerman
2021-08-15  3:49     ` Michael Ellerman
2021-08-25 21:25   ` Nathan Chancellor
2021-08-25 21:25     ` Nathan Chancellor
2021-08-26  3:21     ` Michael Ellerman
2021-08-26  3:21       ` Michael Ellerman
2021-08-26  6:37       ` Christophe Leroy
2021-08-26  6:37         ` Christophe Leroy
2021-08-26 13:47         ` Segher Boessenkool [this message]
2021-08-26 13:47           ` Segher Boessenkool
2021-08-26 14:45         ` Michael Ellerman
2021-08-26 14:45           ` Michael Ellerman
2021-08-26 14:53           ` Christophe Leroy
2021-08-26 14:53             ` Christophe Leroy
2021-08-26 14:12       ` Segher Boessenkool
2021-08-26 14:12         ` Segher Boessenkool
2021-08-26 18:54       ` Nathan Chancellor
2021-08-26 18:54         ` Nathan Chancellor
2021-08-26 23:55         ` Nathan Chancellor
2021-08-26 23:55           ` Nathan Chancellor
2021-08-27  7:53           ` Michael Ellerman
2021-08-27  7:53             ` Michael Ellerman
2021-08-13  6:08 ` [PATCH v2 1/2] powerpc/bug: Remove specific powerpc BUG_ON() and WARN_ON() on PPC32 Nicholas Piggin
2021-08-13  6:08   ` Nicholas Piggin
2021-08-18 15:06   ` Segher Boessenkool
2021-08-18 15:06     ` Segher Boessenkool
2021-08-26  3:26     ` Nicholas Piggin
2021-08-26  3:26       ` Nicholas Piggin
2021-08-26 12:49       ` Segher Boessenkool
2021-08-26 12:49         ` Segher Boessenkool
2021-08-26 13:57         ` Nicholas Piggin
2021-08-26 13:57           ` Nicholas Piggin
2021-08-26 14:37           ` Segher Boessenkool
2021-08-26 14:37             ` Segher Boessenkool
2021-08-26 15:04             ` Nicholas Piggin
2021-08-26 15:04               ` Nicholas Piggin
2021-08-26 15:30               ` Segher Boessenkool
2021-08-26 15:30                 ` Segher Boessenkool
2021-08-27  1:28                 ` Nicholas Piggin
2021-08-27  1:28                   ` Nicholas Piggin
2021-08-18 13:38 ` Michael Ellerman
2021-08-18 13:38   ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210826134758.GZ1583@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=llvm@lists.linux.dev \
    --cc=mpe@ellerman.id.au \
    --cc=nathan@kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.