incubator-nuttx/sched/irq
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
..
Make.defs arch, include, sched : Refactor ARCH_GLOBAL_IRQDISABLE related code 2020-09-03 10:20:20 +08:00
irq.h sched/irq and sched/sched: Measurement of interrupt handler duration used to be available only in Tickless mode since it used the high resolution Tickless timer to measure interrupt time. This commit adds CONFIG_SCHED_IRQMONITOR_GETTIME which, if enabled, will force the interrupt duration caculation to use the same high-resolution, platform-specific timer as is used with the Critical Section Monitor. This leads to two improvements: (1) You can now measure interrupt duration in non-Tickless mode, and (2) in either mode, the interrupt duration and the critical section measures will use the same high-resulotion timer and should, therefore, never be any descripancy due to different clock sources. 2018-11-26 11:29:20 -06:00
irq_attach.c Rename clock_systime[r|spec] to clock_systime_[ticks|timespec] 2020-05-10 14:35:50 -06:00
irq_chain.c Change all files come from Xiaomi/Pinecone to Apache License 2.0 2020-08-22 17:37:21 -06:00
irq_csection.c sched: irq: Fix enter_critical_section() in an irq handler for SMP 2020-11-03 08:19:41 +01:00
irq_dispatch.c Add syscall and irqhandler hooks in sched_note.h 2020-06-16 14:04:53 -03:00
irq_foreach.c sched/irq: Add a configuration option to show interrupt information via a procfs file. 2018-01-12 18:26:46 -06:00
irq_initialize.c Call up_irqinitialize from irq subsystem 2020-02-08 07:39:22 -06:00
irq_procfs.c Rename clock_systime[r|spec] to clock_systime_[ticks|timespec] 2020-05-10 14:35:50 -06:00
irq_spinlock.c arch, include, sched : Refactor ARCH_GLOBAL_IRQDISABLE related code 2020-09-03 10:20:20 +08:00
irq_unexpectedisr.c Fix wait loop and void cast (#24) 2020-01-02 10:54:43 -06:00