This is a tracepoint event that contains the memcg pointer and an enum value representing the reason associated with the flush. Signed-off-by: JP Kobryn <inwardvessel@xxxxxxxxx> --- include/trace/events/memcg.h | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/include/trace/events/memcg.h b/include/trace/events/memcg.h index 8667e57816d2..9cccf0f13d4f 100644 --- a/include/trace/events/memcg.h +++ b/include/trace/events/memcg.h @@ -8,6 +8,43 @@ #include <linux/memcontrol.h> #include <linux/tracepoint.h> +#define MEMCG_FLUSH_REASONS \ + EM(TRACE_MEMCG_FLUSH_READER, "reader") \ + EM(TRACE_MEMCG_FLUSH_READER_SKIP, "reader skip") \ + EM(TRACE_MEMCG_FLUSH_PERIODIC, "periodic") \ + EMe(TRACE_MEMCG_FLUSH_ZSWAP, "zswap") + +#ifndef __MEMCG_DECLARE_TRACE_ENUMS_ONLY_ONCE +#define __MEMCG_DECLARE_TRACE_ENUMS_ONLY_ONCE + +/* Redefine macros to help declare enum */ +#undef EM +#undef EMe +#define EM(a, b) a, +#define EMe(a, b) a + +enum memcg_flush_reason { + MEMCG_FLUSH_REASONS +}; + +#endif /* __MEMCG_DECLARE_TRACE_ENUMS_ONLY_ONCE */ + +/* Redefine macros to export the enums to userspace */ +#undef EM +#undef EMe +#define EM(a, b) TRACE_DEFINE_ENUM(a); +#define EMe(a, b) TRACE_DEFINE_ENUM(a) + +MEMCG_FLUSH_REASONS; + +/* + * Redefine macros to map the enums to the strings that will + * be printed in the output + */ +#undef EM +#undef EMe +#define EM(a, b) { a, b }, +#define EMe(a, b) { a, b } DECLARE_EVENT_CLASS(memcg_rstat_stats, @@ -74,6 +111,25 @@ DEFINE_EVENT(memcg_rstat_events, count_memcg_events, TP_ARGS(memcg, item, val) ); +TRACE_EVENT(memcg_flush_stats, + + TP_PROTO(struct mem_cgroup *memcg, enum memcg_flush_reason reason), + + TP_ARGS(memcg, reason), + + TP_STRUCT__entry( + __field(u64, id) + __field(enum memcg_flush_reason, reason) + ), + + TP_fast_assign( + __entry->id = cgroup_id(memcg->css.cgroup); + __entry->reason = reason; + ), + + TP_printk("memcg_id=%llu reason=%s", + __entry->id, __print_symbolic(__entry->reason, MEMCG_FLUSH_REASONS)) +); #endif /* _TRACE_MEMCG_H */ -- 2.47.0