linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 11/15] bugs/riscv: Pass in 'cond_str' to __BUG_FLAGS()
       [not found] <20250515124644.2958810-1-mingo@kernel.org>
@ 2025-05-15 12:46 ` Ingo Molnar
  2025-05-15 12:46 ` [PATCH 12/15] bugs/riscv: Concatenate 'cond_str' with '__FILE__' in __BUG_FLAGS(), to extend WARN_ON/BUG_ON output Ingo Molnar
  1 sibling, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2025-05-15 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Linus Torvalds, Peter Zijlstra, linux-arch,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	linux-riscv

Pass in the condition string from __WARN_FLAGS() to __BUG_FLAGS(),
but don't use it yet.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: linux-riscv@lists.infradead.org
Cc: <linux-arch@vger.kernel.org>
---
 arch/riscv/include/asm/bug.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h
index b22ee4d2c882..feaf456d465b 100644
--- a/arch/riscv/include/asm/bug.h
+++ b/arch/riscv/include/asm/bug.h
@@ -50,7 +50,7 @@ typedef u32 bug_insn_t;
 #endif
 
 #ifdef CONFIG_GENERIC_BUG
-#define __BUG_FLAGS(flags)					\
+#define __BUG_FLAGS(cond_str, flags)				\
 do {								\
 	__asm__ __volatile__ (					\
 		"1:\n\t"					\
@@ -66,17 +66,17 @@ do {								\
 		  "i" (sizeof(struct bug_entry)));              \
 } while (0)
 #else /* CONFIG_GENERIC_BUG */
-#define __BUG_FLAGS(flags) do {					\
+#define __BUG_FLAGS(cond_str, flags) do {			\
 	__asm__ __volatile__ ("ebreak\n");			\
 } while (0)
 #endif /* CONFIG_GENERIC_BUG */
 
 #define BUG() do {						\
-	__BUG_FLAGS(0);						\
+	__BUG_FLAGS("", 0);					\
 	unreachable();						\
 } while (0)
 
-#define __WARN_FLAGS(cond_str, flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
+#define __WARN_FLAGS(cond_str, flags) __BUG_FLAGS(cond_str, BUGFLAG_WARNING|(flags))
 
 #define HAVE_ARCH_BUG
 
-- 
2.45.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 12/15] bugs/riscv: Concatenate 'cond_str' with '__FILE__' in __BUG_FLAGS(), to extend WARN_ON/BUG_ON output
       [not found] <20250515124644.2958810-1-mingo@kernel.org>
  2025-05-15 12:46 ` [PATCH 11/15] bugs/riscv: Pass in 'cond_str' to __BUG_FLAGS() Ingo Molnar
@ 2025-05-15 12:46 ` Ingo Molnar
  2025-05-16 15:09   ` Alexandre Ghiti
  1 sibling, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2025-05-15 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Linus Torvalds, Peter Zijlstra, linux-arch,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	linux-riscv

Extend WARN_ON and BUG_ON style output from:

  WARNING: CPU: 0 PID: 0 at kernel/sched/core.c:8511 sched_init+0x20/0x410

to:

  WARNING: CPU: 0 PID: 0 at [idx < 0 && ptr] kernel/sched/core.c:8511 sched_init+0x20/0x410

Note that the output will be further reorganized later in this series.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: linux-riscv@lists.infradead.org
Cc: <linux-arch@vger.kernel.org>
---
 arch/riscv/include/asm/bug.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h
index feaf456d465b..da9b8e83934d 100644
--- a/arch/riscv/include/asm/bug.h
+++ b/arch/riscv/include/asm/bug.h
@@ -61,7 +61,7 @@ do {								\
 			".org 2b + %3\n\t"                      \
 			".popsection"				\
 		:						\
-		: "i" (__FILE__), "i" (__LINE__),		\
+		: "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__),	\
 		  "i" (flags),					\
 		  "i" (sizeof(struct bug_entry)));              \
 } while (0)
-- 
2.45.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 12/15] bugs/riscv: Concatenate 'cond_str' with '__FILE__' in __BUG_FLAGS(), to extend WARN_ON/BUG_ON output
  2025-05-15 12:46 ` [PATCH 12/15] bugs/riscv: Concatenate 'cond_str' with '__FILE__' in __BUG_FLAGS(), to extend WARN_ON/BUG_ON output Ingo Molnar
@ 2025-05-16 15:09   ` Alexandre Ghiti
  2025-05-16 15:45     ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Ghiti @ 2025-05-16 15:09 UTC (permalink / raw)
  To: Ingo Molnar, linux-kernel
  Cc: Linus Torvalds, Peter Zijlstra, linux-arch, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, linux-riscv

Hi Ingo,

On 15/05/2025 14:46, Ingo Molnar wrote:
> Extend WARN_ON and BUG_ON style output from:
>
>    WARNING: CPU: 0 PID: 0 at kernel/sched/core.c:8511 sched_init+0x20/0x410
>
> to:
>
>    WARNING: CPU: 0 PID: 0 at [idx < 0 && ptr] kernel/sched/core.c:8511 sched_init+0x20/0x410
>
> Note that the output will be further reorganized later in this series.
>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Cc: Paul Walmsley <paul.walmsley@sifive.com>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Albert Ou <aou@eecs.berkeley.edu>
> Cc: Alexandre Ghiti <alex@ghiti.fr>
> Cc: linux-riscv@lists.infradead.org
> Cc: <linux-arch@vger.kernel.org>
> ---
>   arch/riscv/include/asm/bug.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h
> index feaf456d465b..da9b8e83934d 100644
> --- a/arch/riscv/include/asm/bug.h
> +++ b/arch/riscv/include/asm/bug.h
> @@ -61,7 +61,7 @@ do {								\
>   			".org 2b + %3\n\t"                      \
>   			".popsection"				\
>   		:						\
> -		: "i" (__FILE__), "i" (__LINE__),		\
> +		: "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__),	\
>   		  "i" (flags),					\
>   		  "i" (sizeof(struct bug_entry)));              \
>   } while (0)

I have added a dummy WARN_ON_ONCE(pgtable_l5_enabled == true) and I get 
the following output:

WARNING: [pgtable_l5_enabled == true] arch/riscv/kernel/setup.c:364 at 
setup_arch+0x6c4/0x704, CPU#0: swapper/0

So you can add for riscv:

Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com> # riscv

Thanks,

Alex




_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 12/15] bugs/riscv: Concatenate 'cond_str' with '__FILE__' in __BUG_FLAGS(), to extend WARN_ON/BUG_ON output
  2025-05-16 15:09   ` Alexandre Ghiti
@ 2025-05-16 15:45     ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2025-05-16 15:45 UTC (permalink / raw)
  To: Alexandre Ghiti
  Cc: linux-kernel, Linus Torvalds, Peter Zijlstra, linux-arch,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv


* Alexandre Ghiti <alex@ghiti.fr> wrote:

> Hi Ingo,
> 
> On 15/05/2025 14:46, Ingo Molnar wrote:
> > Extend WARN_ON and BUG_ON style output from:
> > 
> >    WARNING: CPU: 0 PID: 0 at kernel/sched/core.c:8511 sched_init+0x20/0x410
> > 
> > to:
> > 
> >    WARNING: CPU: 0 PID: 0 at [idx < 0 && ptr] kernel/sched/core.c:8511 sched_init+0x20/0x410
> > 
> > Note that the output will be further reorganized later in this series.
> > 
> > Signed-off-by: Ingo Molnar <mingo@kernel.org>
> > Cc: Paul Walmsley <paul.walmsley@sifive.com>
> > Cc: Palmer Dabbelt <palmer@dabbelt.com>
> > Cc: Albert Ou <aou@eecs.berkeley.edu>
> > Cc: Alexandre Ghiti <alex@ghiti.fr>
> > Cc: linux-riscv@lists.infradead.org
> > Cc: <linux-arch@vger.kernel.org>
> > ---
> >   arch/riscv/include/asm/bug.h | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h
> > index feaf456d465b..da9b8e83934d 100644
> > --- a/arch/riscv/include/asm/bug.h
> > +++ b/arch/riscv/include/asm/bug.h
> > @@ -61,7 +61,7 @@ do {								\
> >   			".org 2b + %3\n\t"                      \
> >   			".popsection"				\
> >   		:						\
> > -		: "i" (__FILE__), "i" (__LINE__),		\
> > +		: "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__),	\
> >   		  "i" (flags),					\
> >   		  "i" (sizeof(struct bug_entry)));              \
> >   } while (0)
> 
> I have added a dummy WARN_ON_ONCE(pgtable_l5_enabled == true) and I get the
> following output:
> 
> WARNING: [pgtable_l5_enabled == true] arch/riscv/kernel/setup.c:364 at
> setup_arch+0x6c4/0x704, CPU#0: swapper/0
> 
> So you can add for riscv:
> 
> Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com> # riscv

Thanks, I've updated the tags section of the riscv patches.

BTW., if you tried the WIP.core/bugs tree it has a final (and silly) 
WARN_ON_ONCE()-testing commit as well:

   af0503e693cf ("bugs/core: Test WARN_ON_ONCE()")

   +       WARN_ON_ONCE(ptr == 0 && 1);

:-)

Thanks,

	Ingo

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-16 16:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250515124644.2958810-1-mingo@kernel.org>
2025-05-15 12:46 ` [PATCH 11/15] bugs/riscv: Pass in 'cond_str' to __BUG_FLAGS() Ingo Molnar
2025-05-15 12:46 ` [PATCH 12/15] bugs/riscv: Concatenate 'cond_str' with '__FILE__' in __BUG_FLAGS(), to extend WARN_ON/BUG_ON output Ingo Molnar
2025-05-16 15:09   ` Alexandre Ghiti
2025-05-16 15:45     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).