mirror of
https://github.com/apache/nuttx.git
synced 2025-05-08 22:32:04 +08:00
sched/affinity: Fix CPU_LOCKED functionality for some SMP calls
For some SMP calls it is necessary to lock the current CPU for the process receiving the SMP call. This is done by setting the CPU affinity to the current CPU and preventing the CPU selection algorithm from switching CPUs. dtcb->flags |= TCB_FLAG_CPU_LOCKED; CPU_SET(dtcb->cpu, &dtcb->affinity); However, this logic is currently broken, as CPU_SET is defined as: #define CPU_SET(c,s) do { *(s) |= (1u << (c)); } while (0) In order to assign tcb->cpu (the current CPU) to the affinity mask, the mask must be cleared first by calling CPU_ZERO.
This commit is contained in:
parent
8832136b69
commit
c12aa5663d
@ -130,6 +130,7 @@ int sched_backtrace(pid_t tid, FAR void **buffer, int size, int skip)
|
||||
arg.need_restore = true;
|
||||
|
||||
tcb->flags |= TCB_FLAG_CPU_LOCKED;
|
||||
CPU_ZERO(&tcb->affinity);
|
||||
CPU_SET(tcb->cpu, &tcb->affinity);
|
||||
}
|
||||
|
||||
|
@ -240,6 +240,7 @@ static inline void nxsched_running_setpriority(FAR struct tcb_s *tcb,
|
||||
arg.need_restore = true;
|
||||
|
||||
tcb->flags |= TCB_FLAG_CPU_LOCKED;
|
||||
CPU_ZERO(&tcb->affinity);
|
||||
CPU_SET(tcb->cpu, &tcb->affinity);
|
||||
}
|
||||
|
||||
|
@ -161,6 +161,7 @@ void nxsched_suspend(FAR struct tcb_s *tcb)
|
||||
arg.need_restore = true;
|
||||
|
||||
tcb->flags |= TCB_FLAG_CPU_LOCKED;
|
||||
CPU_ZERO(&tcb->affinity);
|
||||
CPU_SET(tcb->cpu, &tcb->affinity);
|
||||
}
|
||||
|
||||
|
@ -181,6 +181,7 @@ static int nxsig_queue_action(FAR struct tcb_s *stcb, siginfo_t *info)
|
||||
arg.need_restore = true;
|
||||
|
||||
stcb->flags |= TCB_FLAG_CPU_LOCKED;
|
||||
CPU_ZERO(&stcb->affinity);
|
||||
CPU_SET(stcb->cpu, &stcb->affinity);
|
||||
}
|
||||
|
||||
|
@ -241,6 +241,7 @@ static int nxtask_restart(pid_t pid)
|
||||
arg.need_restore = true;
|
||||
|
||||
tcb->flags |= TCB_FLAG_CPU_LOCKED;
|
||||
CPU_ZERO(&tcb->affinity);
|
||||
CPU_SET(tcb->cpu, &tcb->affinity);
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,7 @@ int nxtask_terminate(pid_t pid)
|
||||
tcb_flags = dtcb->flags;
|
||||
dtcb->flags |= TCB_FLAG_CPU_LOCKED;
|
||||
affinity = dtcb->affinity;
|
||||
CPU_ZERO(&dtcb->affinity);
|
||||
CPU_SET(dtcb->cpu, &dtcb->affinity);
|
||||
|
||||
ret = nxsched_smp_call_single(dtcb->cpu, terminat_handler,
|
||||
|
Loading…
x
Reference in New Issue
Block a user