This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 1a86aac6c2d52fd9b48bc05a8f84d440f5407780
Author: wangzhi16 <[email protected]>
AuthorDate: Tue Sep 30 13:12:31 2025 +0800

    sched/misc: replace DEADLOCK_MAX with CONFIG_ARCH_DEADLOCKDUMP_MAX
    
    dump_deadlock() collected at most 8 deadlocked threads, a limit fixed
    by DEADLOCK_MAX in assert.c.  Make it configurable with
    CONFIG_ARCH_DEADLOCKDUMP_MAX (default 8), and drop the doubled period
    in the help text of ARCH_DEADLOCKDUMP.
    
    Signed-off-by: wangzhi16 <[email protected]>
---
 arch/Kconfig        | 10 +++++++++-
 sched/misc/assert.c |  7 +++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 8d3c5543c6f..9a90b204d92 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1301,7 +1301,15 @@ config ARCH_DEADLOCKDUMP
        bool "Dump dead lock thread"
        default "n"
        ---help---
-               This option will dump the dead lock thread when assert happen..
+               This option will dump the dead lock thread when assert happen.
+
+config ARCH_DEADLOCKDUMP_MAX
+       int "The maximum threads to dump when deadlock"
+       depends on ARCH_DEADLOCKDUMP
+       default 8
+       ---help---
+               This is the maximum number of threads to dump when deadlock in 
mutex
+               or spinlock.
 
 config ENDIAN_BIG
        bool "Big Endian Architecture"
diff --git a/sched/misc/assert.c b/sched/misc/assert.c
index 893eed295bd..4e8490549bc 100644
--- a/sched/misc/assert.c
+++ b/sched/misc/assert.c
@@ -64,8 +64,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-#define DEADLOCK_MAX 8
-
 /* The dump_lockholder() buffer must hold the deeper of the two backtrace
  * sources: the spinlock backtrace (CONFIG_LIBC_BACKTRACE_DEPTH) and this
  * tree's fixed mutex backtrace (CONFIG_LIBC_MUTEX_BACKTRACE, an
@@ -647,8 +645,9 @@ static void dump_lockholder(pid_t tid)
 
 static void dump_deadlock(void)
 {
-  pid_t deadlock[DEADLOCK_MAX];
-  size_t i = nxsched_collect_deadlock(deadlock, DEADLOCK_MAX);
+  pid_t deadlock[CONFIG_ARCH_DEADLOCKDUMP_MAX];
+  size_t i = nxsched_collect_deadlock(deadlock,
+                                      CONFIG_ARCH_DEADLOCKDUMP_MAX);
 
   while (i-- > 0)
     {

Reply via email to