[PATCH] trace: add trace_event for the open() syscall
Scott James Remnant
scott at ubuntu.com
Mon Jul 20 16:18:49 UTC 2009
This patch uses TRACE_EVENT to add a tracepoint for the open()
syscall, in the spirit of the previous patch for sreadahead
that added the trace with ftrace.
It's not upstream because a much better system for adding tracepoints
for all syscalls is being worked on upstream, this is a stop-gap until
we have that.
Signed-off-by: Scott James Remnant <scott at ubuntu.com>
---
fs/open.c | 4 ++++
include/trace/events/fs.h | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
create mode 100644 include/trace/events/fs.h
diff --git a/fs/open.c b/fs/open.c
index dd98e80..bc70440 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -31,6 +31,9 @@
#include <linux/falloc.h>
#include <linux/fs_struct.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/fs.h>
+
int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
{
int retval = -ENODEV;
@@ -1040,6 +1043,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
} else {
fsnotify_open(f->f_path.dentry);
fd_install(fd, f);
+ trace_do_sys_open(tmp, flags, mode);
}
}
putname(tmp);
diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
new file mode 100644
index 0000000..ae330c8
--- /dev/null
+++ b/include/trace/events/fs.h
@@ -0,0 +1,35 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM fs
+
+#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_FS_H
+
+#include <linux/fs.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(do_sys_open,
+
+ TP_PROTO(char *filename, int flags, int mode),
+
+ TP_ARGS(filename, flags, mode),
+
+ TP_STRUCT__entry(
+ __string( filename, filename )
+ __field( int, flags )
+ __field( int, mode )
+ ),
+
+ TP_fast_assign(
+ __assign_str(filename, filename);
+ __entry->flags = flags;
+ __entry->mode = mode;
+ ),
+
+ TP_printk("\"%s\" %x %o",
+ __get_str(filename), __entry->flags, __entry->mode)
+);
+
+#endif /* _TRACE_FS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
--
1.6.0.5
More information about the kernel-team
mailing list