This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 82efbd5 sched: group: Fix group_kill_children() for SMP
82efbd5 is described below
commit 82efbd5e6fac82cc0c397943b90b49c6fd3a1c7e
Author: Masayuki Ishikawa <[email protected]>
AuthorDate: Wed Feb 3 09:34:14 2021 +0900
sched: group: Fix group_kill_children() for SMP
Summary:
- During testing iperf -s with lc823450-xgevk:rndis,
I noticed that hard fault happens
- Finally, I found that group_kill_children() is not
not protected by a critical section
- This commit fixes this issue
Impact:
- SMP only
Testing:
- Tested with iperf with the following configurations
- lc823450-xgevk:rndis, spresense:rndis_smp
- Tested with ostest with the following configurations
- lc823450-xgevk:rndis, esp32-devkitc:smp (QEMU)
- sabre-6quad:smp (QEMU), maix-bit:smp (QEMU)
- spresense:rndis_smp, sim:smp
Signed-off-by: Masayuki Ishikawa <[email protected]>
---
sched/group/group_killchildren.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sched/group/group_killchildren.c b/sched/group/group_killchildren.c
index 86a7bf9..e69c500 100644
--- a/sched/group/group_killchildren.c
+++ b/sched/group/group_killchildren.c
@@ -131,14 +131,26 @@ int group_kill_children(FAR struct tcb_s *tcb)
{
int ret;
+#ifdef CONFIG_SMP
+ /* NOTE: sched_lock() is not enough for SMP
+ * because tcb->group will be accessed from the child tasks
+ */
+
+ irqstate_t flags = enter_critical_section();
+#else
/* Lock the scheduler so that there this thread will not lose priority
* until all of its children are suspended.
*/
sched_lock();
+#endif
ret = group_foreachchild(tcb->group, group_kill_children_handler,
(FAR void *)((uintptr_t)tcb->pid));
+#ifdef CONFIG_SMP
+ leave_critical_section(flags);
+#else
sched_unlock();
+#endif
return ret;
}