linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: <linux-kernel@vger.kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Ingo Molnar <mingo@kernel.org>, <kernel-team@fb.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Oleg Nesterov <oleg@redhat.com>
Subject: Re: [RFC] proc, coredump: add CoreDumping flag to /proc/pid/status
Date: Thu, 14 Sep 2017 15:44:31 -0700	[thread overview]
Message-ID: <20170914224431.GA9735@castle> (raw)
In-Reply-To: <20170907111715.1359-1-guro@fb.com>

Adding Andrew Morton and Oleg Nesterov to cc.

On Thu, Sep 07, 2017 at 12:17:15PM +0100, Roman Gushchin wrote:
> Right now there is no convenient way to check if a process is being
> coredumped at the moment.
> 
> It might be necessary to recognize such state to prevent killing
> the process and getting a broken coredump.
> Writing a large core might take significant time, and the process
> is unresponsive during it, so it might be killed by timeout,
> if another process is monitoring and killing/restarting
> hanging tasks.
> 
> To provide an ability to detect if a process is in the state of
> being coreduped, we can expose a boolean CoreDumping flag
> in /proc/pid/status.
> 
> Example:
> $ cat core.sh
>   #!/bin/sh
> 
>   echo "|/usr/bin/sleep 10" > /proc/sys/kernel/core_pattern
>   sleep 1000 &
>   PID=$!
> 
>   cat /proc/$PID/status | grep CoreDumping
>   kill -ABRT $PID
>   sleep 1
>   cat /proc/$PID/status | grep CoreDumping
> 
> $ ./core.sh
>   CoreDumping:	0
>   CoreDumping:	1
> 
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: kernel-team@fb.com
> Cc: linux-kernel@vger.kernel.org
> ---
>  fs/proc/array.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/fs/proc/array.c b/fs/proc/array.c
> index 88c355574aa0..fc4a0aa7f487 100644
> --- a/fs/proc/array.c
> +++ b/fs/proc/array.c
> @@ -369,6 +369,11 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
>  		   cpumask_pr_args(&task->cpus_allowed));
>  }
>  
> +static inline void task_core_dumping(struct seq_file *m, struct mm_struct *mm)
> +{
> +	seq_printf(m, "CoreDumping:\t%d\n", !!mm->core_state);
> +}
> +
>  int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
>  			struct pid *pid, struct task_struct *task)
>  {
> @@ -379,6 +384,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
>  
>  	if (mm) {
>  		task_mem(m, mm);
> +		task_core_dumping(m, mm);
>  		mmput(mm);
>  	}
>  	task_sig(m, task);
> -- 
> 2.13.5
> 

  parent reply	other threads:[~2017-09-14 22:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07 11:17 [RFC] proc, coredump: add CoreDumping flag to /proc/pid/status Roman Gushchin
2017-09-13 22:05 ` Roman Gushchin
2017-09-14 22:44 ` Roman Gushchin [this message]
2017-09-20 23:06   ` [RESEND] " Roman Gushchin
2017-09-22 15:44     ` Konstantin Khlebnikov
2017-09-22 17:18       ` Roman Gushchin
2017-09-26 12:39     ` Roman Gushchin
2017-09-27 23:31     ` Andrew Morton
2017-09-28 13:53       ` Roman Gushchin
  -- strict thread matches above, loose matches on Subject: below --
2017-09-13 22:15 [RFC] " Alexey Dobriyan
2017-09-13 22:21 ` Roman Gushchin
2017-09-13 22:46   ` Alexey Dobriyan
2017-09-13 23:07     ` Roman Gushchin

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=20170914224431.GA9735@castle \
    --to=guro@fb.com \
    --cc=akpm@linux-foundation.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).