[RFC PATCH] sched/core: Enhanced debug logs in do_task_dead()

From: Zhongqiu Han
Date: Tue Dec 10 2024 - 08:46:06 EST


If BUG() is a NOP, dump the problematic stack for debugging purposes.

Signed-off-by: Zhongqiu Han <quic_zhonhan@xxxxxxxxxxx>
---
If BUG() is a NOP, it should make sense for debugging purposes. However,
just arising the patch with RFC, because at least for now, I haven't found
a definition of BUG() as NOP in various architectures. Thanks~

kernel/sched/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index f59f2c0f6e32..fc36a9c5c136 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6774,7 +6774,11 @@ void __noreturn do_task_dead(void)
__schedule(SM_NONE);
BUG();

- /* Avoid "noreturn function does return" - but don't continue if BUG() is a NOP: */
+ /*
+ * Don't continue if BUG() is a NOP to avoid "noreturn function
+ * does return" and dump stack for this case.
+ */
+ dump_stack();
for (;;)
cpu_relax();
}
--
2.25.1