
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/release-management/issues/IC9Q31 -------------------------------- For xcall prefetch different cache state, add tracepoints. Signed-off-by: Yipeng Zou <zouyipeng@huawei.com> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- fs/eventpoll.c | 9 +++ include/trace/events/xcall.h | 106 +++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 include/trace/events/xcall.h diff --git a/fs/eventpoll.c b/fs/eventpoll.c index a60e7f7b12ef..0793174a5c69 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -769,6 +769,9 @@ static void epi_rcu_free(struct rcu_head *head) } #ifdef CONFIG_XCALL_PREFETCH +#define CREATE_TRACE_POINTS +#include <trace/events/xcall.h> + #define XCALL_CACHE_PAGE_ORDER 2 #define XCALL_CACHE_BUF_SIZE ((1 << XCALL_CACHE_PAGE_ORDER) * PAGE_SIZE) DEFINE_PER_CPU_ALIGNED(unsigned long, xcall_cache_hit); @@ -931,10 +934,12 @@ static void prefetch_work_fn(struct work_struct *work) if (!transition_state(pfi, XCALL_CACHE_NONE, XCALL_CACHE_PREFETCH)) return; + trace_epoll_rc_prefetch(pfi->file); pfi->pos = 0; pfi->len = kernel_read(pfi->file, pfi->cache, XCALL_CACHE_BUF_SIZE, &pfi->file->f_pos); transition_state(pfi, XCALL_CACHE_PREFETCH, XCALL_CACHE_READY); + trace_epoll_rc_ready(pfi->file, pfi->len); } static void set_prefetch_numa_cpu(struct prefetch_item *pfi, int fd) @@ -1046,6 +1051,7 @@ static int xcall_read(struct prefetch_item *pfi, char __user *buf, size_t count) if (copy_len == 0) { this_cpu_inc(xcall_cache_hit); + trace_epoll_rc_hit(pfi->file, 0); transition_state(pfi, XCALL_CACHE_CANCEL, XCALL_CACHE_NONE); return 0; } @@ -1060,10 +1066,12 @@ static int xcall_read(struct prefetch_item *pfi, char __user *buf, size_t count) transition_state(pfi, XCALL_CACHE_CANCEL, XCALL_CACHE_READY); this_cpu_inc(xcall_cache_hit); + trace_epoll_rc_hit(pfi->file, copy_len); return copy_len; slow_read: this_cpu_inc(xcall_cache_miss); + trace_epoll_rc_miss(pfi->file); pfi->len = 0; pfi->pos = 0; cancel_work(&pfi->work); @@ -1141,6 +1149,7 @@ static void ep_prefetch_item_enqueue(struct eventpoll *ep, struct epitem *epi) cpu = get_async_prefetch_cpu(pfi); queue_work_on(cpu, rc_work, &pfi->work); + trace_epoll_rc_queue(pfi->file, cpu); } static void xcall_cancel_work(struct file *file) diff --git a/include/trace/events/xcall.h b/include/trace/events/xcall.h new file mode 100644 index 000000000000..524a21e433ba --- /dev/null +++ b/include/trace/events/xcall.h @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM xcall + +#if !defined(_TRACE_XCALL_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_XCALL_H + +#include <linux/types.h> +#include <linux/tracepoint.h> +#include <linux/fs.h> + +TRACE_EVENT(epoll_rc_queue, + + TP_PROTO(struct file *file, int cpu), + + TP_ARGS(file, cpu), + + TP_STRUCT__entry( + __field(struct file *, file) + __field(int, cpu) + ), + + TP_fast_assign( + __entry->file = file; + __entry->cpu = cpu; + ), + + TP_printk("0x%p on cpu %d", __entry->file, __entry->cpu) +); + +TRACE_EVENT(epoll_rc_prefetch, + + TP_PROTO(struct file *file), + + TP_ARGS(file), + + TP_STRUCT__entry( + __field(struct file *, file) + ), + + TP_fast_assign( + __entry->file = file; + ), + + TP_printk("0x%p", __entry->file) +); + +TRACE_EVENT(epoll_rc_ready, + + TP_PROTO(struct file *file, int len), + + TP_ARGS(file, len), + + TP_STRUCT__entry( + __field(struct file *, file) + __field(int, len) + ), + + TP_fast_assign( + __entry->file = file; + __entry->len = len; + ), + + TP_printk("0x%p, len %d", __entry->file, __entry->len) +); + +TRACE_EVENT(epoll_rc_hit, + + TP_PROTO(struct file *file, int len), + + TP_ARGS(file, len), + + TP_STRUCT__entry( + __field(struct file *, file) + __field(int, len) + ), + + TP_fast_assign( + __entry->file = file; + __entry->len = len; + ), + + TP_printk("0x%p, len: %d", __entry->file, __entry->len) +); + +TRACE_EVENT(epoll_rc_miss, + + TP_PROTO(struct file *file), + + TP_ARGS(file), + + TP_STRUCT__entry( + __field(struct file *, file) + ), + + TP_fast_assign( + __entry->file = file; + ), + + TP_printk("0x%p", __entry->file) +); + +#endif /* _TRACE_XCALL_H */ + +/* This part must be outside protection */ +#include <trace/define_trace.h> -- 2.34.1