xref: /openbmc/linux/include/trace/events/pagemap.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2c6286c98SMel Gorman #undef TRACE_SYSTEM
3c6286c98SMel Gorman #define TRACE_SYSTEM pagemap
4c6286c98SMel Gorman 
5c6286c98SMel Gorman #if !defined(_TRACE_PAGEMAP_H) || defined(TRACE_HEADER_MULTI_READ)
6c6286c98SMel Gorman #define _TRACE_PAGEMAP_H
7c6286c98SMel Gorman 
8c6286c98SMel Gorman #include <linux/tracepoint.h>
9c6286c98SMel Gorman #include <linux/mm.h>
10c6286c98SMel Gorman 
11c6286c98SMel Gorman #define	PAGEMAP_MAPPED		0x0001u
12c6286c98SMel Gorman #define PAGEMAP_ANONYMOUS	0x0002u
13c6286c98SMel Gorman #define PAGEMAP_FILE		0x0004u
14c6286c98SMel Gorman #define PAGEMAP_SWAPCACHE	0x0008u
15c6286c98SMel Gorman #define PAGEMAP_SWAPBACKED	0x0010u
16c6286c98SMel Gorman #define PAGEMAP_MAPPEDDISK	0x0020u
17c6286c98SMel Gorman #define PAGEMAP_BUFFERS		0x0040u
18c6286c98SMel Gorman 
19*934387c9SMatthew Wilcox (Oracle) #define trace_pagemap_flags(folio) ( \
20*934387c9SMatthew Wilcox (Oracle) 	(folio_test_anon(folio)		? PAGEMAP_ANONYMOUS  : PAGEMAP_FILE) | \
21*934387c9SMatthew Wilcox (Oracle) 	(folio_mapped(folio)		? PAGEMAP_MAPPED     : 0) | \
22*934387c9SMatthew Wilcox (Oracle) 	(folio_test_swapcache(folio)	? PAGEMAP_SWAPCACHE  : 0) | \
23*934387c9SMatthew Wilcox (Oracle) 	(folio_test_swapbacked(folio)	? PAGEMAP_SWAPBACKED : 0) | \
24*934387c9SMatthew Wilcox (Oracle) 	(folio_test_mappedtodisk(folio)	? PAGEMAP_MAPPEDDISK : 0) | \
25*934387c9SMatthew Wilcox (Oracle) 	(folio_test_private(folio)	? PAGEMAP_BUFFERS    : 0) \
26c6286c98SMel Gorman 	)
27c6286c98SMel Gorman 
28c6286c98SMel Gorman TRACE_EVENT(mm_lru_insertion,
29c6286c98SMel Gorman 
30*934387c9SMatthew Wilcox (Oracle) 	TP_PROTO(struct folio *folio),
31c6286c98SMel Gorman 
32*934387c9SMatthew Wilcox (Oracle) 	TP_ARGS(folio),
33c6286c98SMel Gorman 
34c6286c98SMel Gorman 	TP_STRUCT__entry(
35*934387c9SMatthew Wilcox (Oracle) 		__field(struct folio *,	folio	)
36c6286c98SMel Gorman 		__field(unsigned long,	pfn	)
3786140453SYu Zhao 		__field(enum lru_list,	lru	)
38c6286c98SMel Gorman 		__field(unsigned long,	flags	)
39c6286c98SMel Gorman 	),
40c6286c98SMel Gorman 
41c6286c98SMel Gorman 	TP_fast_assign(
42*934387c9SMatthew Wilcox (Oracle) 		__entry->folio	= folio;
43*934387c9SMatthew Wilcox (Oracle) 		__entry->pfn	= folio_pfn(folio);
44*934387c9SMatthew Wilcox (Oracle) 		__entry->lru	= folio_lru_list(folio);
45*934387c9SMatthew Wilcox (Oracle) 		__entry->flags	= trace_pagemap_flags(folio);
46c6286c98SMel Gorman 	),
47c6286c98SMel Gorman 
48c6286c98SMel Gorman 	/* Flag format is based on page-types.c formatting for pagemap */
49*934387c9SMatthew Wilcox (Oracle) 	TP_printk("folio=%p pfn=0x%lx lru=%d flags=%s%s%s%s%s%s",
50*934387c9SMatthew Wilcox (Oracle) 			__entry->folio,
51c6286c98SMel Gorman 			__entry->pfn,
52c6286c98SMel Gorman 			__entry->lru,
53c6286c98SMel Gorman 			__entry->flags & PAGEMAP_MAPPED		? "M" : " ",
54c6286c98SMel Gorman 			__entry->flags & PAGEMAP_ANONYMOUS	? "a" : "f",
55c6286c98SMel Gorman 			__entry->flags & PAGEMAP_SWAPCACHE	? "s" : " ",
56c6286c98SMel Gorman 			__entry->flags & PAGEMAP_SWAPBACKED	? "b" : " ",
57c6286c98SMel Gorman 			__entry->flags & PAGEMAP_MAPPEDDISK	? "d" : " ",
58c6286c98SMel Gorman 			__entry->flags & PAGEMAP_BUFFERS	? "B" : " ")
59c6286c98SMel Gorman );
60c6286c98SMel Gorman 
61c6286c98SMel Gorman TRACE_EVENT(mm_lru_activate,
62c6286c98SMel Gorman 
63f2d27392SMatthew Wilcox (Oracle) 	TP_PROTO(struct folio *folio),
64c6286c98SMel Gorman 
65f2d27392SMatthew Wilcox (Oracle) 	TP_ARGS(folio),
66c6286c98SMel Gorman 
67c6286c98SMel Gorman 	TP_STRUCT__entry(
68f2d27392SMatthew Wilcox (Oracle) 		__field(struct folio *,	folio	)
69c6286c98SMel Gorman 		__field(unsigned long,	pfn	)
70c6286c98SMel Gorman 	),
71c6286c98SMel Gorman 
72c6286c98SMel Gorman 	TP_fast_assign(
73f2d27392SMatthew Wilcox (Oracle) 		__entry->folio	= folio;
74f2d27392SMatthew Wilcox (Oracle) 		__entry->pfn	= folio_pfn(folio);
75c6286c98SMel Gorman 	),
76c6286c98SMel Gorman 
77f2d27392SMatthew Wilcox (Oracle) 	TP_printk("folio=%p pfn=0x%lx", __entry->folio, __entry->pfn)
78c6286c98SMel Gorman );
79c6286c98SMel Gorman 
80c6286c98SMel Gorman #endif /* _TRACE_PAGEMAP_H */
81c6286c98SMel Gorman 
82c6286c98SMel Gorman /* This part must be outside protection */
83c6286c98SMel Gorman #include <trace/define_trace.h>
84