* Make the get_user_pages interruptible
@ 2008-11-20 22:03 Ying Han
2008-11-21 22:50 ` Andrew Morton
2008-11-21 23:24 ` David Rientjes
0 siblings, 2 replies; 4+ messages in thread
From: Ying Han @ 2008-11-20 22:03 UTC (permalink / raw)
To: linux-mm, akpm, linux-kernel, Paul Menage, David Rientjes, Rohit Seth
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>
Ying Han <yinghan@google.com>
include/linux/sched.h | 1 +
kernel/signal.c | 2 +-
mm/memory.c | 9 +-
diff --git a/include/linux/sched.h b/include/linux/sched.h
index b483f39..f2a5cac 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1795,6 +1795,7 @@ extern void flush_signals(struct task_struct *);
extern void ignore_signals(struct task_struct *);
extern void flush_signal_handlers(struct task_struct *, int force_default);
extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t
+extern int sigkill_pending(struct task_struct *tsk);
static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask
{
diff --git a/kernel/signal.c b/kernel/signal.c
index 105217d..f3f154e 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1497,7 +1497,7 @@ static inline int may_ptrace_stop(void)
* Return nonzero if there is a SIGKILL that should be waking us up.
* Called with the siglock held.
*/
-static int sigkill_pending(struct task_struct *tsk)
+int sigkill_pending(struct task_struct *tsk)
{
return sigismember(&tsk->pending.signal, SIGKILL) ||
sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
diff --git a/mm/memory.c b/mm/memory.c
index 164951c..157ea3b 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 (sigkill_pending(current))
+ return -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] 4+ messages in thread* Re: Make the get_user_pages interruptible
2008-11-20 22:03 Make the get_user_pages interruptible Ying Han
@ 2008-11-21 22:50 ` Andrew Morton
2008-11-21 23:24 ` David Rientjes
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2008-11-21 22:50 UTC (permalink / raw)
To: Ying Han; +Cc: linux-mm, linux-kernel, menage, rientjes, rohitseth
On Thu, 20 Nov 2008 14:03:36 -0800
Ying Han <yinghan@google.com> wrote:
> 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>
> Ying Han <yinghan@google.com>
>
>
This isn't right?
> --- 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 (sigkill_pending(current))
> + return -ERESTARTSYS;
>
> if (write)
> foll_flags |= FOLL_WRITE;
If this function has already put some page*'s into *pages, they will be
leaked. The function fails to release those pages and it does not
provide sufficient information to callers to allow them to release the
pages.
I thought I already mentioned that last time I saw this patch?
--
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] 4+ messages in thread
* Re: Make the get_user_pages interruptible
2008-11-20 22:03 Make the get_user_pages interruptible Ying Han
2008-11-21 22:50 ` Andrew Morton
@ 2008-11-21 23:24 ` David Rientjes
2008-11-22 0:06 ` Ying Han
1 sibling, 1 reply; 4+ messages in thread
From: David Rientjes @ 2008-11-21 23:24 UTC (permalink / raw)
To: Ying Han; +Cc: linux-mm, akpm, linux-kernel, Paul Menage, Rohit Seth
On Thu, 20 Nov 2008, Ying Han wrote:
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index b483f39..f2a5cac 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1795,6 +1795,7 @@ extern void flush_signals(struct task_struct *);
> extern void ignore_signals(struct task_struct *);
> extern void flush_signal_handlers(struct task_struct *, int force_default);
> extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t
> +extern int sigkill_pending(struct task_struct *tsk);
>
> static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask
> {
I can't git apply this because it appears as though your email client has
truncated long lines (see dequeue_signal above).
Your headers look like you're using the gmail GUI to send patches, and
that client has its own section in Documentation/email-clients.txt. If
the instructions don't happen to work for you, please fix that section
once you've troubleshooted the problem.
--
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] 4+ messages in thread* Re: Make the get_user_pages interruptible
2008-11-21 23:24 ` David Rientjes
@ 2008-11-22 0:06 ` Ying Han
0 siblings, 0 replies; 4+ messages in thread
From: Ying Han @ 2008-11-22 0:06 UTC (permalink / raw)
To: David Rientjes; +Cc: linux-mm, akpm, linux-kernel, Paul Menage, Rohit Seth
David, i resent the patch with change in another thread.
thanks
--Ying
On Fri, Nov 21, 2008 at 3:24 PM, David Rientjes <rientjes@google.com> wrote:
> On Thu, 20 Nov 2008, Ying Han wrote:
>
>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>> index b483f39..f2a5cac 100644
>> --- a/include/linux/sched.h
>> +++ b/include/linux/sched.h
>> @@ -1795,6 +1795,7 @@ extern void flush_signals(struct task_struct *);
>> extern void ignore_signals(struct task_struct *);
>> extern void flush_signal_handlers(struct task_struct *, int force_default);
>> extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t
>> +extern int sigkill_pending(struct task_struct *tsk);
>>
>> static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask
>> {
>
> I can't git apply this because it appears as though your email client has
> truncated long lines (see dequeue_signal above).
>
> Your headers look like you're using the gmail GUI to send patches, and
> that client has its own section in Documentation/email-clients.txt. If
> the instructions don't happen to work for you, please fix that section
> once you've troubleshooted the problem.
>
--
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] 4+ messages in thread
end of thread, other threads:[~2008-11-22 0:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-20 22:03 Make the get_user_pages interruptible Ying Han
2008-11-21 22:50 ` Andrew Morton
2008-11-21 23:24 ` David Rientjes
2008-11-22 0:06 ` Ying Han
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox