
From: Yipeng Zou <zouyipeng@huawei.com> Add tracepoint. Signed-off-by: Yipeng Zou <zouyipeng@huawei.com> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- fs/eventpoll.c | 3 ++ fs/read_write.c | 3 ++ include/trace/events/fs.h | 91 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 189b80488eca..e0cdb9172732 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -38,6 +38,7 @@ #include <linux/compat.h> #include <linux/rculist.h> #include <net/busy_poll.h> +#include <trace/events/fs.h> /* * LOCKING: @@ -1233,6 +1234,7 @@ static void do_prefetch_item(struct prefetch_item *pfi) pfi->len = kernel_read(pfi->f, pfi->cache, max_fd_cache_pages * PAGE_SIZE, &pfi->f->f_pos); pfi->state = EPOLL_FILE_CACHE_READY; + trace_epoll_rc_ready(pfi->fd, pfi->len); pfi->keep_running = false; } @@ -1409,6 +1411,7 @@ static void ep_prefetch_item_enqueue(struct eventpoll *ep, struct epitem *epi) spin_lock(&pfi->pfi_lock); pfi->state = EPOLL_FILE_CACHE_QUEUED; + trace_epoll_rc_queue(epi->ffd.fd, t_cpu); pfi->rc->cache_queued++; if (pfi->rc->sync_mode) do_prefetch_item(pfi); diff --git a/fs/read_write.c b/fs/read_write.c index 119c2788fac8..5505409209ea 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -633,6 +633,7 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count) if (!spin_trylock(&pfi->pfi_lock)) { if (current->rc) current->rc->cache_wait++; + trace_epoll_rc_wait(fd); spin_lock(&pfi->pfi_lock); } @@ -662,6 +663,7 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count) if (current->rc) current->rc->cache_hit++; + trace_epoll_rc_hit(fd, copy_len); fdput_pos(f); spin_unlock(&pfi->pfi_lock); @@ -676,6 +678,7 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count) if (current->rc) current->rc->cache_miss++; cancel_work(&pfi->work); + trace_epoll_rc_miss(fd); spin_unlock(&pfi->pfi_lock); if (copy_len < 0) diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h index ee82dad9d9da..d5bfd22647dd 100644 --- a/include/trace/events/fs.h +++ b/include/trace/events/fs.h @@ -29,5 +29,96 @@ DECLARE_TRACE(fs_file_release, #endif /* _TRACE_FS_H */ +TRACE_EVENT(epoll_rc_ready, + + TP_PROTO(int fd, int len), + + TP_ARGS(fd, len), + + TP_STRUCT__entry( + __field(int, fd) + __field(int, len) + ), + + TP_fast_assign( + __entry->fd = fd; + __entry->len = len; + ), + + TP_printk("%d, len %d", __entry->fd, __entry->len) +); + +TRACE_EVENT(epoll_rc_queue, + + TP_PROTO(int fd, int cpu), + + TP_ARGS(fd, cpu), + + TP_STRUCT__entry( + __field(int, fd) + __field(int, cpu) + ), + + TP_fast_assign( + __entry->fd = fd; + __entry->cpu = cpu; + ), + + TP_printk("%d on cpu %d", __entry->fd, __entry->cpu) +); + +TRACE_EVENT(epoll_rc_hit, + + TP_PROTO(int fd, int len), + + TP_ARGS(fd, len), + + TP_STRUCT__entry( + __field(int, fd) + __field(int, len) + ), + + TP_fast_assign( + __entry->fd = fd; + __entry->len = len; + ), + + TP_printk("%d, len: %d", __entry->fd, __entry->len) +); + +TRACE_EVENT(epoll_rc_miss, + + TP_PROTO(int fd), + + TP_ARGS(fd), + + TP_STRUCT__entry( + __field(int, fd) + ), + + TP_fast_assign( + __entry->fd = fd; + ), + + TP_printk("%d", __entry->fd) +); + +TRACE_EVENT(epoll_rc_wait, + + TP_PROTO(int fd), + + TP_ARGS(fd), + + TP_STRUCT__entry( + __field(int, fd) + ), + + TP_fast_assign( + __entry->fd = fd; + ), + + TP_printk("%d", __entry->fd) +); + /* This part must be outside protection */ #include <trace/define_trace.h> -- 2.34.1