Create a module which declares FS tracepoint probes, using markers. Signed-off-by: Mathieu Desnoyers CC: Alexander Viro CC: 'Peter Zijlstra' CC: "Frank Ch. Eigler" CC: 'Ingo Molnar' CC: 'Hideo AOKI' CC: Takashi Nishiie CC: 'Steven Rostedt' CC: Masami Hiramatsu --- fs/Makefile | 1 fs/fs-trace.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) Index: linux-2.6-lttng/fs/fs-trace.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6-lttng/fs/fs-trace.c 2008-07-04 19:30:42.000000000 -0400 @@ -0,0 +1,167 @@ +/* + * fs/fs-trace.c + * + * FS tracepoint probes. + */ + +#include +#include +#include "fs-trace.h" + +static void probe_fs_buffer_wait_start(struct buffer_head *bh) +{ + trace_mark(fs_buffer_wait_start, "bh %p", bh); +} + +static void probe_fs_buffer_wait_end(struct buffer_head *bh) +{ + trace_mark(fs_buffer_wait_end, "bh %p", bh); +} + +static void probe_fs_exec(char *filename) +{ + trace_mark(fs_exec, "filename %s", filename); +} + +static void probe_fs_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) +{ + trace_mark(fs_ioctl, "fd %u cmd %u arg %lu", fd, cmd, arg); +} + +static void probe_fs_open(int fd, char *filename) +{ + trace_mark(fs_open, "fd %d filename %s", fd, filename); +} + +static void probe_fs_close(unsigned int fd) +{ + trace_mark(fs_close, "fd %u", fd); +} + +static void probe_fs_lseek(unsigned int fd, long offset, unsigned int origin) +{ + trace_mark(fs_lseek, "fd %u offset %ld origin %u", fd, offset, origin); +} + +static void probe_fs_llseek(unsigned int fd, loff_t offset, unsigned int origin) +{ + trace_mark(fs_llseek, "fd %u offset %lld origin %u", fd, + (long long)offset, origin); +} + +static void probe_fs_read(unsigned int fd, char __user *buf, size_t count, + ssize_t ret) +{ + trace_mark(fs_read, "fd %u count %zu", fd, count); +} + +static void probe_fs_write(unsigned int fd, const char __user *buf, + size_t count, ssize_t ret) +{ + trace_mark(fs_write, "fd %u count %zu", fd, count); +} + +static void probe_fs_pread64(unsigned int fd, char __user *buf, size_t count, + loff_t pos, ssize_t ret) +{ + trace_mark(fs_pread64, "fd %u count %zu pos %llu", + fd, count, (unsigned long long)pos); +} + +static void probe_fs_pwrite64(unsigned int fd, const char __user *buf, + size_t count, loff_t pos, ssize_t ret) +{ + trace_mark(fs_pwrite64, "fd %u count %zu pos %llu", + fd, count, (unsigned long long)pos); +} + +static void probe_fs_readv(unsigned long fd, const struct iovec __user *vec, + unsigned long vlen, ssize_t ret) +{ + trace_mark(fs_readv, "fd %lu vlen %lu", fd, vlen); +} + +static void probe_fs_writev(unsigned long fd, const struct iovec __user *vec, + unsigned long vlen, ssize_t ret) +{ + trace_mark(fs_writev, "fd %lu vlen %lu", fd, vlen); +} + +static void probe_fs_select(int fd, s64 timeout) +{ + trace_mark(fs_select, "fd %d timeout #8d%lld", fd, (long long)timeout); +} + +static void probe_fs_poll(int fd) +{ + trace_mark(fs_pollfd, "fd %d", fd); +} + + +int __init fs_trace_init(void) +{ + int ret; + + ret = register_trace_fs_buffer_wait_start(probe_fs_buffer_wait_start); + WARN_ON(ret); + ret = register_trace_fs_buffer_wait_end(probe_fs_buffer_wait_end); + WARN_ON(ret); + ret = register_trace_fs_exec(probe_fs_exec); + WARN_ON(ret); + ret = register_trace_fs_ioctl(probe_fs_ioctl); + WARN_ON(ret); + ret = register_trace_fs_open(probe_fs_open); + WARN_ON(ret); + ret = register_trace_fs_close(probe_fs_close); + WARN_ON(ret); + ret = register_trace_fs_lseek(probe_fs_lseek); + WARN_ON(ret); + ret = register_trace_fs_llseek(probe_fs_llseek); + WARN_ON(ret); + ret = register_trace_fs_read(probe_fs_read); + WARN_ON(ret); + ret = register_trace_fs_write(probe_fs_write); + WARN_ON(ret); + ret = register_trace_fs_pread64(probe_fs_pread64); + WARN_ON(ret); + ret = register_trace_fs_pwrite64(probe_fs_pwrite64); + WARN_ON(ret); + ret = register_trace_fs_readv(probe_fs_readv); + WARN_ON(ret); + ret = register_trace_fs_writev(probe_fs_writev); + WARN_ON(ret); + ret = register_trace_fs_select(probe_fs_select); + WARN_ON(ret); + ret = register_trace_fs_poll(probe_fs_poll); + WARN_ON(ret); + + return 0; +} + +module_init(fs_trace_init); + +void __exit fs_trace_exit(void) +{ + unregister_trace_fs_poll(probe_fs_poll); + unregister_trace_fs_select(probe_fs_select); + unregister_trace_fs_writev(probe_fs_writev); + unregister_trace_fs_readv(probe_fs_readv); + unregister_trace_fs_pwrite64(probe_fs_pwrite64); + unregister_trace_fs_pread64(probe_fs_pread64); + unregister_trace_fs_write(probe_fs_write); + unregister_trace_fs_read(probe_fs_read); + unregister_trace_fs_llseek(probe_fs_llseek); + unregister_trace_fs_lseek(probe_fs_lseek); + unregister_trace_fs_close(probe_fs_close); + unregister_trace_fs_open(probe_fs_open); + unregister_trace_fs_ioctl(probe_fs_ioctl); + unregister_trace_fs_exec(probe_fs_exec); + unregister_trace_fs_buffer_wait_end(probe_fs_buffer_wait_end); + unregister_trace_fs_buffer_wait_start(probe_fs_buffer_wait_start); +} + +module_exit(fs_trace_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("FS Tracepoint Probes"); Index: linux-2.6-lttng/fs/Makefile =================================================================== --- linux-2.6-lttng.orig/fs/Makefile 2008-07-04 19:21:32.000000000 -0400 +++ linux-2.6-lttng/fs/Makefile 2008-07-04 19:26:08.000000000 -0400 @@ -63,6 +63,7 @@ obj-$(CONFIG_CONFIGFS_FS) += configfs/ obj-y += devpts/ obj-$(CONFIG_PROFILING) += dcookies.o +obj-$(CONFIG_TRACEPROBES) += fs-trace.o obj-$(CONFIG_DLM) += dlm/ # Do not add any filesystems before this line -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/