You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2021/09/29 07:23:24 UTC

[incubator-nuttx] 02/02: sched/sched/remove_readytorun.c: Fix CPU affinity issues in SMP

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

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

commit dfc08a0b6600c611f06a4b96c5870807c2e988cc
Author: chenhonglin <ch...@xiaomi.com>
AuthorDate: Tue Sep 28 11:28:05 2021 +0800

    sched/sched/remove_readytorun.c: Fix CPU affinity issues in SMP
    
    the logical may choose the head of g_readytorun(the greatest priority)
    task as the next while ignoring the cpu affinity of it.
    
    Signed-off-by: chenhonglin <ch...@xiaomi.com>
---
 sched/sched/sched_removereadytorun.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sched/sched/sched_removereadytorun.c b/sched/sched/sched_removereadytorun.c
index 170e18b..398a348 100644
--- a/sched/sched/sched_removereadytorun.c
+++ b/sched/sched/sched_removereadytorun.c
@@ -209,20 +209,16 @@ bool nxsched_remove_readytorun(FAR struct tcb_s *rtcb)
 
       if (rtrtcb != NULL && rtrtcb->sched_priority >= nxttcb->sched_priority)
         {
-          FAR struct tcb_s *tmptcb;
-
-          /* The TCB at the head of the ready to run list has the higher
-           * priority.  Remove that task from the head of the g_readytorun
+          /* The TCB rtrtcb has the higher priority and it can be run on
+           * target CPU. Remove that task (rtrtcb) from the g_readytorun
            * list and add to the head of the g_assignedtasks[cpu] list.
            */
 
-          tmptcb = (FAR struct tcb_s *)
-            dq_remfirst((FAR dq_queue_t *)&g_readytorun);
-
-          dq_addfirst((FAR dq_entry_t *)tmptcb, tasklist);
+          dq_rem((FAR dq_entry_t *)rtrtcb, (FAR dq_queue_t *)&g_readytorun);
+          dq_addfirst((FAR dq_entry_t *)rtrtcb, tasklist);
 
-          tmptcb->cpu = cpu;
-          nxttcb = tmptcb;
+          rtrtcb->cpu = cpu;
+          nxttcb = rtrtcb;
         }
 
       /* Will pre-emption be disabled after the switch?  If the lockcount is