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 57a0b759f792971d92e4cd623fe6bed14f9817a8
Author: ouyangxiangzhen <[email protected]>
AuthorDate: Wed Nov 11 11:26:45 2026 +0800

    hrtimer: use SPIN_WAIT/SPIN_KICK for lock waiting
    
    The hrtimer cancel-sync wait loop slept on UP_WFE() and the running
    mark release woke it with UP_SEV() directly, bypassing the lock wait
    policy introduced by the spinlock wait-policy change.  Route both
    through the policy hooks: SPIN_WAIT() in the wait loop and SPIN_KICK()
    after the release.  Under SPINWAIT_PM this keeps the WFE/SEV pairing
    (with the DSB-before-SEV ordering carried by UP_WFESEV()); under
    SPINWAIT_RELAX the wait degenerates to the relax hint and the kick is
    empty, matching the spinlock paths.
    
    Assisted-by: mimo-v2.6-pro
    Signed-off-by: ouyangxiangzhen <[email protected]>
---
 sched/hrtimer/hrtimer.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sched/hrtimer/hrtimer.h b/sched/hrtimer/hrtimer.h
index 79ee9a8637e..682715a7a0c 100644
--- a/sched/hrtimer/hrtimer.h
+++ b/sched/hrtimer/hrtimer.h
@@ -33,6 +33,7 @@
 #include <nuttx/hrtimer.h>
 #include <nuttx/list.h>
 #include <nuttx/seqlock.h>
+#include <nuttx/spinlock.h>
 
 #include <sys/tree.h>
 
@@ -533,11 +534,9 @@ DEFINE_HRTIMER_READ(32, uint32_t)
 static inline_function
 void hrtimer_unmark_running(int cpu)
 {
-#ifdef CONFIG_SMP
   hrtimer_mark_running(NULL, cpu);
-  UP_SEV();
-#else
-  UNUSED(cpu);
+#ifdef CONFIG_SMP
+  SPIN_KICK();
 #endif
 }
 
@@ -669,7 +668,7 @@ static inline_function void hrtimer_wait(FAR hrtimer_t 
*timer)
             }
           else
             {
-              UP_WFE();
+              SPIN_WAIT();
             }
         }
     }

Reply via email to