Skip to content

Commit

Permalink
kernel shell, stacks shell commands: iterate unlocked on SMP
Browse files Browse the repository at this point in the history
call k_thread_foreach_unlocked to avoid assertions caused
by calling shell_print while holding a global lock

Signed-off-by: Maxim Adelman <[email protected]>
(cherry picked from commit ecf2cb5)
  • Loading branch information
Maxim Adelman authored and finikorg committed Oct 31, 2023
1 parent 2e98b1f commit b8ff36f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions subsys/shell/modules/kernel_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ static int cmd_kernel_threads(const struct shell *shell,

shell_print(shell, "Scheduler: %u since last call", sys_clock_elapsed());
shell_print(shell, "Threads:");

#ifdef CONFIG_SMP
k_thread_foreach_unlocked(shell_tdata_dump, (void *)shell);
#else
k_thread_foreach(shell_tdata_dump, (void *)shell);
#endif
return 0;
}

Expand Down Expand Up @@ -184,7 +189,12 @@ static int cmd_kernel_stacks(const struct shell *shell,

ARG_UNUSED(argc);
ARG_UNUSED(argv);

#ifdef CONFIG_SMP
k_thread_foreach_unlocked(shell_stack_dump, (void *)shell);
#else
k_thread_foreach(shell_stack_dump, (void *)shell);
#endif

/* Placeholder logic for interrupt stack until we have better
* kernel support, including dumping arch-specific exception-related
Expand Down

0 comments on commit b8ff36f

Please sign in to comment.