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 b18d59e1791ce2afdb4d0bc2c9334ddc5b2ee384
Author: ouyangxiangzhen <[email protected]>
AuthorDate: Wed Nov 25 16:16:55 2026 +0800

    spinlock: restore the irq_restore pairing in spin_unlock_irqrestore
    
    spin_unlock_irqrestore() called spin_unlock_irqrestore_notrace(), whose
    inner up_irq_restore() does not run the critmon IRQ-disable accounting.
    The matching spin_lock_irqsave() had raised the counter with irq_save(),
    so after the first lock/unlock pair every later irq_save() of the task
    returned early and the IRQ-disabled time was no longer measured.  Use
    spin_unlock_notrace() and then irq_restore() explicitly, as the
    reference implementation does.
    
    This is a series-original fix: it aligns the merged unlock helper with
    the reference pairing.
    
    Assisted-By: mimo-v2.6-pro
    Signed-off-by: ouyangxiangzhen <[email protected]>
---
 include/nuttx/spinlock.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h
index b0a5ce87a56..44cd6efbb56 100644
--- a/include/nuttx/spinlock.h
+++ b/include/nuttx/spinlock.h
@@ -1044,11 +1044,12 @@ void spin_unlock_irqrestore(FAR volatile spinlock_t 
*lock, irqstate_t flags)
 
   /* Unlock without trace note */
 
-  spin_unlock_irqrestore_notrace(lock, flags);
+  spin_unlock_notrace(lock);
 
   /* Notify that we are unlocking the spinlock */
 
   sched_note_spinlock_unlock(lock);
+  irq_restore(flags);
 }
 #else
 #  define spin_unlock_irqrestore(l, f) ((void)(l), irq_restore(f))

Reply via email to