From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Konstantin Khlebnikov" <khlebnikov@yandex-team.ru>,
"Roman Gushchin" <guro@fb.com>,
"Cyrill Gorcunov" <gorcunov@gmail.com>,
"Kirill Tkhai" <ktkhai@virtuozzo.com>,
"Michal Hocko" <mhocko@suse.com>,
"Alexey Dobriyan" <adobriyan@gmail.com>,
"Al Viro" <viro@zeniv.linux.org.uk>,
"Matthew Wilcox" <willy@infradead.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Oleg Nesterov" <oleg@redhat.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Sasha Levin" <sashal@kernel.org>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 094/101] proc: use down_read_killable mmap_sem for /proc/pid/smaps_rollup
Date: Fri, 19 Jul 2019 00:07:25 -0400 [thread overview]
Message-ID: <20190719040732.17285-94-sashal@kernel.org> (raw)
In-Reply-To: <20190719040732.17285-1-sashal@kernel.org>
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
[ Upstream commit a26a97815548574213fd37f29b4b78ccc6d9ed20 ]
Do not remain stuck forever if something goes wrong. Using a killable
lock permits cleanup of stuck tasks and simplifies investigation.
Link: http://lkml.kernel.org/r/156007493429.3335.14666825072272692455.stgit@buzz
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Reviewed-by: Roman Gushchin <guro@fb.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/proc/task_mmu.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index c5819baee35c..b2010055180e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -826,7 +826,10 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
memset(&mss, 0, sizeof(mss));
- down_read(&mm->mmap_sem);
+ ret = down_read_killable(&mm->mmap_sem);
+ if (ret)
+ goto out_put_mm;
+
hold_task_mempolicy(priv);
for (vma = priv->mm->mmap; vma; vma = vma->vm_next) {
@@ -843,8 +846,9 @@ static int show_smaps_rollup(struct seq_file *m, void *v)
release_task_mempolicy(priv);
up_read(&mm->mmap_sem);
- mmput(mm);
+out_put_mm:
+ mmput(mm);
out_put_task:
put_task_struct(priv->task);
priv->task = NULL;
--
2.20.1
next prev parent reply other threads:[~2019-07-19 4:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190719040732.17285-1-sashal@kernel.org>
2019-07-19 4:07 ` [PATCH AUTOSEL 4.19 092/101] memcg, fsnotify: no oom-kill for remote memcg charging Sasha Levin
2019-07-19 4:07 ` Sasha Levin [this message]
2019-07-19 4:07 ` [PATCH AUTOSEL 4.19 095/101] proc: use down_read_killable mmap_sem for /proc/pid/pagemap Sasha Levin
2019-07-19 4:07 ` [PATCH AUTOSEL 4.19 096/101] proc: use down_read_killable mmap_sem for /proc/pid/clear_refs Sasha Levin
2019-07-19 4:07 ` [PATCH AUTOSEL 4.19 097/101] proc: use down_read_killable mmap_sem for /proc/pid/map_files Sasha Levin
2019-07-19 4:07 ` [PATCH AUTOSEL 4.19 099/101] proc: use down_read_killable mmap_sem for /proc/pid/maps Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190719040732.17285-94-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=gorcunov@gmail.com \
--cc=guro@fb.com \
--cc=khlebnikov@yandex-team.ru \
--cc=ktkhai@virtuozzo.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=mkoutny@suse.com \
--cc=oleg@redhat.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).