From: Ying Han <yinghan@google.com>
To: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Lee Schermerhorn <lee.schermerhorn@hp.com>,
Oleg Nesterov <oleg@redhat.com>,
Pekka Enberg <penberg@cs.helsinki.fi>,
Paul Menage <menage@google.com>,
Rohit Seth <rohitseth@google.com>
Subject: [PATCH][V6]make get_user_pages interruptible
Date: Tue, 2 Dec 2008 11:30:25 -0800 [thread overview]
Message-ID: <604427e00812021130t1aad58a8j7474258ae33e15a4@mail.gmail.com> (raw)
changelog
[v6] replace the sigkill_pending() with fatal_signal_pending()
add the check for cases current != tsk
From: Ying Han <yinghan@google.com>
make get_user_pages interruptible
The initial implementation of checking TIF_MEMDIE covers the cases of OOM
killing. If the process has been OOM killed, the TIF_MEMDIE is set and it
return immediately. This patch includes:
1. add the case that the SIGKILL is sent by user processes. The process can
try to get_user_pages() unlimited memory even if a user process has sent a
SIGKILL to it(maybe a monitor find the process exceed its memory limit and
try to kill it). In the old implementation, the SIGKILL won't be handled
until the get_user_pages() returns.
2. change the return value to be ERESTARTSYS. It makes no sense to return
ENOMEM if the get_user_pages returned by getting a SIGKILL signal.
Considering the general convention for a system call interrupted by a
signal is ERESTARTNOSYS, so the current return value is consistant to that.
Signed-off-by: Paul Menage <menage@google.com>
Signed-off-by: Ying Han <yinghan@google.com>
mm/memory.c | 13 ++-
diff --git a/mm/memory.c b/mm/memory.c
index 164951c..049a4f1 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1218,12 +1218,15 @@ int __get_user_pages(struct task_struct *tsk, struct m
struct page *page;
/*
- * If tsk is ooming, cut off its access to large memory
- * allocations. It has a pending SIGKILL, but it can't
- * be processed until returning to user space.
+ * If we have a pending SIGKILL, don't keep
+ * allocating memory. We check both current
+ * and tsk to cover the cases where current
+ * is allocating pages on behalf of tsk.
*/
- if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE)))
- return i ? i : -ENOMEM;
+ if (unlikely(fatal_signal_pending(current) ||
+ ((current != tsk) &&
+ fatal_signal_pending(tsk))))
+ return i ? i : -ERESTARTSYS;
if (write)
foll_flags |= FOLL_WRITE;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2008-12-02 19:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-02 19:30 Ying Han [this message]
2008-12-02 21:26 ` Pekka Enberg
2008-12-02 22:00 ` Ying Han
2008-12-03 2:24 ` KOSAKI Motohiro
2008-12-03 3:57 ` Ying Han
2008-12-03 4:17 ` KOSAKI Motohiro
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=604427e00812021130t1aad58a8j7474258ae33e15a4@mail.gmail.com \
--to=yinghan@google.com \
--cc=akpm@linux-foundation.org \
--cc=lee.schermerhorn@hp.com \
--cc=linux-mm@kvack.org \
--cc=menage@google.com \
--cc=oleg@redhat.com \
--cc=penberg@cs.helsinki.fi \
--cc=rohitseth@google.com \
/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