exec: log when wait_for_dump_helpers aborts due to a signal
Subsystems (2)
PATCH 1/1 exec: log when wait_for_dump_helpers aborts due to a signal
To allow coredump pipe readers to look at /proc/<pid> of the crashing process, the kernel waits for the reader to exit. However, the wait is silently aborted if the crashing process is signalled.
This patch, logs whenever wait_for_dump_helpers is aborted or in order to assist in debugging cases where /proc/<pid> is gone.
Alternatively, we may want to consider not aborting on a signal. You could always break the loop by killing the reader process.
Reference: http://crosbug.com/21559
--- fs/exec.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
fs/exec.c +8 -1
@@ -2030,7 +2030,14 @@ static void wait_for_dump_helpers(struct file *file) pipe->readers++; pipe->writers--; -while ((pipe->readers >1 ) && (!signal_pending (current))) { +while (pipe->readers >1 ) { +if (signal_pending (current)) { +pr_info ("wait_for_dump_helpers[%d]: " +"aborted due to signal\n" , +task_pid_nr (current)); +break ; + } +wake_up_interruptible_sync (&pipe->wait);kill_fasync (&pipe->fasync_readers,SIGIO ,POLL_IN );pipe_wait (pipe);
Signature · 1 line
1.7.3.1
Quoted 10 lines · Mandeep Singh Baines
To allow coredump pipe readers to look at /proc/<pid> of the crashing process, the kernel waits for the reader to exit. However, the wait is silently aborted if the crashing process is signalled.
This patch, logs whenever
wait_for_dump_helpersis aborted or in order to assist in debugging cases where /proc/<pid> is gone.Alternatively, we may want to consider not aborting on a signal. You could always break the loop by killing the reader process.
Not checking for signal pending might not be such a bad idea. If you're stuck in wait_for_dump_helpers, it means the reader is stuck so you'll want to kill it. Once you kill the reader, the loop will exit naturally.
Quoted 38 lines
Reference: http://crosbug.com/21559
Signed-off-by Mandeep Singh Baines <[email protected]>Cc Alexander Viro <[email protected]>Cc Neil Horman <[email protected]>Cc Earl Chew <[email protected]>Cc Oleg Nesterov <[email protected]>Cc Andi Kleen <[email protected]>Cc Alan Cox <[email protected]>Cc Andrew Morton <[email protected]>---
fs/exec.c | 9 ++++++++-1 files changed, 8 insertions(+), 1 deletions(-)fs/exec.c +8
-2@@ -2030,7 +2030,14 @@ static void wait_for_dump_helpers(struct file *file) pipe->readers++; pipe->writers--; - while ((pipe->readers > 1) && (!signal_pending(current))) { + while (pipe->readers > 1) { + if (signal_pending(current)) { + pr_info("wait_for_dump_helpers[%d]: " + "aborted due to signal\n", + task_pid_nr(current)); + break; + } + wake_up_interruptible_sync(&pipe->wait); kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); pipe_wait(pipe); --1.7.3.1
Quoted 4 lines · Mandeep Singh Baines
To allow coredump pipe readers to look at /proc/<pid> of the crashing process, the kernel waits for the reader to exit. However, the wait is silently aborted if the crashing process is signalled.
Well, yes... But note that this signal_pending() is only used because with TIF_SIGPENDING we have the problems anyway.
Oh. I promise myself I'll make do_coredump() killable and cleanup this all every time I look at this code...
Quoted 2 lines
This patch, logs whenever
wait_for_dump_helpersis aborted or in order to assist in debugging cases where /proc/<pid> is gone.
I don't really understand why this is useful. The reader process can complain if it can't collect the data (say, /proc/pid goes away or EOF doesn't come).
As for the patch itself,
fs/exec.c static void wait_for_dump_helpers(struct file *file) · line 2041
Quoted 10 lines
fs/exec.c +8
-1-while ((pipe->readers >1 ) && (!signal_pending (current))) { +while (pipe->readers >1 ) { +if (signal_pending (current)) { +pr_info ("wait_for_dump_helpers[%d]: " +"aborted due to signal\n" , +task_pid_nr (current)); +break ; + } +wake_up_interruptible_sync (&pipe->wait);
This can't help in general. If signal_pending() == T, it is quite possible that pipe_write() already failed before.
Oleg.
Quoted 6 lines · On Tue, 25 Oct 2011 18:07:08 -0700 Mandeep Singh Baines <[email protected]>…
To allow coredump pipe readers to look at /proc/<pid> of the crashing process, the kernel waits for the reader to exit. However, the wait is silently aborted if the crashing process is signalled.
This patch, logs whenever
wait_for_dump_helpersis aborted or in order to assist in debugging cases where /proc/<pid> is gone.
You don't really describe what problem you're observing. What's the use case? What are you trying to do? etc.
Because if that is known, we can perhaps find better solutions.
Quoted 2 lines
Alternatively, we may want to consider not aborting on a signal. You could always break the loop by killing the reader process.
Well. Neil's changelog for 61be228a06dc6e8662 is quite nice and tells us everything we could possibly want to know, except for why it tests sgnal_pending() :(
Neil, Oleg: can you remember?
Quoted 5 lines
fs/exec.c +0
-0@@ -2030,7 +2030,14 @@ static void wait_for_dump_helpers(struct file *file) pipe->readers++; pipe->writers--;
fs/exec.c static void wait_for_dump_helpers(struct file *file) · line 2040
Quoted 10 lines
fs/exec.c +8
-1-while ((pipe->readers >1 ) && (!signal_pending (current))) { +while (pipe->readers >1 ) { +if (signal_pending (current)) { +pr_info ("wait_for_dump_helpers[%d]: " +"aborted due to signal\n" , +task_pid_nr (current)); +break ; + } +
argh, printk("i screwed up"). Hopefully we can find a better solution to whatever-your-problem is than this!
Quoted 15 lines · Andrew Morton
Quoted 6 lines · On Tue, 25 Oct 2011 18:07:08 -0700 Mandeep Singh Baines <[email protected]>…
To allow coredump pipe readers to look at /proc/<pid> of the crashing process, the kernel waits for the reader to exit. However, the wait is silently aborted if the crashing process is signalled.
This patch, logs whenever
wait_for_dump_helpersis aborted or in order to assist in debugging cases where /proc/<pid> is gone.You don't really describe what problem you're observing. What's the use case? What are you trying to do? etc.
Because if that is known, we can perhaps find better solutions.
Quoted 9 lines
Quoted 2 lines
Alternatively, we may want to consider not aborting on a signal. You could always break the loop by killing the reader process.
Well. Neil's changelog for
61be228a06dc6e8662is quite nice and tells us everything we could possibly want to know, except for why it testssgnal_pending():(Neil, Oleg: can you remember?
I _think_ it was a way to detect if the helper was still running, or had become stuck. I.e. we send the process a SIGIO, and if on the next iteration its still pending, we can assume something has gone wrong, and abort the dump. Of course my memory could be faulty, Oleg do you have better recollection than I?
I'm heading out for a long weekend, but when I get back, I'll dig through the archives for a better answer. I recall Oleg and I talking at length about this code.
Quoted 19 lines
Quoted 5 lines
fs/exec.c +0
-0@@ -2030,7 +2030,14 @@ static void wait_for_dump_helpers(struct file *file) pipe->readers++; pipe->writers--;fs/exec.c static void wait_for_dump_helpers(struct file *file) · line 2040
Quoted 10 lines
fs/exec.c +8
-1-while ((pipe->readers >1 ) && (!signal_pending (current))) { +while (pipe->readers >1 ) { +if (signal_pending (current)) { +pr_info ("wait_for_dump_helpers[%d]: " +"aborted due to signal\n" , +task_pid_nr (current)); +break ; + } +argh,
printk("i screwed up"). Hopefully we can find a better solution to whatever-your-problem is than this!
Quoted 4 lines · Andrew Morton
Well. Neil's changelog for
61be228a06dc6e8662is quite nice and tells us everything we could possibly want to know, except for why it testssgnal_pending():(
In short, signal_pending() should not be here. It only reflects the fact that do_coredump() needs the fixes (and can't resist, I sent the patch several years ago, but it was ignored ;)
There are 2 reasons. if signal_pending() == T then:
- pipe_wait() is pointless, it won't block. We do not want a busywait loop.
- And probably even wait_for_dump_helpers() is pointless, it is quite possible that pipe_write() already failed before and the reader doesn't know this.
What I think we should do:
- Fix this code, it should not react to signals.
- But! at the same time the explicit SIGKILL should stop the coredump. It can take a lot of time/resources.
This also makes it oom-killable, and this is important.
- If we dump to the pipe, then perhaps it makes sense to send a signal to the pipe reader in the latter case, but this is a bit offtopic.
I'll try to redo my old patches for 3.2 once I have the time. There are some nasty problems which I forgot, _iirc_ this is not that trivial.
Oleg.