]> err.no Git - linux-2.6/commitdiff
coredump: turn core_state->nr_threads into atomic_t
authorOleg Nesterov <oleg@tv-sign.ru>
Fri, 25 Jul 2008 08:47:42 +0000 (01:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 25 Jul 2008 17:53:39 +0000 (10:53 -0700)
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>
fs/exec.c
include/linux/mm_types.h
kernel/exit.c

index c74bb34eeeff032f1d45809bc2a736e15bbab8e2..15d493fe8aa3201655511b6baf3bce5caf25f5b8 100644 (file)
--- 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;
 }
 
index c0b1747b61a5526c3aed33bb1975d46a50c7fe3b..ae99a28ba6ae4cbc5c6ca093163501254b7c2db3 100644 (file)
@@ -160,7 +160,7 @@ struct vm_area_struct {
 };
 
 struct core_state {
-       int nr_threads;
+       atomic_t nr_threads;
        struct completion startup;
 };
 
index 988e232254e9ace0cf4a4afae854c256102fb849..63d82957baae26886deaad373e6112bc6a255689 100644 (file)
@@ -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);