xref: /openbmc/linux/include/trace/events/migrate.h (revision 276e552e)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM migrate
4 
5 #if !defined(_TRACE_MIGRATE_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_MIGRATE_H
7 
8 #include <linux/tracepoint.h>
9 
10 #define MIGRATE_MODE						\
11 	EM( MIGRATE_ASYNC,	"MIGRATE_ASYNC")		\
12 	EM( MIGRATE_SYNC_LIGHT,	"MIGRATE_SYNC_LIGHT")		\
13 	EMe(MIGRATE_SYNC,	"MIGRATE_SYNC")
14 
15 
16 #define MIGRATE_REASON						\
17 	EM( MR_COMPACTION,	"compaction")			\
18 	EM( MR_MEMORY_FAILURE,	"memory_failure")		\
19 	EM( MR_MEMORY_HOTPLUG,	"memory_hotplug")		\
20 	EM( MR_SYSCALL,		"syscall_or_cpuset")		\
21 	EM( MR_MEMPOLICY_MBIND,	"mempolicy_mbind")		\
22 	EM( MR_NUMA_MISPLACED,	"numa_misplaced")		\
23 	EM( MR_CONTIG_RANGE,	"contig_range")			\
24 	EMe(MR_LONGTERM_PIN,	"longterm_pin")
25 
26 /*
27  * First define the enums in the above macros to be exported to userspace
28  * via TRACE_DEFINE_ENUM().
29  */
30 #undef EM
31 #undef EMe
32 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
33 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
34 
35 MIGRATE_MODE
36 MIGRATE_REASON
37 
38 /*
39  * Now redefine the EM() and EMe() macros to map the enums to the strings
40  * that will be printed in the output.
41  */
42 #undef EM
43 #undef EMe
44 #define EM(a, b)	{a, b},
45 #define EMe(a, b)	{a, b}
46 
47 TRACE_EVENT(mm_migrate_pages,
48 
49 	TP_PROTO(unsigned long succeeded, unsigned long failed,
50 		 unsigned long thp_succeeded, unsigned long thp_failed,
51 		 unsigned long thp_split, enum migrate_mode mode, int reason),
52 
53 	TP_ARGS(succeeded, failed, thp_succeeded, thp_failed,
54 		thp_split, mode, reason),
55 
56 	TP_STRUCT__entry(
57 		__field(	unsigned long,		succeeded)
58 		__field(	unsigned long,		failed)
59 		__field(	unsigned long,		thp_succeeded)
60 		__field(	unsigned long,		thp_failed)
61 		__field(	unsigned long,		thp_split)
62 		__field(	enum migrate_mode,	mode)
63 		__field(	int,			reason)
64 	),
65 
66 	TP_fast_assign(
67 		__entry->succeeded	= succeeded;
68 		__entry->failed		= failed;
69 		__entry->thp_succeeded	= thp_succeeded;
70 		__entry->thp_failed	= thp_failed;
71 		__entry->thp_split	= thp_split;
72 		__entry->mode		= mode;
73 		__entry->reason		= reason;
74 	),
75 
76 	TP_printk("nr_succeeded=%lu nr_failed=%lu nr_thp_succeeded=%lu nr_thp_failed=%lu nr_thp_split=%lu mode=%s reason=%s",
77 		__entry->succeeded,
78 		__entry->failed,
79 		__entry->thp_succeeded,
80 		__entry->thp_failed,
81 		__entry->thp_split,
82 		__print_symbolic(__entry->mode, MIGRATE_MODE),
83 		__print_symbolic(__entry->reason, MIGRATE_REASON))
84 );
85 
86 TRACE_EVENT(mm_migrate_pages_start,
87 
88 	TP_PROTO(enum migrate_mode mode, int reason),
89 
90 	TP_ARGS(mode, reason),
91 
92 	TP_STRUCT__entry(
93 		__field(enum migrate_mode, mode)
94 		__field(int, reason)
95 	),
96 
97 	TP_fast_assign(
98 		__entry->mode	= mode;
99 		__entry->reason	= reason;
100 	),
101 
102 	TP_printk("mode=%s reason=%s",
103 		  __print_symbolic(__entry->mode, MIGRATE_MODE),
104 		  __print_symbolic(__entry->reason, MIGRATE_REASON))
105 );
106 
107 #endif /* _TRACE_MIGRATE_H */
108 
109 /* This part must be outside protection */
110 #include <trace/define_trace.h>
111