Scott James Remnant | 56686d6 | 2009-11-09 18:38:51 +0000 | [diff] [blame] | 1 | From ee9c0b591bf16ca11bb354bc68dae75a903f3a64 Mon Sep 17 00:00:00 2001 |
| 2 | From: Scott James Remnant <scott@ubuntu.com> |
| 3 | Date: Tue, 27 Oct 2009 10:05:32 +0000 |
| 4 | Subject: [PATCH] trace: add trace events for open(), exec() and uselib() |
| 5 | |
| 6 | This patch uses TRACE_EVENT to add tracepoints for the open(), |
| 7 | exec() and uselib() syscalls so that ureadahead can cheaply trace |
| 8 | the boot sequence to determine what to read to speed up the next. |
| 9 | |
| 10 | It's not upstream because it will need to be rebased onto the syscall |
| 11 | trace events whenever that gets merged, and is a stop-gap. |
| 12 | |
| 13 | Signed-off-by: Scott James Remnant <scott@ubuntu.com> |
| 14 | --- |
| 15 | fs/exec.c | 8 +++++ |
| 16 | fs/open.c | 4 ++ |
| 17 | include/trace/events/fs.h | 71 +++++++++++++++++++++++++++++++++++++++++++++ |
| 18 | 3 files changed, 83 insertions(+), 0 deletions(-) |
| 19 | create mode 100644 include/trace/events/fs.h |
| 20 | |
| 21 | diff --git a/fs/exec.c b/fs/exec.c |
| 22 | index 172ceb6..c936999 100644 |
| 23 | --- a/fs/exec.c |
| 24 | +++ b/fs/exec.c |
| 25 | @@ -56,6 +56,8 @@ |
| 26 | #include <linux/fsnotify.h> |
| 27 | #include <linux/fs_struct.h> |
| 28 | |
| 29 | +#include <trace/events/fs.h> |
| 30 | + |
| 31 | #include <asm/uaccess.h> |
| 32 | #include <asm/mmu_context.h> |
| 33 | #include <asm/tlb.h> |
| 34 | @@ -130,6 +132,10 @@ SYSCALL_DEFINE1(uselib, const char __user *, library) |
| 35 | |
| 36 | fsnotify_open(file->f_path.dentry); |
| 37 | |
| 38 | + tmp = getname(library); |
| 39 | + trace_uselib(tmp); |
| 40 | + putname(library); |
| 41 | + |
| 42 | error = -ENOEXEC; |
| 43 | if(file->f_op) { |
| 44 | struct linux_binfmt * fmt; |
| 45 | @@ -665,6 +671,8 @@ struct file *open_exec(const char *name) |
| 46 | |
| 47 | fsnotify_open(file->f_path.dentry); |
| 48 | |
| 49 | + trace_open_exec(name); |
| 50 | + |
| 51 | err = deny_write_access(file); |
| 52 | if (err) |
| 53 | goto exit; |
| 54 | diff --git a/fs/open.c b/fs/open.c |
| 55 | index 04b9aad..41c87f3 100644 |
| 56 | --- a/fs/open.c |
| 57 | +++ b/fs/open.c |
| 58 | @@ -31,6 +31,9 @@ |
| 59 | #include <linux/falloc.h> |
| 60 | #include <linux/fs_struct.h> |
| 61 | |
| 62 | +#define CREATE_TRACE_POINTS |
| 63 | +#include <trace/events/fs.h> |
| 64 | + |
| 65 | int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
| 66 | { |
| 67 | int retval = -ENODEV; |
| 68 | @@ -1041,6 +1044,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode) |
| 69 | } else { |
| 70 | fsnotify_open(f->f_path.dentry); |
| 71 | fd_install(fd, f); |
| 72 | + trace_do_sys_open(tmp, flags, mode); |
| 73 | } |
| 74 | } |
| 75 | putname(tmp); |
| 76 | diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h |
| 77 | new file mode 100644 |
| 78 | index 0000000..e967c55 |
| 79 | --- /dev/null |
| 80 | +++ b/include/trace/events/fs.h |
| 81 | @@ -0,0 +1,71 @@ |
| 82 | +#undef TRACE_SYSTEM |
| 83 | +#define TRACE_SYSTEM fs |
| 84 | + |
| 85 | +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ) |
| 86 | +#define _TRACE_FS_H |
| 87 | + |
| 88 | +#include <linux/fs.h> |
| 89 | +#include <linux/tracepoint.h> |
| 90 | + |
| 91 | +TRACE_EVENT(do_sys_open, |
| 92 | + |
| 93 | + TP_PROTO(char *filename, int flags, int mode), |
| 94 | + |
| 95 | + TP_ARGS(filename, flags, mode), |
| 96 | + |
| 97 | + TP_STRUCT__entry( |
| 98 | + __string( filename, filename ) |
| 99 | + __field( int, flags ) |
| 100 | + __field( int, mode ) |
| 101 | + ), |
| 102 | + |
| 103 | + TP_fast_assign( |
| 104 | + __assign_str(filename, filename); |
| 105 | + __entry->flags = flags; |
| 106 | + __entry->mode = mode; |
| 107 | + ), |
| 108 | + |
| 109 | + TP_printk("\"%s\" %x %o", |
| 110 | + __get_str(filename), __entry->flags, __entry->mode) |
| 111 | +); |
| 112 | + |
| 113 | +TRACE_EVENT(uselib, |
| 114 | + |
| 115 | + TP_PROTO(char *filename), |
| 116 | + |
| 117 | + TP_ARGS(filename), |
| 118 | + |
| 119 | + TP_STRUCT__entry( |
| 120 | + __string( filename, filename ) |
| 121 | + ), |
| 122 | + |
| 123 | + TP_fast_assign( |
| 124 | + __assign_str(filename, filename); |
| 125 | + ), |
| 126 | + |
| 127 | + TP_printk("\"%s\"", |
| 128 | + __get_str(filename)) |
| 129 | +); |
| 130 | + |
| 131 | +TRACE_EVENT(open_exec, |
| 132 | + |
| 133 | + TP_PROTO(char *filename), |
| 134 | + |
| 135 | + TP_ARGS(filename), |
| 136 | + |
| 137 | + TP_STRUCT__entry( |
| 138 | + __string( filename, filename ) |
| 139 | + ), |
| 140 | + |
| 141 | + TP_fast_assign( |
| 142 | + __assign_str(filename, filename); |
| 143 | + ), |
| 144 | + |
| 145 | + TP_printk("\"%s\"", |
| 146 | + __get_str(filename)) |
| 147 | +); |
| 148 | + |
| 149 | +#endif /* _TRACE_FS_H */ |
| 150 | + |
| 151 | +/* This part must be outside protection */ |
| 152 | +#include <trace/define_trace.h> |
| 153 | -- |
| 154 | 1.6.3.3 |
| 155 | |