All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Peter.Enderborg@sony.com>
To: <ebiederm@xmission.com>
Cc: <linux-kernel@vger.kernel.org>, <rostedt@goodmis.org>,
	<mingo@redhat.com>, <akpm@linux-foundation.org>,
	<peterz@infradead.org>, <ast@kernel.org>,
	<christian.brauner@ubuntu.com>, <dave@stgolabs.net>,
	<walken@google.com>, <jannh@google.com>,
	<mathieu.desnoyers@efficios.com>, <christophe.leroy@c-s.fr>,
	<minchan@kernel.org>
Subject: Re: [PATCH 1/2] tracing: Add a trace for task_exit
Date: Sat, 1 May 2021 09:29:41 +0000	[thread overview]
Message-ID: <4bb24db4-f720-f5e7-9054-36bdeaee1d79@sony.com> (raw)
In-Reply-To: <m14kfnzmsp.fsf@fess.ebiederm.org>

On 4/30/21 7:48 PM, Eric W. Biederman wrote:
> Peter Enderborg <peter.enderborg@sony.com> writes:
>
>> This is the peer functions to task_rename and task_newtask.
>> With this we get hole "life-cycle" of task and can easily
>> see short livied task and their exit status.
> This patch is incorrect.  The location you are dealing with is not part
> of task exit.  The location you have instrumented is part of reaping a
> task which can come arbitrarily long after the task exits.

That is what it aiming. When using this as tool for userspace you
would like to know when the task is done. When it no longer
holds any thing that might have any impact. If you think the
exit imply something more specific I can change the name.

I thought exit was a good name, it is in in exit.c.

Will the name task_done, task_finished or task_reaped work for you?


>
> There are some special rules associated with task_comm so I don't know
> if your change to __string from a fixed size character array is safe.
>
> Certainly something like that needs an explanation of why such a type
> change is safe.
>
> Eric
>
>
>> Format might look like:
>>             bash-1144    [006] ....  1306.601707: task_newtask: pid=1181 comm=bash clone_flags=1200000 oom_score_adj=0
>>            <...>-1181    [007] ....  1306.602080: task_rename: pid=1181 oldcomm=bash newcomm=ls oom_score_adj=0
>>             bash-1144    [006] d...  1306.785960: task_exit: pid=1181 oom_score_adj=0 exit_signal=17 exit_code=0 exit_state=0x10 comm=ls
>>
>> For a sequence when a bash shell runs the ls command.
>>
>> Signed-off-by: Peter Enderborg <peter.enderborg@sony.com>
>> ---
>>  include/trace/events/task.h | 32 ++++++++++++++++++++++++++++++++
>>  kernel/exit.c               |  3 +++
>>  2 files changed, 35 insertions(+)
>>
>> diff --git a/include/trace/events/task.h b/include/trace/events/task.h
>> index 64d160930b0d..2e977d2935e1 100644
>> --- a/include/trace/events/task.h
>> +++ b/include/trace/events/task.h
>> @@ -56,6 +56,38 @@ TRACE_EVENT(task_rename,
>>  		__entry->newcomm, __entry->oom_score_adj)
>>  );
>>  
>> +TRACE_EVENT(task_exit,
>> +
>> +	TP_PROTO(struct task_struct *task),
>> +
>> +	TP_ARGS(task),
>> +
>> +	TP_STRUCT__entry(
>> +		__field(pid_t,	pid)
>> +		__field(short,	oom_score_adj)
>> +		__field(int,	exit_signal)
>> +		__field(int,	exit_code)
>> +		__field(int,	exit_state)
>> +		__string(comm, task->comm)
>> +
>> +	),
>> +
>> +	TP_fast_assign(
>> +		__entry->pid = task->pid;
>> +		__entry->oom_score_adj = task->signal->oom_score_adj;
>> +		__entry->exit_signal = task->exit_signal;
>> +		__entry->exit_code = task->exit_code;
>> +		__entry->exit_state = task->exit_state;
>> +		__assign_str(comm, task->comm);
>> +	),
>> +
>> +	TP_printk("pid=%d oom_score_adj=%hd exit_signal=%d exit_code=%d exit_state=0x%x comm=%s",
>> +		  __entry->pid,
>> +		  __entry->oom_score_adj, __entry->exit_signal,
>> +		  __entry->exit_code, __entry->exit_state,
>> +		  __get_str(comm))
>> +);
>> +
>>  #endif
>>  
>>  /* This part must be outside protection */
>> diff --git a/kernel/exit.c b/kernel/exit.c
>> index 04029e35e69a..3ab0944e5dfc 100644
>> --- a/kernel/exit.c
>> +++ b/kernel/exit.c
>> @@ -68,6 +68,7 @@
>>  #include <linux/uaccess.h>
>>  #include <asm/unistd.h>
>>  #include <asm/mmu_context.h>
>> +#include <trace/events/task.h>
>>  
>>  static void __unhash_process(struct task_struct *p, bool group_dead)
>>  {
>> @@ -107,6 +108,8 @@ static void __exit_signal(struct task_struct *tsk)
>>  		posix_cpu_timers_exit_group(tsk);
>>  #endif
>>  
>> +	trace_task_exit(tsk);
>> +
>>  	if (group_dead) {
>>  		tty = sig->tty;
>>  		sig->tty = NULL;


  reply	other threads:[~2021-05-01  9:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-30 14:22 [PATCH 0/2] tracing: Add trace for task_exit Peter Enderborg
2021-04-30 14:22 ` [PATCH 1/2] tracing: Add a " Peter Enderborg
2021-04-30 17:48   ` Eric W. Biederman
2021-05-01  9:29     ` Peter.Enderborg [this message]
2021-05-01 13:11       ` Steven Rostedt
2021-05-03 13:50         ` Mathieu Desnoyers
2021-05-03 14:48           ` Peter.Enderborg
2021-05-03 16:30             ` Eric W. Biederman
2021-05-03 18:04               ` Peter.Enderborg
2021-05-03 19:02                 ` Eric W. Biederman
2021-05-03 19:43                   ` Peter.Enderborg
2021-05-03 20:55                   ` Steven Rostedt
2021-05-04  8:00                     ` Peter.Enderborg
2021-05-04 13:18                       ` Steven Rostedt
2021-04-30 14:22 ` [PATCH 2/2] tracing: Align task.h to use __assing_str for strings Peter Enderborg

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=4bb24db4-f720-f5e7-9054-36bdeaee1d79@sony.com \
    --to=peter.enderborg@sony.com \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=christophe.leroy@c-s.fr \
    --cc=dave@stgolabs.net \
    --cc=ebiederm@xmission.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=minchan@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=walken@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.