public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] Tracepoint: add exec tracepoint
@ 2011-10-18 18:41 David Smith
  2011-10-18 18:58 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: David Smith @ 2011-10-18 18:41 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Steven Rostedt

Added general purpose exec tracepoint.  The 'bprm' argument gives details of the exec.

Signed-off-by: David Smith <dsmith@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
---
 fs/exec.c                    |    6 +++++-
 include/trace/events/sched.h |   22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index 25dcbe5..fdb1686 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -61,6 +61,8 @@
 #include <asm/tlb.h>
 #include "internal.h"
 
+#include <trace/events/sched.h>
+
 int core_uses_pid;
 char core_pattern[CORENAME_MAX_SIZE] = "core";
 unsigned int core_pipe_limit;
@@ -1401,9 +1403,11 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
 			 */
 			bprm->recursion_depth = depth;
 			if (retval >= 0) {
-				if (depth == 0)
+				if (depth == 0) {
+					trace_sched_process_exec(bprm);
 					ptrace_event(PTRACE_EVENT_EXEC,
 							old_pid);
+				}
 				put_binfmt(fmt);
 				allow_write_access(bprm->file);
 				if (bprm->file)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index f633478..3054a97 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -275,6 +275,28 @@ TRACE_EVENT(sched_process_fork,
 );
 
 /*
+ * Tracepoint for exec:
+ */
+TRACE_EVENT(sched_process_exec,
+
+	TP_PROTO(struct linux_binprm *bprm),
+
+	TP_ARGS(bprm),
+
+	TP_STRUCT__entry(
+		__string(	filename,	bprm->filename	)
+		__field(	pid_t,		pid		)
+	),
+
+	TP_fast_assign(
+		__assign_str(filename, bprm->filename);
+		__entry->pid	= current->pid;
+	),
+
+	TP_printk("filename=%s pid=%d", __get_str(filename), __entry->pid)
+);
+
+/*
  * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
  *     adding sched_stat support to SCHED_FIFO/RR would be welcome.
  */

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] Tracepoint: add exec tracepoint
  2011-10-18 18:41 [RFC PATCH] Tracepoint: add exec tracepoint David Smith
@ 2011-10-18 18:58 ` Christoph Hellwig
  2011-10-18 19:31   ` David Smith
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2011-10-18 18:58 UTC (permalink / raw)
  To: David Smith; +Cc: Linux Kernel Mailing List, Steven Rostedt

On Tue, Oct 18, 2011 at 01:41:35PM -0500, David Smith wrote:
> Added general purpose exec tracepoint.  The 'bprm' argument gives details of the exec.

Given that you only need the filename from the bprm please just pass
it directly.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] Tracepoint: add exec tracepoint
  2011-10-18 18:58 ` Christoph Hellwig
@ 2011-10-18 19:31   ` David Smith
  2011-10-18 20:26     ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: David Smith @ 2011-10-18 19:31 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Linux Kernel Mailing List, Steven Rostedt

On 10/18/2011 01:58 PM, Christoph Hellwig wrote:

> On Tue, Oct 18, 2011 at 01:41:35PM -0500, David Smith wrote:
>> Added general purpose exec tracepoint.  The 'bprm' argument gives details of the exec.
> 
> Given that you only need the filename from the bprm please just pass
> it directly.


Thanks for looking at the patch.

I'm not totally opposed to this change, but passing bprm allows custom
tracepoint handlers to look at other fields in bprm besides filename,
which could be useful (depending on your needs).

But, I don't have a real strong opinion here.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] Tracepoint: add exec tracepoint
  2011-10-18 19:31   ` David Smith
@ 2011-10-18 20:26     ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2011-10-18 20:26 UTC (permalink / raw)
  To: David Smith; +Cc: Christoph Hellwig, Linux Kernel Mailing List

On Tue, 2011-10-18 at 14:31 -0500, David Smith wrote:
> On 10/18/2011 01:58 PM, Christoph Hellwig wrote:
> 
> > On Tue, Oct 18, 2011 at 01:41:35PM -0500, David Smith wrote:
> >> Added general purpose exec tracepoint.  The 'bprm' argument gives details of the exec.
> > 
> > Given that you only need the filename from the bprm please just pass
> > it directly.
> 
> 
> Thanks for looking at the patch.
> 
> I'm not totally opposed to this change, but passing bprm allows custom
> tracepoint handlers to look at other fields in bprm besides filename,
> which could be useful (depending on your needs).

I like flexible tracepoints too.

> 
> But, I don't have a real strong opinion here.
> 

I rather pass the pointer. If we pass the string, gcc may not optimize
when tracing is disabled and still do the work to dereference the
pointer unnecessarily.

-- Steve




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-18 20:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-18 18:41 [RFC PATCH] Tracepoint: add exec tracepoint David Smith
2011-10-18 18:58 ` Christoph Hellwig
2011-10-18 19:31   ` David Smith
2011-10-18 20:26     ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox