This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 8fc308fd868 sched/instrument: use g_running_tasks in stack monitor
8fc308fd868 is described below
commit 8fc308fd868430d86846d91d66429960b40e50d4
Author: anjiahao <[email protected]>
AuthorDate: Thu Dec 19 17:14:22 2024 +0800
sched/instrument: use g_running_tasks in stack monitor
running_task() is not stable in the stack monitor hooks:
nxsched_remove_readytorun() can change the task it returns while the
instrumentation hook is running.
Use g_running_tasks[this_cpu()] instead, which is the task actually
running on the current CPU.
Signed-off-by: anjiahao <[email protected]>
---
sched/instrument/stack_monitor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sched/instrument/stack_monitor.c b/sched/instrument/stack_monitor.c
index 43990e237af..1a8534b0463 100644
--- a/sched/instrument/stack_monitor.c
+++ b/sched/instrument/stack_monitor.c
@@ -61,7 +61,7 @@ struct instrument_s g_stack_monitor =
static void stack_monitor_enter(FAR void *this_fn, FAR void *call_site,
FAR void *arg)
{
- FAR struct tcb_s *tcb = running_task();
+ FAR struct tcb_s *tcb = g_running_tasks[this_cpu()];
FAR void *sp = &tcb;
size_t i;
@@ -101,7 +101,7 @@ static void stack_monitor_enter(FAR void *this_fn, FAR void
*call_site,
static void stack_monitor_leave(FAR void *this_fn, FAR void *call_site,
FAR void *arg)
{
- FAR struct tcb_s *tcb = running_task();
+ FAR struct tcb_s *tcb = g_running_tasks[this_cpu()];
FAR void *sp = &tcb;
if (tcb == NULL || tcb->level == 0 || sp < tcb->stack_base_ptr ||