This is an automated email from the ASF dual-hosted git repository.
Donny9 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 ace658fb2bc armv8-m: skip scheduler bookkeeping without task switch
ace658fb2bc is described below
commit ace658fb2bcf51152cd55e1e5bc44399f659fec1
Author: chao an <[email protected]>
AuthorDate: Tue Oct 20 16:20:27 2026 +0800
armv8-m: skip scheduler bookkeeping without task switch
The ARMv8-M IRQ path can return to the interrupted task without
performing a context switch. In that case, calling
nxsched_switch_context() still runs scheduler switch bookkeeping even
though no task changed.
Guard the scheduler bookkeeping with a running-task comparison, but
keep reloading tcb->xcp.regs unconditionally. The unconditional reload
preserves cases such as signal delivery where the return register
context may be updated without switching tasks.
Signed-off-by: chao an <[email protected]>
---
arch/arm/src/armv8-m/arm_doirq.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/arch/arm/src/armv8-m/arm_doirq.c b/arch/arm/src/armv8-m/arm_doirq.c
index 22c011e3fa5..8f2206aae1b 100644
--- a/arch/arm/src/armv8-m/arm_doirq.c
+++ b/arch/arm/src/armv8-m/arm_doirq.c
@@ -115,20 +115,24 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
}
#endif
- /* Update scheduler parameters.
- * The arm-m architecture svc call will trigger an interrupt,
- * and the actual context switch is executed after doirq is completed,
- * so only the scheduling information needs to be updated in doirq.
- */
+ if (*running_task != tcb)
+ {
+ /* Update scheduler parameters.
+ * The arm-m architecture svc call will trigger an interrupt,
+ * and the actual context switch is executed after doirq is completed,
+ * so only the scheduling information needs to be updated in doirq.
+ */
- nxsched_switch_context(*running_task, tcb);
+ nxsched_switch_context(*running_task, tcb);
- /* Record the new "running" task when context switch occurred.
- * g_running_tasks[] is only used by assertion logic for reporting
- * crashes.
- */
+ /* Record the new "running" task when context switch occurred.
+ * g_running_tasks[] is only used by assertion logic for reporting
+ * crashes.
+ */
+
+ *running_task = tcb;
+ }
- *running_task = tcb;
regs = tcb->xcp.regs;
#endif