xref: /openbmc/linux/include/trace/events/migrate.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
27b2a2d4aSMel Gorman #undef TRACE_SYSTEM
37b2a2d4aSMel Gorman #define TRACE_SYSTEM migrate
47b2a2d4aSMel Gorman 
57b2a2d4aSMel Gorman #if !defined(_TRACE_MIGRATE_H) || defined(TRACE_HEADER_MULTI_READ)
67b2a2d4aSMel Gorman #define _TRACE_MIGRATE_H
77b2a2d4aSMel Gorman 
88643e92bSSteven Rostedt (Red Hat) #include <linux/tracepoint.h>
98643e92bSSteven Rostedt (Red Hat) 
107b2a2d4aSMel Gorman #define MIGRATE_MODE						\
11190f0b76SSteven Rostedt (Red Hat) 	EM( MIGRATE_ASYNC,	"MIGRATE_ASYNC")		\
12190f0b76SSteven Rostedt (Red Hat) 	EM( MIGRATE_SYNC_LIGHT,	"MIGRATE_SYNC_LIGHT")		\
13190f0b76SSteven Rostedt (Red Hat) 	EMe(MIGRATE_SYNC,	"MIGRATE_SYNC")
14190f0b76SSteven Rostedt (Red Hat) 
157b2a2d4aSMel Gorman 
167b2a2d4aSMel Gorman #define MIGRATE_REASON						\
17190f0b76SSteven Rostedt (Red Hat) 	EM( MR_COMPACTION,	"compaction")			\
18190f0b76SSteven Rostedt (Red Hat) 	EM( MR_MEMORY_FAILURE,	"memory_failure")		\
19190f0b76SSteven Rostedt (Red Hat) 	EM( MR_MEMORY_HOTPLUG,	"memory_hotplug")		\
20190f0b76SSteven Rostedt (Red Hat) 	EM( MR_SYSCALL,		"syscall_or_cpuset")		\
21190f0b76SSteven Rostedt (Red Hat) 	EM( MR_MEMPOLICY_MBIND,	"mempolicy_mbind")		\
22190f0b76SSteven Rostedt (Red Hat) 	EM( MR_NUMA_MISPLACED,	"numa_misplaced")		\
23d1e153feSPavel Tatashin 	EM( MR_CONTIG_RANGE,	"contig_range")			\
2426aa2d19SDave Hansen 	EM( MR_LONGTERM_PIN,	"longterm_pin")			\
2526aa2d19SDave Hansen 	EMe(MR_DEMOTION,	"demotion")
26190f0b76SSteven Rostedt (Red Hat) 
27190f0b76SSteven Rostedt (Red Hat) /*
28190f0b76SSteven Rostedt (Red Hat)  * First define the enums in the above macros to be exported to userspace
29190f0b76SSteven Rostedt (Red Hat)  * via TRACE_DEFINE_ENUM().
30190f0b76SSteven Rostedt (Red Hat)  */
31190f0b76SSteven Rostedt (Red Hat) #undef EM
32190f0b76SSteven Rostedt (Red Hat) #undef EMe
33190f0b76SSteven Rostedt (Red Hat) #define EM(a, b)	TRACE_DEFINE_ENUM(a);
34190f0b76SSteven Rostedt (Red Hat) #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
35190f0b76SSteven Rostedt (Red Hat) 
36190f0b76SSteven Rostedt (Red Hat) MIGRATE_MODE
37190f0b76SSteven Rostedt (Red Hat) MIGRATE_REASON
38190f0b76SSteven Rostedt (Red Hat) 
39190f0b76SSteven Rostedt (Red Hat) /*
40190f0b76SSteven Rostedt (Red Hat)  * Now redefine the EM() and EMe() macros to map the enums to the strings
41190f0b76SSteven Rostedt (Red Hat)  * that will be printed in the output.
42190f0b76SSteven Rostedt (Red Hat)  */
43190f0b76SSteven Rostedt (Red Hat) #undef EM
44190f0b76SSteven Rostedt (Red Hat) #undef EMe
45190f0b76SSteven Rostedt (Red Hat) #define EM(a, b)	{a, b},
46190f0b76SSteven Rostedt (Red Hat) #define EMe(a, b)	{a, b}
477b2a2d4aSMel Gorman 
487b2a2d4aSMel Gorman TRACE_EVENT(mm_migrate_pages,
497b2a2d4aSMel Gorman 
507b2a2d4aSMel Gorman 	TP_PROTO(unsigned long succeeded, unsigned long failed,
511a5bae25SAnshuman Khandual 		 unsigned long thp_succeeded, unsigned long thp_failed,
521a5bae25SAnshuman Khandual 		 unsigned long thp_split, enum migrate_mode mode, int reason),
537b2a2d4aSMel Gorman 
541a5bae25SAnshuman Khandual 	TP_ARGS(succeeded, failed, thp_succeeded, thp_failed,
551a5bae25SAnshuman Khandual 		thp_split, mode, reason),
567b2a2d4aSMel Gorman 
577b2a2d4aSMel Gorman 	TP_STRUCT__entry(
587b2a2d4aSMel Gorman 		__field(	unsigned long,		succeeded)
597b2a2d4aSMel Gorman 		__field(	unsigned long,		failed)
601a5bae25SAnshuman Khandual 		__field(	unsigned long,		thp_succeeded)
611a5bae25SAnshuman Khandual 		__field(	unsigned long,		thp_failed)
621a5bae25SAnshuman Khandual 		__field(	unsigned long,		thp_split)
637b2a2d4aSMel Gorman 		__field(	enum migrate_mode,	mode)
647b2a2d4aSMel Gorman 		__field(	int,			reason)
657b2a2d4aSMel Gorman 	),
667b2a2d4aSMel Gorman 
677b2a2d4aSMel Gorman 	TP_fast_assign(
687b2a2d4aSMel Gorman 		__entry->succeeded	= succeeded;
697b2a2d4aSMel Gorman 		__entry->failed		= failed;
701a5bae25SAnshuman Khandual 		__entry->thp_succeeded	= thp_succeeded;
711a5bae25SAnshuman Khandual 		__entry->thp_failed	= thp_failed;
721a5bae25SAnshuman Khandual 		__entry->thp_split	= thp_split;
737b2a2d4aSMel Gorman 		__entry->mode		= mode;
747b2a2d4aSMel Gorman 		__entry->reason		= reason;
757b2a2d4aSMel Gorman 	),
767b2a2d4aSMel Gorman 
771a5bae25SAnshuman Khandual 	TP_printk("nr_succeeded=%lu nr_failed=%lu nr_thp_succeeded=%lu nr_thp_failed=%lu nr_thp_split=%lu mode=%s reason=%s",
787b2a2d4aSMel Gorman 		__entry->succeeded,
797b2a2d4aSMel Gorman 		__entry->failed,
801a5bae25SAnshuman Khandual 		__entry->thp_succeeded,
811a5bae25SAnshuman Khandual 		__entry->thp_failed,
821a5bae25SAnshuman Khandual 		__entry->thp_split,
837b2a2d4aSMel Gorman 		__print_symbolic(__entry->mode, MIGRATE_MODE),
847b2a2d4aSMel Gorman 		__print_symbolic(__entry->reason, MIGRATE_REASON))
857b2a2d4aSMel Gorman );
867bc1aec5SLiam Mark 
877bc1aec5SLiam Mark TRACE_EVENT(mm_migrate_pages_start,
887bc1aec5SLiam Mark 
897bc1aec5SLiam Mark 	TP_PROTO(enum migrate_mode mode, int reason),
907bc1aec5SLiam Mark 
917bc1aec5SLiam Mark 	TP_ARGS(mode, reason),
927bc1aec5SLiam Mark 
937bc1aec5SLiam Mark 	TP_STRUCT__entry(
947bc1aec5SLiam Mark 		__field(enum migrate_mode, mode)
957bc1aec5SLiam Mark 		__field(int, reason)
967bc1aec5SLiam Mark 	),
977bc1aec5SLiam Mark 
987bc1aec5SLiam Mark 	TP_fast_assign(
997bc1aec5SLiam Mark 		__entry->mode	= mode;
1007bc1aec5SLiam Mark 		__entry->reason	= reason;
1017bc1aec5SLiam Mark 	),
1027bc1aec5SLiam Mark 
1037bc1aec5SLiam Mark 	TP_printk("mode=%s reason=%s",
1047bc1aec5SLiam Mark 		  __print_symbolic(__entry->mode, MIGRATE_MODE),
1057bc1aec5SLiam Mark 		  __print_symbolic(__entry->reason, MIGRATE_REASON))
1067bc1aec5SLiam Mark );
1077bc1aec5SLiam Mark 
108*4cc79b33SAnshuman Khandual DECLARE_EVENT_CLASS(migration_pte,
109*4cc79b33SAnshuman Khandual 
110*4cc79b33SAnshuman Khandual 		TP_PROTO(unsigned long addr, unsigned long pte, int order),
111*4cc79b33SAnshuman Khandual 
112*4cc79b33SAnshuman Khandual 		TP_ARGS(addr, pte, order),
113*4cc79b33SAnshuman Khandual 
114*4cc79b33SAnshuman Khandual 		TP_STRUCT__entry(
115*4cc79b33SAnshuman Khandual 			__field(unsigned long, addr)
116*4cc79b33SAnshuman Khandual 			__field(unsigned long, pte)
117*4cc79b33SAnshuman Khandual 			__field(int, order)
118*4cc79b33SAnshuman Khandual 		),
119*4cc79b33SAnshuman Khandual 
120*4cc79b33SAnshuman Khandual 		TP_fast_assign(
121*4cc79b33SAnshuman Khandual 			__entry->addr = addr;
122*4cc79b33SAnshuman Khandual 			__entry->pte = pte;
123*4cc79b33SAnshuman Khandual 			__entry->order = order;
124*4cc79b33SAnshuman Khandual 		),
125*4cc79b33SAnshuman Khandual 
126*4cc79b33SAnshuman Khandual 		TP_printk("addr=%lx, pte=%lx order=%d", __entry->addr, __entry->pte, __entry->order)
127*4cc79b33SAnshuman Khandual );
128*4cc79b33SAnshuman Khandual 
129*4cc79b33SAnshuman Khandual DEFINE_EVENT(migration_pte, set_migration_pte,
130*4cc79b33SAnshuman Khandual 	TP_PROTO(unsigned long addr, unsigned long pte, int order),
131*4cc79b33SAnshuman Khandual 	TP_ARGS(addr, pte, order)
132*4cc79b33SAnshuman Khandual );
133*4cc79b33SAnshuman Khandual 
134*4cc79b33SAnshuman Khandual DEFINE_EVENT(migration_pte, remove_migration_pte,
135*4cc79b33SAnshuman Khandual 	TP_PROTO(unsigned long addr, unsigned long pte, int order),
136*4cc79b33SAnshuman Khandual 	TP_ARGS(addr, pte, order)
137*4cc79b33SAnshuman Khandual );
138*4cc79b33SAnshuman Khandual 
1397b2a2d4aSMel Gorman #endif /* _TRACE_MIGRATE_H */
1407b2a2d4aSMel Gorman 
1417b2a2d4aSMel Gorman /* This part must be outside protection */
1427b2a2d4aSMel Gorman #include <trace/define_trace.h>
143