diff options
author | Michal Hocko <mhocko@suse.com> | 2016-05-06 11:15:50 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2016-05-06 14:35:45 +1000 |
commit | b856ecf57a76ffc6e2d9ddf16bffefc0994ddb04 (patch) | |
tree | b60539512de62a5beeded330c74c847644d59276 | |
parent | 7107147b10928140d47134b0a0198f4c3c5b8b26 (diff) | |
download | linux-b856ecf57a76ffc6e2d9ddf16bffefc0994ddb04.tar.gz linux-b856ecf57a76ffc6e2d9ddf16bffefc0994ddb04.tar.xz |
coredump: make coredump_wait wait for mmap_sem for write killable
coredump_wait waits for mmap_sem for write currently which can prevent
oom_reaper to reclaim the oom victims address space asynchronously because
that requires mmap_sem for read. This might happen if the oom victim is
multi threaded and some thread(s) is holding mmap_sem for read (e.g. page
fault) and it is stuck in the page allocator while other thread(s) reached
coredump_wait already.
This patch simply uses down_write_killable and bails out with EINTR if the
lock got interrupted by the fatal signal. do_coredump will return right
away and do_group_exit will take care to zap the whole thread group.
Signed-off-by: Michal Hocko <mhocko@suse.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | fs/coredump.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/coredump.c b/fs/coredump.c index 47c32c3bfa1d..f2cef927789b 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -413,7 +413,9 @@ static int coredump_wait(int exit_code, struct core_state *core_state) core_state->dumper.task = tsk; core_state->dumper.next = NULL; - down_write(&mm->mmap_sem); + if (down_write_killable(&mm->mmap_sem)) + return -EINTR; + if (!mm->core_state) core_waiters = zap_threads(tsk, mm, core_state, exit_code); up_write(&mm->mmap_sem); |