[PATCH -tip 2/3] Add coredump tracepoint

From: Masami Hiramatsu
Date: Fri Nov 13 2009 - 17:53:05 EST


Add coredump tracepoint for tracing coredump event. This event shows coredump
caused signal, limit size, dumpable flag, dump-filter, and core name.

Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Cc: Roland McGrath <roland@xxxxxxxxxx>
---

fs/exec.c | 9 +++++++++
include/trace/events/sched.h | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index dc418e3..6b77d10 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -56,6 +56,7 @@
#include <linux/fsnotify.h>
#include <linux/fs_struct.h>
#include <linux/pipe_fs_i.h>
+#include <trace/events/sched.h>

#include <asm/uaccess.h>
#include <asm/mmu_context.h>
@@ -1907,6 +1908,14 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
goto close_fail;

+ /*
+ * Trace core dump event.
+ * Casting signr to int is safe because it comes from
+ * si->signo int field.
+ */
+ trace_sched_process_coredump((int)signr, core_limit, mm_flags,
+ corename);
+
retval = binfmt->core_dump(signr, regs, file, core_limit, mm_flags);

if (retval)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index b50b985..ff9d5fb 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -320,6 +320,40 @@ TRACE_EVENT(sched_process_fork,
);

/*
+ * Tracepoint for core_dump:
+ */
+TRACE_EVENT(sched_process_coredump,
+
+ TP_PROTO(int sig, unsigned long core_limit, unsigned long mm_flags,
+ const char *core_name),
+
+ TP_ARGS(sig, core_limit, mm_flags, core_name),
+
+ TP_STRUCT__entry(
+ __field( int, sig )
+ __field( unsigned long, limit )
+ __field( unsigned long, flags )
+ __string( name, core_name )
+ ),
+
+
+ TP_fast_assign(
+ __entry->sig = sig;
+ __entry->limit = core_limit;
+ __entry->flags = mm_flags;
+ __assign_str(name, core_name);
+ ),
+
+ TP_printk("sig: %d limit: %lu dumpable: %lx dump_filter: %lx "
+ "corename: %s",
+ __entry->sig, __entry->limit,
+ __entry->flags & MMF_DUMPABLE_MASK,
+ (__entry->flags & MMF_DUMP_FILTER_MASK) >>
+ MMF_DUMP_FILTER_SHIFT,
+ __get_str(name))
+);
+
+/*
* Tracepoint for sending a signal:
*/
TRACE_EVENT(sched_signal_send,


--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@xxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/