coredump: turn core_state->nr_threads into atomic_t
Subsystems (3)
PATCH 4/4 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 <[email protected]>
include/linux/mm_types.h | 2 +- kernel/exit.c | 5 ++--- fs/exec.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
include/linux/mm_types.h renamed from include/linux/mm_types.h~4_NR_ATOMIC +1 -1
@@ -160,7 +160,7 @@ struct vm_area_struct { };struct core_state { -int nr_threads; +atomic_t nr_threads;struct completion startup; };
kernel/exit.c renamed from kernel/exit.c~4_NR_ATOMIC +2 -3
@@ -667,10 +667,9 @@ static void exit_mm(struct task_struct *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);
fs/exec.c renamed from fs/exec.c~4_NR_ATOMIC +1 -1
@@ -1585,7 +1585,7 @@ static inline int zap_threads(struct tas }rcu_read_unlock (); done: - core_state->nr_threads = nr; +atomic_set (&core_state->nr_threads, nr); mm->core_state = core_state;return nr; }