+ make-get_user_pages-interruptible.patch added to -mm tree
Quoted 13 lines · Ying Han
(quoted diff) +1
-1-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 -puN
mm/memory.c~make-get_user_pages-interruptiblemm/memory.cmm/memory.c renamed from mm/memory.c~make-get_user_pages-interruptible +0
-0@@ -1219,12 +1219,12 @@ int __get_user_pages(struct task_structstruct page *page;/*
mm/memory.c int __get_user_pages(struct task_struct · line 1226
Quoted 10 lines
mm/memory.c renamed from mm/memory.c~make-get_user_pages-interruptible +4
-5-* 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 (sigkill_pending (current) || +sigkill_pending (tsk)))
Please do not export/use sigkill_pending(). It is "private" for ptrace_stop() (and actually should die imho).
We have fatal_signal_pending() for that.
Oleg.
Thanks Oleg, i looked at the code again and this is a reasonable change. I will make the change on the patch.
Andrew,
should i make a patch based on current change or make the same
patch as [V6]?
thanks
--Ying
Quoted 33 lines · Oleg Nesterov
Quoted 13 lines · Ying Han
(quoted diff) +1
-1-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 -puN
mm/memory.c~make-get_user_pages-interruptiblemm/memory.cmm/memory.c renamed from mm/memory.c~make-get_user_pages-interruptible +0
-0@@ -1219,12 +1219,12 @@ int __get_user_pages(struct task_structstruct page *page;/* mm/memory.c int __get_user_pages(struct task_struct · line 1226
Quoted 10 lines
mm/memory.c renamed from mm/memory.c~make-get_user_pages-interruptible +4
-5-* 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 (sigkill_pending (current) || +sigkill_pending (tsk)))Please do not export/use
sigkill_pending(). It is "private" forptrace_stop()(and actually should die imho).We have
fatal_signal_pending()for that.Oleg.
Quoted 29 lines · On Mon, 1 Dec 2008 15:00:14 -0800 Ying Han <[email protected]> wrote:
Quoted 28 lines · Oleg Nesterov
Quoted 13 lines · Ying Han
(quoted diff) +1
-1-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 -puN
mm/memory.c~make-get_user_pages-interruptiblemm/memory.cmm/memory.c renamed from mm/memory.c~make-get_user_pages-interruptible +0
-0@@ -1219,12 +1219,12 @@ int __get_user_pages(struct task_structstruct page *page;/* mm/memory.c int __get_user_pages(struct task_struct · line 1226
Quoted 10 lines
mm/memory.c renamed from mm/memory.c~make-get_user_pages-interruptible +4
-5-* 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 (sigkill_pending (current) || +sigkill_pending (tsk)))Please do not export/use
sigkill_pending(). It is "private" forptrace_stop()(and actually should die imho).
Quoted 4 lines
Quoted 4 lines
We have
fatal_signal_pending()for that.Oleg.
(top-posting repaired..)
Quoted 5 lines
Thanks Oleg, i looked at the code again and this is a reasonable change. I will make the change on the patch.
Andrew,
should i make a patch based on current change or make the same
patch as [V6]?
I don't mind either way. I guess a fresh new patch would simplify review for everyone.
Note that fatal_signal_pending() is not an exact replacement for sigkill_pending() - fatal_signal_pending() doesn't test the shared pending signals.
thanks Andrew.
Quoted 45 lines · Andrew Morton
Quoted 29 lines · On Mon, 1 Dec 2008 15:00:14 -0800 Ying Han <[email protected]> wrote:
Quoted 28 lines · Oleg Nesterov
Quoted 13 lines · Ying Han
(quoted diff) +1
-1-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 -puN
mm/memory.c~make-get_user_pages-interruptiblemm/memory.cmm/memory.c renamed from mm/memory.c~make-get_user_pages-interruptible +0
-0@@ -1219,12 +1219,12 @@ int __get_user_pages(struct task_structstruct page *page;/* mm/memory.c int __get_user_pages(struct task_struct · line 1226
Quoted 10 lines
mm/memory.c renamed from mm/memory.c~make-get_user_pages-interruptible +4
-5-* 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 (sigkill_pending (current) || +sigkill_pending (tsk)))Please do not export/use
sigkill_pending(). It is "private" forptrace_stop()(and actually should die imho).Quoted 4 lines
Quoted 4 lines
We have
fatal_signal_pending()for that.Oleg.
(top-posting repaired..)
Quoted 5 lines
Thanks Oleg, i looked at the code again and this is a reasonable change. I will make the change on the patch.
Andrew,
should i make a patch based on current change or make the same
patch as [V6]?
Quoted 7 lines
I don't mind either way. I guess a fresh new patch would simplify review for everyone.
Note that
fatal_signal_pending()is not an exact replacement forsigkill_pending()-fatal_signal_pending()doesn't test the shared pending signals.
yeah, i noticed that and that is why i used the sigkill_pending initially. But after a deeper look
at the signal code, i found for SIGKILL ( signal we care about in this patch ), tsk->pending is a
superset of tsk->signal->shared_pending.
--Ying
Quoted 2 lines
Quoted 7 lines · Ying Han
Quoted 5 lines · Andrew Morton
Note that
fatal_signal_pending()is not an exact replacement forsigkill_pending()-fatal_signal_pending()doesn't test the shared pending signals.
Quoted 5 lines
yeah, i noticed that and that is why i used the
sigkill_pendinginitially. But after a deeper look
at the signal code, i found for SIGKILL ( signal we care about in this patch ),tsk->pendingis a
superset oftsk->signal->shared_pending.
Yes. If we have SIGKILL in ->shared_pending, we must have it in in ->pending too.
The only exception is when we send SIGKILL to the already dying task which has already dequeued SIGKILL from ->pending. And we do have a special case: coredumping. elf_core_dump() does get_user_pages() when the process is "almost" dead, it has SIGNAL_GROUP_EXIT.
So, if get_user_pages() calls sigkill_pending() instead of fatal_signal_pending(), this can help. But:
- this relies on the fact that we always queue SIGKILL even if the task is dead. This behaviour can be changed.
- this doesn't stop the coredumping, it will continue with DUMP_SEEK(). Yes, this is better if we want to stop this thread to populate the memory, but I think we should just fix the coredumping - it should be interruptible.
Actually, the patch exists:
http://marc.info/?l=linux-kernel&m=121665710711931
Oleg.