linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][V7]make get_user_pages interruptible
@ 2008-12-03  5:17 Ying Han
  2008-12-03  7:19 ` KOSAKI Motohiro
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Ying Han @ 2008-12-03  5:17 UTC (permalink / raw)
  To: linux-mm, Andrew Morton, KOSAKI Motohiro, Lee Schermerhorn,
	Oleg Nesterov, Pekka Enberg, Paul Menage, Rohit Seth

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                   |    9 +-

diff --git a/mm/memory.c b/mm/memory.c
index 164951c..ef1c3f0 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1218,12 +1218,11 @@ 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.
 			 */
-			if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE)))
-				return i ? i : -ENOMEM;
+			if (unlikely(fatal_signal_pending(current)))
+				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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-12-04  1:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-03  5:17 [PATCH][V7]make get_user_pages interruptible Ying Han
2008-12-03  7:19 ` KOSAKI Motohiro
2008-12-03  8:21   ` Pekka Enberg
2008-12-03 15:03 ` Lee Schermerhorn
2008-12-03 20:25   ` Ying Han
2008-12-03 20:36     ` Lee Schermerhorn
2008-12-03 20:01 ` [PATCH] mmotm: ignore sigkill in get_user_pages during munlock Lee Schermerhorn
2008-12-04  0:30   ` KOSAKI Motohiro
2008-12-04  1:19     ` Ying Han
2008-12-04  1:49     ` Lee Schermerhorn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox