From d4f50e12cbe1bcc23ab01a7daac1d078759bf933 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Thu, 9 Jul 2009 23:28:49 +0200 Subject: [PATCH] --- yaml --- r: 157315 b: refs/heads/master c: 967cc5371113f9806b39a2ebb2174af2883d96fe h: refs/heads/master i: 157313: 063608336be098d173a35ae3509a5f92b13ecbbe 157311: a73562f22c3563ca81e62962a7d6dfecd007ffc2 v: v3 --- [refs] | 2 +- trunk/lib/is_single_threaded.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 57ac203ba14f..01cd1d2c9dcd 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 5bb459bb45d1ad3c177485dcf0af01580aa31125 +refs/heads/master: 967cc5371113f9806b39a2ebb2174af2883d96fe diff --git a/trunk/lib/is_single_threaded.c b/trunk/lib/is_single_threaded.c index 434010980bdf..bd2bea963364 100644 --- a/trunk/lib/is_single_threaded.c +++ b/trunk/lib/is_single_threaded.c @@ -22,8 +22,6 @@ bool current_is_single_threaded(void) struct task_struct *p, *t; bool ret; - might_sleep(); - if (atomic_read(&task->signal->live) != 1) return false; @@ -31,7 +29,6 @@ bool current_is_single_threaded(void) return true; ret = false; - down_write(&mm->mmap_sem); rcu_read_lock(); for_each_process(p) { if (unlikely(p->flags & PF_KTHREAD)) @@ -45,12 +42,17 @@ bool current_is_single_threaded(void) goto found; if (likely(t->mm)) break; + /* + * t->mm == NULL. Make sure next_thread/next_task + * will see other CLONE_VM tasks which might be + * forked before exiting. + */ + smp_rmb(); } while_each_thread(p, t); } ret = true; found: rcu_read_unlock(); - up_write(&mm->mmap_sem); return ret; }