aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2008-07-25 01:47:42 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 10:53:39 -0700
commitc5f1cc8c1828486a61ab3e575da6e2c62b34d399 (patch)
tree9cc88e7d1dae063482e1e9117ded747578cbd7ad
parent8cd9c249128a59e8e833d454a784b0cbd338d468 (diff)
coredump: turn core_state->nr_threads into atomic_t
Turn core_state->nr_threads into atomic_t and kill now unneeded down_write(&mm->mmap_sem) in exit_mm(). Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/exec.c2
-rw-r--r--include/linux/mm_types.h2
-rw-r--r--kernel/exit.c5
3 files changed, 4 insertions, 5 deletions
diff --git a/fs/exec.c b/fs/exec.c
index c74bb34eeef..15d493fe8aa 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1591,7 +1591,7 @@ static inline int zap_threads(struct task_struct *tsk, struct mm_struct *mm,
}
rcu_read_unlock();
done:
- core_state->nr_threads = nr;
+ atomic_set(&core_state->nr_threads, nr);
return nr;
}
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index c0b1747b61a..ae99a28ba6a 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -160,7 +160,7 @@ struct vm_area_struct {
};
struct core_state {
- int nr_threads;
+ atomic_t nr_threads;
struct completion startup;
};
diff --git a/kernel/exit.c b/kernel/exit.c
index 988e232254e..63d82957baa 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -678,10 +678,9 @@ static void exit_mm(struct task_struct * tsk)
down_read(&mm->mmap_sem);
if (mm->core_state) {
up_read(&mm->mmap_sem);
- down_write(&mm->mmap_sem);
- if (!--mm->core_state->nr_threads)
+
+ if (atomic_dec_and_test(&mm->core_state->nr_threads))
complete(&mm->core_state->startup);
- up_write(&mm->mmap_sem);
wait_for_completion(&mm->core_done);
down_read(&mm->mmap_sem);