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 453cafdc4dd480365a93e82b8c884bda049fb82a Author: wangyongrong <[email protected]> AuthorDate: Tue Oct 20 15:08:38 2026 +0800 sched/irq: account IRQ-disabled time in enter_critical_section nxsched_critmon_irqdisable() was only hooked into irq_save() and irq_restore(), so critical sections entered through enter_critical_section() were never measured. Call it on both sides, after interrupts are disabled and before they are re-enabled, mirroring irq_save()/irq_restore(). Pick-adapted: the merged tree's enter/leave_critical_section() already go through the notrace variants (up_irq_save()/rspin lock paths), so the explicit accounting calls land at the same points as in the reference tree. Assisted-By: mimo-v2.6-pro Co-authored-by: Claude <[email protected]> Signed-off-by: wangyongrong <[email protected]> --- sched/irq/irq_csection.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sched/irq/irq_csection.c b/sched/irq/irq_csection.c index 781e992ff3e..91a336a5970 100644 --- a/sched/irq/irq_csection.c +++ b/sched/irq/irq_csection.c @@ -305,6 +305,18 @@ irqstate_t enter_critical_section(void) nxsched_critmon_busywait(false, return_address(0)); + /* Start counting the IRQ-disabled duration. + * + * enter_critical_section_notrace() deliberately bypasses the irq_save() + * wrapper where this accounting normally happens: in the non-SMP + * configuration it expands to a bare up_irq_save(), and in the SMP + * configuration to rspin_lock_irqsave_notrace(), neither of which + * accounts for the time. Do it explicitly here so that the critical + * sections entered through this function are measured as well. + */ + + nxsched_critmon_irqdisable(true, false, return_address(0)); + if (!up_interrupt_context()) { rtcb = this_task(); @@ -474,6 +486,13 @@ void leave_critical_section(irqstate_t flags) } } + /* Stop counting the IRQ-disabled duration. This must happen before + * interrupts are actually re-enabled below, mirroring the ordering in + * irq_restore(). + */ + + nxsched_critmon_irqdisable(false, false, return_address(0)); + leave_critical_section_notrace(flags); } #endif
