
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 be34d94d26bd..8378250cbb4b 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: @@ -1255,6 +1256,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); } struct cpumask xcall_numa_cpumask[4] __read_mostly; @@ -1380,6 +1382,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); queue_work_on(t_cpu, rc_work, &pfi->work); spin_unlock(&pfi->pfi_lock); } diff --git a/fs/read_write.c b/fs/read_write.c index 81ca30ff069c..55e3f4b0ad3e 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -635,6 +635,7 @@ static int xcall_read(struct prefetch_item *pfi, struct fd *f, unsigned int fd, if (!spin_trylock(&pfi->pfi_lock)) { this_cpu_inc(xcall_cache_wait); + trace_epoll_rc_wait(fd); spin_lock(&pfi->pfi_lock); } @@ -663,6 +664,7 @@ static int xcall_read(struct prefetch_item *pfi, struct fd *f, unsigned int fd, hit_return: this_cpu_inc(xcall_cache_hit); + trace_epoll_rc_hit(fd, copy_len); fdput_pos(*f); spin_unlock(&pfi->pfi_lock); @@ -681,6 +683,7 @@ static int xcall_read(struct prefetch_item *pfi, struct fd *f, unsigned int fd, pfi->state = EPOLL_FILE_CACHE_NONE; this_cpu_inc(xcall_cache_miss); cancel_work(&pfi->work); + trace_epoll_rc_miss(fd); spin_unlock(&pfi->pfi_lock); return -EAGAIN; 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