This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch releases/10.0
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 2629090a6ff5dfb2366266494a98540ff3728f44
Author: Masayuki Ishikawa <[email protected]>
AuthorDate: Thu Oct 15 09:43:27 2020 +0900

    sched: Fix DEBUGASSERT() in sched_unlock() for SMP
    
    Summary:
    - I noticed DEBUGASSERT() happens in sched_unlock()
    - The test was Wi-Fi audio streaming stress test with spresense 3cores
    - Actually, g_cpu_schedlock was locked but g_cpu_lockset was incorrect
    - Finally, I found that cpu was obtained before enter_critical_section()
    - And the task was moved from one cpu to another cpu
    - However, that call should be done within the critical section
    - This commit fixes this issue
    
    Impact:
    - Affects SMP only
    
    Testing:
    - Tested with spresense:wifi_smp (both NCPUS=2 and 3)
    - Tested with lc823450-xgevk:rndis
    - Tested with maix-bit:smp (QEMU)
    - Tested with esp32-core:smp (QEMU)
    - Tested with sabre-6quad:smp (QEMU)
    
    Signed-off-by: Masayuki Ishikawa <[email protected]>
---
 sched/sched/sched_unlock.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sched/sched/sched_unlock.c b/sched/sched/sched_unlock.c
index 857c682..3991b16 100644
--- a/sched/sched/sched_unlock.c
+++ b/sched/sched/sched_unlock.c
@@ -54,14 +54,12 @@
 int sched_unlock(void)
 {
   FAR struct tcb_s *rtcb;
-  int cpu;
 
   /* This operation is safe because the scheduler is locked and no context
    * switch may occur.
    */
 
-  cpu  = this_cpu();
-  rtcb = current_task(cpu);
+  rtcb = this_task();
 
   /* Check for some special cases:  (1) rtcb may be NULL only during
    * early boot-up phases, and (2) sched_unlock() should have no
@@ -73,6 +71,7 @@ int sched_unlock(void)
       /* Prevent context switches throughout the following. */
 
       irqstate_t flags = enter_critical_section();
+      int cpu = this_cpu();
 
       /* Decrement the preemption lock counter */
 

Reply via email to