nuttx/sched
Masayuki Ishikawa 6ec94082a1 sched: irq: Fix enter_critical_section() in an irq handler for SMP
Summary:
- I found a deadlock during Wi-Fi audio streaming test plus stress test
- The testing environment was spresense:wifi_smp (NCPUS=4)
- The deadlock happened because two CPUs called up_cpu_pause() almost simultaneously
- This situation should not happen, because up_cpu_pause() is called in a critical section
- Actually, the latter call was from nxsem_post() in an IRQ handler
- And when enter_critical_section() was called, irq_waitlock() detected a deadlock
- Then it called up_cpu_paused() to break the deadlock
- However, this resulted in setting g_cpu_irqset on the CPU
- Even though another CPU had held a g_cpu_irqlock
- This situation violates the critical section and should be avoided
- To avoid the situation, if a CPU sets g_cpu_irqset after calling up_cpu_paused()
- The CPU must release g_cpu_irqlock first
- Then retry irq_waitlock() to acquire g_cpu_irqlock

Impact:
- Affect SMP

Testing:
- Tested with spresense:wifi_smp (NCPUS=2 and 4)
- Tested with spresense:smp
- Tested with sim:smp
- Tested with sabre-6quad:smp (QEMU)
- Tested with maix-bit:smp (QEMU)
- Tested with esp32-core:smp (QEMU)
- Tested with lc823450-xgevk:rndis

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-11-03 08:19:41 +01:00
..
clock Rename clock_systime[r|spec] to clock_systime_[ticks|timespec] 2020-05-10 14:35:50 -06:00
environ global change: repace sched_xfree() to kxmm_free() 2020-04-09 10:29:28 -06:00
group Modify SIGSTP to SIGTSTP 2020-10-29 01:12:43 -07:00
init Modify SIGSTP to SIGTSTP 2020-10-29 01:12:43 -07:00
irq sched: irq: Fix enter_critical_section() in an irq handler for SMP 2020-11-03 08:19:41 +01:00
module modsym: Fix a printf format for berr 2020-04-13 16:20:09 +01:00
mqueue sched/wdog: Remove MAX_WDOGPARMS and related stuff 2020-08-14 08:19:50 -06:00
paging Rename clock_systime[r|spec] to clock_systime_[ticks|timespec] 2020-05-10 14:35:50 -06:00
pthread Revert "sched: Call up_[use|create]_stack after nxtask_setup_scheduler" 2020-10-22 18:31:31 +09:00
sched Fix build break when CONFIG_TASK_NAME_SIZE == 0 2020-11-01 18:46:26 -08:00
semaphore sched/wdog: Remove MAX_WDOGPARMS and related stuff 2020-08-14 08:19:50 -06:00
signal sched/signal/sig_default.c: Fix a comment 2020-10-30 19:57:06 -07:00
task Fix typos 2020-10-28 19:15:04 -07:00
timer Fix nxstyle warning 2020-08-22 17:37:21 -06:00
wdog sched/wdog: Remove MAX_WDOGPARMS and related stuff 2020-08-14 08:19:50 -06:00
wqueue sched/: Make more naming consistent 2020-05-16 13:39:03 -03:00
Kconfig Modify SIGSTP to SIGTSTP 2020-10-29 01:12:43 -07:00
Makefile Makefile: Fix Make.dep not updated by config changes 2020-07-28 03:59:45 -05:00