]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bugs/x86: Augment warnings output by concatenating 'cond_str' with the regular __FILE...
authorIngo Molnar <mingo@kernel.org>
Thu, 15 May 2025 12:46:34 +0000 (14:46 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 13 Jun 2025 08:25:32 +0000 (10:25 +0200)
This allows the reuse of the UD2 based 'struct bug_entry' low-overhead
_BUG_FLAGS() implementation and string-printing backend, without
having to add a new field.

An example:

If we have the following WARN_ON_ONCE() in kernel/sched/core.c:

WARN_ON_ONCE(idx < 0 && ptr);

Then previously _BUG_FLAGS() would store this string in bug_entry::file:

"kernel/sched/core.c"

After this patch, it would store and print:

"[idx < 0 && ptr] kernel/sched/core.c"

Which is an extended string that will be printed in warnings.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: linux-arch@vger.kernel.org
Link: https://lore.kernel.org/r/20250515124644.2958810-6-mingo@kernel.org
arch/x86/include/asm/bug.h

index aff1c6b7a7f3334bfb8d837fc9d28c69e4c9521c..8593976b32cbb145b6d88fa7d7dceb292c1a4099 100644 (file)
@@ -50,7 +50,7 @@ do {                                                                  \
                     "\t.org 2b+%c3\n"                                  \
                     ".popsection\n"                                    \
                     extra                                              \
-                    : : "i" (__FILE__), "i" (__LINE__),                \
+                    : : "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__),           \
                         "i" (flags),                                   \
                         "i" (sizeof(struct bug_entry)));               \
 } while (0)