aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 c74bb34eeeff..15d493fe8aa3 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,
1591 } 1591 }
1592 rcu_read_unlock(); 1592 rcu_read_unlock();
1593done: 1593done:
1594 core_state->nr_threads = nr; 1594 atomic_set(&core_state->nr_threads, nr);
1595 return nr; 1595 return nr;
1596} 1596}
1597 1597
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index c0b1747b61a5..ae99a28ba6ae 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -160,7 +160,7 @@ struct vm_area_struct {
160}; 160};
161 161
162struct core_state { 162struct core_state {
163 int nr_threads; 163 atomic_t nr_threads;
164 struct completion startup; 164 struct completion startup;
165}; 165};
166 166
diff --git a/kernel/exit.c b/kernel/exit.c
index 988e232254e9..63d82957baae 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -678,10 +678,9 @@ static void exit_mm(struct task_struct * tsk)
678 down_read(&mm->mmap_sem); 678 down_read(&mm->mmap_sem);
679 if (mm->core_state) { 679 if (mm->core_state) {
680 up_read(&mm->mmap_sem); 680 up_read(&mm->mmap_sem);
681 down_write(&mm->mmap_sem); 681
682 if (!--mm->core_state->nr_threads) 682 if (atomic_dec_and_test(&mm->core_state->nr_threads))
683 complete(&mm->core_state->startup); 683 complete(&mm->core_state->startup);
684 up_write(&mm->mmap_sem);
685 684
686 wait_for_completion(&mm->core_done); 685 wait_for_completion(&mm->core_done);
687 down_read(&mm->mmap_sem); 686 down_read(&mm->mmap_sem);