-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Arch: allIssues that apply to all architecturesIssues that apply to all architecturesArea: KernelKernel issuesKernel issuesOS: LinuxIssues related to Linux (building system, etc)Issues related to Linux (building system, etc)Type: BugSomething isn't workingSomething isn't working
Description
Description / Steps to reproduce the issue
The round robin scheduling logic causes crashes via:
nuttx/sched/sched/sched_removereadytorun.c
Lines 287 to 294 in db31e56
| bool nxsched_remove_readytorun(FAR struct tcb_s *tcb) | |
| { | |
| if (tcb->task_state == TSTATE_TASK_RUNNING) | |
| { | |
| DEBUGASSERT(tcb->cpu == this_cpu()); | |
| nxsched_remove_running(tcb); | |
| return true; | |
| } |
The crash occurs when the task being pre-empted is running on a different CPU / core. The call tree is as follows:
_assert() at assert.c:906 0xa001f690
__assert() at lib_assert.c:38 0xa0005d4a
nxsched_remove_readytorun() at sched_removereadytorun.c:291 0xa0027f2c
nxsched_reprioritize_rtr() at sched_reprioritizertr.c:67 0xa00214f2
nxsched_process_roundrobin() at sched_roundrobin.c:141 0xa003c800
nxsched_cpu_scheduler() at sched_processtimer.c:77 0xa003c424
nxsched_process_scheduler() at sched_processtimer.c:134 0xa003c424
nxsched_process_timer() at sched_processtimer.c:189 0xa003c424
This happens when the system tick advances. An arbitrary CPU will handle the timer interrupt and advance the system ticker. It will then try to run the round robin scheduling logic for every CPU.
nuttx/sched/sched/sched_processtimer.c
Lines 128 to 138 in db31e56
| flags = enter_critical_section(); | |
| /* Perform scheduler operations on all CPUs */ | |
| for (i = 0; i < CONFIG_SMP_NCPUS; i++) | |
| { | |
| nxsched_cpu_scheduler(i); | |
| } | |
| leave_critical_section(flags); | |
| } |
Pre-empting a task on another CPU directly will obviously not work -> crash.
What do you think @hujun260 should this be handled by your SMP call logic, or something else ?
On which OS does this issue occur?
[OS: Linux]
What is the version of your OS?
Ubuntu
NuttX Version
master
Issue Architecture
[Arch: all]
Issue Area
[Area: Kernel]
Verification
- I have verified before submitting the report.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Arch: allIssues that apply to all architecturesIssues that apply to all architecturesArea: KernelKernel issuesKernel issuesOS: LinuxIssues related to Linux (building system, etc)Issues related to Linux (building system, etc)Type: BugSomething isn't workingSomething isn't working