From dbba7dea188d0724ec0f96d8faeca9f9948bda83 Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Tue, 20 Mar 2018 14:08:37 +0900 Subject: [PATCH] uti: Allow only the first do_fork() call to create a uti thread --- kernel/syscall.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/syscall.c b/kernel/syscall.c index 7401d1f4..e989ae35 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -2632,7 +2632,9 @@ retry_tid: ihk_mc_syscall_ret(new->uctx) = 0; new->status = PS_RUNNING; - if (old->mod_clone == SPAWN_TO_REMOTE) { + + /* Only the first do_fork() call creates a thread on a Linux CPU */ + if (__sync_bool_compare_and_swap(&old->mod_clone, SPAWN_TO_REMOTE, SPAWN_TO_LOCAL)) { new->mod_clone = SPAWNING_TO_REMOTE; if (old->mod_clone_arg) { new->mod_clone_arg = kmalloc(sizeof(struct uti_attr), @@ -9164,6 +9166,7 @@ utilthr_migrate() { struct thread *thread = cpu_local_var(current); + /* Don't inherit mod_clone */ if (thread->mod_clone == SPAWNING_TO_REMOTE) { thread->mod_clone = SPAWN_TO_LOCAL; util_thread(thread->mod_clone_arg);