xref: /openbmc/linux/include/trace/events/writeback.h (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2455b2864SDave Chinner #undef TRACE_SYSTEM
3455b2864SDave Chinner #define TRACE_SYSTEM writeback
4455b2864SDave Chinner 
5455b2864SDave Chinner #if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
6455b2864SDave Chinner #define _TRACE_WRITEBACK_H
7455b2864SDave Chinner 
8f479447aSSteven Rostedt (Red Hat) #include <linux/tracepoint.h>
9455b2864SDave Chinner #include <linux/backing-dev.h>
10455b2864SDave Chinner #include <linux/writeback.h>
11455b2864SDave Chinner 
12251d6a47SWu Fengguang #define show_inode_state(state)					\
13251d6a47SWu Fengguang 	__print_flags(state, "|",				\
14251d6a47SWu Fengguang 		{I_DIRTY_SYNC,		"I_DIRTY_SYNC"},	\
15251d6a47SWu Fengguang 		{I_DIRTY_DATASYNC,	"I_DIRTY_DATASYNC"},	\
16251d6a47SWu Fengguang 		{I_DIRTY_PAGES,		"I_DIRTY_PAGES"},	\
17251d6a47SWu Fengguang 		{I_NEW,			"I_NEW"},		\
18251d6a47SWu Fengguang 		{I_WILL_FREE,		"I_WILL_FREE"},		\
19251d6a47SWu Fengguang 		{I_FREEING,		"I_FREEING"},		\
20251d6a47SWu Fengguang 		{I_CLEAR,		"I_CLEAR"},		\
21251d6a47SWu Fengguang 		{I_SYNC,		"I_SYNC"},		\
220ae45f63STheodore Ts'o 		{I_DIRTY_TIME,		"I_DIRTY_TIME"},	\
23251d6a47SWu Fengguang 		{I_REFERENCED,		"I_REFERENCED"}		\
24251d6a47SWu Fengguang 	)
25251d6a47SWu Fengguang 
2691df6089SSteven Rostedt (Red Hat) /* enums need to be exported to user space */
2791df6089SSteven Rostedt (Red Hat) #undef EM
2891df6089SSteven Rostedt (Red Hat) #undef EMe
2991df6089SSteven Rostedt (Red Hat) #define EM(a,b) 	TRACE_DEFINE_ENUM(a);
3091df6089SSteven Rostedt (Red Hat) #define EMe(a,b)	TRACE_DEFINE_ENUM(a);
3191df6089SSteven Rostedt (Red Hat) 
32b3bba872SWu Fengguang #define WB_WORK_REASON							\
3391df6089SSteven Rostedt (Red Hat) 	EM( WB_REASON_BACKGROUND,		"background")		\
34726d061fSJohannes Weiner 	EM( WB_REASON_VMSCAN,			"vmscan")		\
3591df6089SSteven Rostedt (Red Hat) 	EM( WB_REASON_SYNC,			"sync")			\
3691df6089SSteven Rostedt (Red Hat) 	EM( WB_REASON_PERIODIC,			"periodic")		\
3791df6089SSteven Rostedt (Red Hat) 	EM( WB_REASON_LAPTOP_TIMER,		"laptop_timer")		\
3891df6089SSteven Rostedt (Red Hat) 	EM( WB_REASON_FS_FREE_SPACE,		"fs_free_space")	\
393d3d9c07SChunguang Xu 	EM( WB_REASON_FORKER_THREAD,		"forker_thread")	\
403d3d9c07SChunguang Xu 	EMe(WB_REASON_FOREIGN_FLUSH,		"foreign_flush")
4191df6089SSteven Rostedt (Red Hat) 
4291df6089SSteven Rostedt (Red Hat) WB_WORK_REASON
4391df6089SSteven Rostedt (Red Hat) 
4491df6089SSteven Rostedt (Red Hat) /*
4591df6089SSteven Rostedt (Red Hat)  * Now redefine the EM() and EMe() macros to map the enums to the strings
4691df6089SSteven Rostedt (Red Hat)  * that will be printed in the output.
4791df6089SSteven Rostedt (Red Hat)  */
4891df6089SSteven Rostedt (Red Hat) #undef EM
4991df6089SSteven Rostedt (Red Hat) #undef EMe
5091df6089SSteven Rostedt (Red Hat) #define EM(a,b)		{ a, b },
5191df6089SSteven Rostedt (Red Hat) #define EMe(a,b)	{ a, b }
52b3bba872SWu Fengguang 
53455b2864SDave Chinner struct wb_writeback_work;
54455b2864SDave Chinner 
55b9b0ff61SMatthew Wilcox (Oracle) DECLARE_EVENT_CLASS(writeback_folio_template,
569fb0a7daSTejun Heo 
57b9b0ff61SMatthew Wilcox (Oracle) 	TP_PROTO(struct folio *folio, struct address_space *mapping),
589fb0a7daSTejun Heo 
59b9b0ff61SMatthew Wilcox (Oracle) 	TP_ARGS(folio, mapping),
609fb0a7daSTejun Heo 
619fb0a7daSTejun Heo 	TP_STRUCT__entry (
629fb0a7daSTejun Heo 		__array(char, name, 32)
63f05499a0STejun Heo 		__field(ino_t, ino)
649fb0a7daSTejun Heo 		__field(pgoff_t, index)
659fb0a7daSTejun Heo 	),
669fb0a7daSTejun Heo 
679fb0a7daSTejun Heo 	TP_fast_assign(
68d1a445d3SQian Cai 		strscpy_pad(__entry->name,
6968f23b89STheodore Ts'o 			    bdi_dev_name(mapping ? inode_to_bdi(mapping->host) :
7068f23b89STheodore Ts'o 					 NULL), 32);
71*54abe19eSRafael Aquini 		__entry->ino = (mapping && mapping->host) ? mapping->host->i_ino : 0;
72b9b0ff61SMatthew Wilcox (Oracle) 		__entry->index = folio->index;
739fb0a7daSTejun Heo 	),
749fb0a7daSTejun Heo 
759fb0a7daSTejun Heo 	TP_printk("bdi %s: ino=%lu index=%lu",
769fb0a7daSTejun Heo 		__entry->name,
7740363cf1SQian Cai 		(unsigned long)__entry->ino,
789fb0a7daSTejun Heo 		__entry->index
799fb0a7daSTejun Heo 	)
809fb0a7daSTejun Heo );
819fb0a7daSTejun Heo 
82b9b0ff61SMatthew Wilcox (Oracle) DEFINE_EVENT(writeback_folio_template, writeback_dirty_folio,
8319343b5bSYafang Shao 
84b9b0ff61SMatthew Wilcox (Oracle) 	TP_PROTO(struct folio *folio, struct address_space *mapping),
8519343b5bSYafang Shao 
86b9b0ff61SMatthew Wilcox (Oracle) 	TP_ARGS(folio, mapping)
8719343b5bSYafang Shao );
8819343b5bSYafang Shao 
89b9b0ff61SMatthew Wilcox (Oracle) DEFINE_EVENT(writeback_folio_template, folio_wait_writeback,
9019343b5bSYafang Shao 
91b9b0ff61SMatthew Wilcox (Oracle) 	TP_PROTO(struct folio *folio, struct address_space *mapping),
9219343b5bSYafang Shao 
93b9b0ff61SMatthew Wilcox (Oracle) 	TP_ARGS(folio, mapping)
9419343b5bSYafang Shao );
9519343b5bSYafang Shao 
969fb0a7daSTejun Heo DECLARE_EVENT_CLASS(writeback_dirty_inode_template,
979fb0a7daSTejun Heo 
989fb0a7daSTejun Heo 	TP_PROTO(struct inode *inode, int flags),
999fb0a7daSTejun Heo 
1009fb0a7daSTejun Heo 	TP_ARGS(inode, flags),
1019fb0a7daSTejun Heo 
1029fb0a7daSTejun Heo 	TP_STRUCT__entry (
1039fb0a7daSTejun Heo 		__array(char, name, 32)
104f05499a0STejun Heo 		__field(ino_t, ino)
1050ae45f63STheodore Ts'o 		__field(unsigned long, state)
1069fb0a7daSTejun Heo 		__field(unsigned long, flags)
1079fb0a7daSTejun Heo 	),
1089fb0a7daSTejun Heo 
1099fb0a7daSTejun Heo 	TP_fast_assign(
110de1414a6SChristoph Hellwig 		struct backing_dev_info *bdi = inode_to_bdi(inode);
1119fb0a7daSTejun Heo 
1129fb0a7daSTejun Heo 		/* may be called for files on pseudo FSes w/ unregistered bdi */
11368f23b89STheodore Ts'o 		strscpy_pad(__entry->name, bdi_dev_name(bdi), 32);
1149fb0a7daSTejun Heo 		__entry->ino		= inode->i_ino;
1150ae45f63STheodore Ts'o 		__entry->state		= inode->i_state;
1169fb0a7daSTejun Heo 		__entry->flags		= flags;
1179fb0a7daSTejun Heo 	),
1189fb0a7daSTejun Heo 
1190ae45f63STheodore Ts'o 	TP_printk("bdi %s: ino=%lu state=%s flags=%s",
1209fb0a7daSTejun Heo 		__entry->name,
12140363cf1SQian Cai 		(unsigned long)__entry->ino,
1220ae45f63STheodore Ts'o 		show_inode_state(__entry->state),
1239fb0a7daSTejun Heo 		show_inode_state(__entry->flags)
1249fb0a7daSTejun Heo 	)
1259fb0a7daSTejun Heo );
1269fb0a7daSTejun Heo 
1270ae45f63STheodore Ts'o DEFINE_EVENT(writeback_dirty_inode_template, writeback_mark_inode_dirty,
1280ae45f63STheodore Ts'o 
1290ae45f63STheodore Ts'o 	TP_PROTO(struct inode *inode, int flags),
1300ae45f63STheodore Ts'o 
1310ae45f63STheodore Ts'o 	TP_ARGS(inode, flags)
1320ae45f63STheodore Ts'o );
1330ae45f63STheodore Ts'o 
1349fb0a7daSTejun Heo DEFINE_EVENT(writeback_dirty_inode_template, writeback_dirty_inode_start,
1359fb0a7daSTejun Heo 
1369fb0a7daSTejun Heo 	TP_PROTO(struct inode *inode, int flags),
1379fb0a7daSTejun Heo 
1389fb0a7daSTejun Heo 	TP_ARGS(inode, flags)
1399fb0a7daSTejun Heo );
1409fb0a7daSTejun Heo 
1419fb0a7daSTejun Heo DEFINE_EVENT(writeback_dirty_inode_template, writeback_dirty_inode,
1429fb0a7daSTejun Heo 
1439fb0a7daSTejun Heo 	TP_PROTO(struct inode *inode, int flags),
1449fb0a7daSTejun Heo 
1459fb0a7daSTejun Heo 	TP_ARGS(inode, flags)
1469fb0a7daSTejun Heo );
1479fb0a7daSTejun Heo 
1485634cc2aSTejun Heo #ifdef CREATE_TRACE_POINTS
1495634cc2aSTejun Heo #ifdef CONFIG_CGROUP_WRITEBACK
1505634cc2aSTejun Heo 
__trace_wb_assign_cgroup(struct bdi_writeback * wb)151f05499a0STejun Heo static inline ino_t __trace_wb_assign_cgroup(struct bdi_writeback *wb)
1525634cc2aSTejun Heo {
15367c0496eSTejun Heo 	return cgroup_ino(wb->memcg_css->cgroup);
1545634cc2aSTejun Heo }
1555634cc2aSTejun Heo 
__trace_wbc_assign_cgroup(struct writeback_control * wbc)156f05499a0STejun Heo static inline ino_t __trace_wbc_assign_cgroup(struct writeback_control *wbc)
1575634cc2aSTejun Heo {
1585634cc2aSTejun Heo 	if (wbc->wb)
159a664edb3SYang Shi 		return __trace_wb_assign_cgroup(wbc->wb);
1605634cc2aSTejun Heo 	else
161f05499a0STejun Heo 		return 1;
1625634cc2aSTejun Heo }
1635634cc2aSTejun Heo #else	/* CONFIG_CGROUP_WRITEBACK */
1645634cc2aSTejun Heo 
__trace_wb_assign_cgroup(struct bdi_writeback * wb)165f05499a0STejun Heo static inline ino_t __trace_wb_assign_cgroup(struct bdi_writeback *wb)
1665634cc2aSTejun Heo {
167f05499a0STejun Heo 	return 1;
1685634cc2aSTejun Heo }
1695634cc2aSTejun Heo 
__trace_wbc_assign_cgroup(struct writeback_control * wbc)170f05499a0STejun Heo static inline ino_t __trace_wbc_assign_cgroup(struct writeback_control *wbc)
1715634cc2aSTejun Heo {
172f05499a0STejun Heo 	return 1;
1735634cc2aSTejun Heo }
1745634cc2aSTejun Heo 
1755634cc2aSTejun Heo #endif	/* CONFIG_CGROUP_WRITEBACK */
1765634cc2aSTejun Heo #endif	/* CREATE_TRACE_POINTS */
1775634cc2aSTejun Heo 
1783a8e9ac8STejun Heo #ifdef CONFIG_CGROUP_WRITEBACK
1793a8e9ac8STejun Heo TRACE_EVENT(inode_foreign_history,
1803a8e9ac8STejun Heo 
1813a8e9ac8STejun Heo 	TP_PROTO(struct inode *inode, struct writeback_control *wbc,
1823a8e9ac8STejun Heo 		 unsigned int history),
1833a8e9ac8STejun Heo 
1843a8e9ac8STejun Heo 	TP_ARGS(inode, wbc, history),
1853a8e9ac8STejun Heo 
1863a8e9ac8STejun Heo 	TP_STRUCT__entry(
1873a8e9ac8STejun Heo 		__array(char,		name, 32)
188f05499a0STejun Heo 		__field(ino_t,		ino)
189f05499a0STejun Heo 		__field(ino_t,		cgroup_ino)
1903a8e9ac8STejun Heo 		__field(unsigned int,	history)
1913a8e9ac8STejun Heo 	),
1923a8e9ac8STejun Heo 
1933a8e9ac8STejun Heo 	TP_fast_assign(
194fdeb17c7SHui Su 		strscpy_pad(__entry->name, bdi_dev_name(inode_to_bdi(inode)), 32);
1953a8e9ac8STejun Heo 		__entry->ino		= inode->i_ino;
1963a8e9ac8STejun Heo 		__entry->cgroup_ino	= __trace_wbc_assign_cgroup(wbc);
1973a8e9ac8STejun Heo 		__entry->history	= history;
1983a8e9ac8STejun Heo 	),
1993a8e9ac8STejun Heo 
200f05499a0STejun Heo 	TP_printk("bdi %s: ino=%lu cgroup_ino=%lu history=0x%x",
2013a8e9ac8STejun Heo 		__entry->name,
20240363cf1SQian Cai 		(unsigned long)__entry->ino,
20340363cf1SQian Cai 		(unsigned long)__entry->cgroup_ino,
2043a8e9ac8STejun Heo 		__entry->history
2053a8e9ac8STejun Heo 	)
2063a8e9ac8STejun Heo );
2073a8e9ac8STejun Heo 
2083a8e9ac8STejun Heo TRACE_EVENT(inode_switch_wbs,
2093a8e9ac8STejun Heo 
2103a8e9ac8STejun Heo 	TP_PROTO(struct inode *inode, struct bdi_writeback *old_wb,
2113a8e9ac8STejun Heo 		 struct bdi_writeback *new_wb),
2123a8e9ac8STejun Heo 
2133a8e9ac8STejun Heo 	TP_ARGS(inode, old_wb, new_wb),
2143a8e9ac8STejun Heo 
2153a8e9ac8STejun Heo 	TP_STRUCT__entry(
2163a8e9ac8STejun Heo 		__array(char,		name, 32)
217f05499a0STejun Heo 		__field(ino_t,		ino)
218f05499a0STejun Heo 		__field(ino_t,		old_cgroup_ino)
219f05499a0STejun Heo 		__field(ino_t,		new_cgroup_ino)
2203a8e9ac8STejun Heo 	),
2213a8e9ac8STejun Heo 
2223a8e9ac8STejun Heo 	TP_fast_assign(
223fdeb17c7SHui Su 		strscpy_pad(__entry->name, bdi_dev_name(old_wb->bdi), 32);
2243a8e9ac8STejun Heo 		__entry->ino		= inode->i_ino;
2253a8e9ac8STejun Heo 		__entry->old_cgroup_ino	= __trace_wb_assign_cgroup(old_wb);
2263a8e9ac8STejun Heo 		__entry->new_cgroup_ino	= __trace_wb_assign_cgroup(new_wb);
2273a8e9ac8STejun Heo 	),
2283a8e9ac8STejun Heo 
229f05499a0STejun Heo 	TP_printk("bdi %s: ino=%lu old_cgroup_ino=%lu new_cgroup_ino=%lu",
2303a8e9ac8STejun Heo 		__entry->name,
23140363cf1SQian Cai 		(unsigned long)__entry->ino,
23240363cf1SQian Cai 		(unsigned long)__entry->old_cgroup_ino,
23340363cf1SQian Cai 		(unsigned long)__entry->new_cgroup_ino
2343a8e9ac8STejun Heo 	)
2353a8e9ac8STejun Heo );
2363a8e9ac8STejun Heo 
2373a8e9ac8STejun Heo TRACE_EVENT(track_foreign_dirty,
2383a8e9ac8STejun Heo 
2399d8053fcSMatthew Wilcox (Oracle) 	TP_PROTO(struct folio *folio, struct bdi_writeback *wb),
2403a8e9ac8STejun Heo 
2419d8053fcSMatthew Wilcox (Oracle) 	TP_ARGS(folio, wb),
2423a8e9ac8STejun Heo 
2433a8e9ac8STejun Heo 	TP_STRUCT__entry(
2443a8e9ac8STejun Heo 		__array(char,		name, 32)
2453a8e9ac8STejun Heo 		__field(u64,		bdi_id)
246f05499a0STejun Heo 		__field(ino_t,		ino)
2473a8e9ac8STejun Heo 		__field(unsigned int,	memcg_id)
248f05499a0STejun Heo 		__field(ino_t,		cgroup_ino)
249f05499a0STejun Heo 		__field(ino_t,		page_cgroup_ino)
2503a8e9ac8STejun Heo 	),
2513a8e9ac8STejun Heo 
2523a8e9ac8STejun Heo 	TP_fast_assign(
2539d8053fcSMatthew Wilcox (Oracle) 		struct address_space *mapping = folio_mapping(folio);
2540feacaa2STejun Heo 		struct inode *inode = mapping ? mapping->host : NULL;
2550feacaa2STejun Heo 
256fdeb17c7SHui Su 		strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32);
2573a8e9ac8STejun Heo 		__entry->bdi_id		= wb->bdi->id;
2580feacaa2STejun Heo 		__entry->ino		= inode ? inode->i_ino : 0;
2593a8e9ac8STejun Heo 		__entry->memcg_id	= wb->memcg_css->id;
2603a8e9ac8STejun Heo 		__entry->cgroup_ino	= __trace_wb_assign_cgroup(wb);
2619d8053fcSMatthew Wilcox (Oracle) 		__entry->page_cgroup_ino = cgroup_ino(folio_memcg(folio)->css.cgroup);
2623a8e9ac8STejun Heo 	),
2633a8e9ac8STejun Heo 
264f05499a0STejun Heo 	TP_printk("bdi %s[%llu]: ino=%lu memcg_id=%u cgroup_ino=%lu page_cgroup_ino=%lu",
2653a8e9ac8STejun Heo 		__entry->name,
2663a8e9ac8STejun Heo 		__entry->bdi_id,
26740363cf1SQian Cai 		(unsigned long)__entry->ino,
2683a8e9ac8STejun Heo 		__entry->memcg_id,
26940363cf1SQian Cai 		(unsigned long)__entry->cgroup_ino,
27040363cf1SQian Cai 		(unsigned long)__entry->page_cgroup_ino
2713a8e9ac8STejun Heo 	)
2723a8e9ac8STejun Heo );
2733a8e9ac8STejun Heo 
2743a8e9ac8STejun Heo TRACE_EVENT(flush_foreign,
2753a8e9ac8STejun Heo 
2763a8e9ac8STejun Heo 	TP_PROTO(struct bdi_writeback *wb, unsigned int frn_bdi_id,
2773a8e9ac8STejun Heo 		 unsigned int frn_memcg_id),
2783a8e9ac8STejun Heo 
2793a8e9ac8STejun Heo 	TP_ARGS(wb, frn_bdi_id, frn_memcg_id),
2803a8e9ac8STejun Heo 
2813a8e9ac8STejun Heo 	TP_STRUCT__entry(
2823a8e9ac8STejun Heo 		__array(char,		name, 32)
283f05499a0STejun Heo 		__field(ino_t,		cgroup_ino)
2843a8e9ac8STejun Heo 		__field(unsigned int,	frn_bdi_id)
2853a8e9ac8STejun Heo 		__field(unsigned int,	frn_memcg_id)
2863a8e9ac8STejun Heo 	),
2873a8e9ac8STejun Heo 
2883a8e9ac8STejun Heo 	TP_fast_assign(
289fdeb17c7SHui Su 		strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32);
2903a8e9ac8STejun Heo 		__entry->cgroup_ino	= __trace_wb_assign_cgroup(wb);
2913a8e9ac8STejun Heo 		__entry->frn_bdi_id	= frn_bdi_id;
2923a8e9ac8STejun Heo 		__entry->frn_memcg_id	= frn_memcg_id;
2933a8e9ac8STejun Heo 	),
2943a8e9ac8STejun Heo 
295f05499a0STejun Heo 	TP_printk("bdi %s: cgroup_ino=%lu frn_bdi_id=%u frn_memcg_id=%u",
2963a8e9ac8STejun Heo 		__entry->name,
29740363cf1SQian Cai 		(unsigned long)__entry->cgroup_ino,
2983a8e9ac8STejun Heo 		__entry->frn_bdi_id,
2993a8e9ac8STejun Heo 		__entry->frn_memcg_id
3003a8e9ac8STejun Heo 	)
3013a8e9ac8STejun Heo );
3023a8e9ac8STejun Heo #endif
3033a8e9ac8STejun Heo 
3049fb0a7daSTejun Heo DECLARE_EVENT_CLASS(writeback_write_inode_template,
3059fb0a7daSTejun Heo 
3069fb0a7daSTejun Heo 	TP_PROTO(struct inode *inode, struct writeback_control *wbc),
3079fb0a7daSTejun Heo 
3089fb0a7daSTejun Heo 	TP_ARGS(inode, wbc),
3099fb0a7daSTejun Heo 
3109fb0a7daSTejun Heo 	TP_STRUCT__entry (
3119fb0a7daSTejun Heo 		__array(char, name, 32)
312f05499a0STejun Heo 		__field(ino_t, ino)
3139fb0a7daSTejun Heo 		__field(int, sync_mode)
314f05499a0STejun Heo 		__field(ino_t, cgroup_ino)
3159fb0a7daSTejun Heo 	),
3169fb0a7daSTejun Heo 
3179fb0a7daSTejun Heo 	TP_fast_assign(
318d1a445d3SQian Cai 		strscpy_pad(__entry->name,
31968f23b89STheodore Ts'o 			    bdi_dev_name(inode_to_bdi(inode)), 32);
3209fb0a7daSTejun Heo 		__entry->ino		= inode->i_ino;
3219fb0a7daSTejun Heo 		__entry->sync_mode	= wbc->sync_mode;
322a664edb3SYang Shi 		__entry->cgroup_ino	= __trace_wbc_assign_cgroup(wbc);
3239fb0a7daSTejun Heo 	),
3249fb0a7daSTejun Heo 
325f05499a0STejun Heo 	TP_printk("bdi %s: ino=%lu sync_mode=%d cgroup_ino=%lu",
3269fb0a7daSTejun Heo 		__entry->name,
32740363cf1SQian Cai 		(unsigned long)__entry->ino,
3285634cc2aSTejun Heo 		__entry->sync_mode,
32940363cf1SQian Cai 		(unsigned long)__entry->cgroup_ino
3309fb0a7daSTejun Heo 	)
3319fb0a7daSTejun Heo );
3329fb0a7daSTejun Heo 
3339fb0a7daSTejun Heo DEFINE_EVENT(writeback_write_inode_template, writeback_write_inode_start,
3349fb0a7daSTejun Heo 
3359fb0a7daSTejun Heo 	TP_PROTO(struct inode *inode, struct writeback_control *wbc),
3369fb0a7daSTejun Heo 
3379fb0a7daSTejun Heo 	TP_ARGS(inode, wbc)
3389fb0a7daSTejun Heo );
3399fb0a7daSTejun Heo 
3409fb0a7daSTejun Heo DEFINE_EVENT(writeback_write_inode_template, writeback_write_inode,
3419fb0a7daSTejun Heo 
3429fb0a7daSTejun Heo 	TP_PROTO(struct inode *inode, struct writeback_control *wbc),
3439fb0a7daSTejun Heo 
3449fb0a7daSTejun Heo 	TP_ARGS(inode, wbc)
3459fb0a7daSTejun Heo );
3469fb0a7daSTejun Heo 
347455b2864SDave Chinner DECLARE_EVENT_CLASS(writeback_work_class,
3485634cc2aSTejun Heo 	TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work),
3495634cc2aSTejun Heo 	TP_ARGS(wb, work),
350455b2864SDave Chinner 	TP_STRUCT__entry(
351455b2864SDave Chinner 		__array(char, name, 32)
352455b2864SDave Chinner 		__field(long, nr_pages)
353455b2864SDave Chinner 		__field(dev_t, sb_dev)
354455b2864SDave Chinner 		__field(int, sync_mode)
355455b2864SDave Chinner 		__field(int, for_kupdate)
356455b2864SDave Chinner 		__field(int, range_cyclic)
357455b2864SDave Chinner 		__field(int, for_background)
3580e175a18SCurt Wohlgemuth 		__field(int, reason)
359f05499a0STejun Heo 		__field(ino_t, cgroup_ino)
360455b2864SDave Chinner 	),
361455b2864SDave Chinner 	TP_fast_assign(
36268f23b89STheodore Ts'o 		strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32);
363455b2864SDave Chinner 		__entry->nr_pages = work->nr_pages;
364455b2864SDave Chinner 		__entry->sb_dev = work->sb ? work->sb->s_dev : 0;
365455b2864SDave Chinner 		__entry->sync_mode = work->sync_mode;
366455b2864SDave Chinner 		__entry->for_kupdate = work->for_kupdate;
367455b2864SDave Chinner 		__entry->range_cyclic = work->range_cyclic;
368455b2864SDave Chinner 		__entry->for_background	= work->for_background;
3690e175a18SCurt Wohlgemuth 		__entry->reason = work->reason;
370a664edb3SYang Shi 		__entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
371455b2864SDave Chinner 	),
372455b2864SDave Chinner 	TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
373f05499a0STejun Heo 		  "kupdate=%d range_cyclic=%d background=%d reason=%s cgroup_ino=%lu",
374455b2864SDave Chinner 		  __entry->name,
375455b2864SDave Chinner 		  MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
376455b2864SDave Chinner 		  __entry->nr_pages,
377455b2864SDave Chinner 		  __entry->sync_mode,
378455b2864SDave Chinner 		  __entry->for_kupdate,
379455b2864SDave Chinner 		  __entry->range_cyclic,
3800e175a18SCurt Wohlgemuth 		  __entry->for_background,
3815634cc2aSTejun Heo 		  __print_symbolic(__entry->reason, WB_WORK_REASON),
38240363cf1SQian Cai 		  (unsigned long)__entry->cgroup_ino
383455b2864SDave Chinner 	)
384455b2864SDave Chinner );
385455b2864SDave Chinner #define DEFINE_WRITEBACK_WORK_EVENT(name) \
386455b2864SDave Chinner DEFINE_EVENT(writeback_work_class, name, \
3875634cc2aSTejun Heo 	TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work), \
3885634cc2aSTejun Heo 	TP_ARGS(wb, work))
389455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
390455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
391d46db3d5SWu Fengguang DEFINE_WRITEBACK_WORK_EVENT(writeback_start);
392d46db3d5SWu Fengguang DEFINE_WRITEBACK_WORK_EVENT(writeback_written);
393d46db3d5SWu Fengguang DEFINE_WRITEBACK_WORK_EVENT(writeback_wait);
394455b2864SDave Chinner 
395455b2864SDave Chinner TRACE_EVENT(writeback_pages_written,
396455b2864SDave Chinner 	TP_PROTO(long pages_written),
397455b2864SDave Chinner 	TP_ARGS(pages_written),
398455b2864SDave Chinner 	TP_STRUCT__entry(
399455b2864SDave Chinner 		__field(long,		pages)
400455b2864SDave Chinner 	),
401455b2864SDave Chinner 	TP_fast_assign(
402455b2864SDave Chinner 		__entry->pages		= pages_written;
403455b2864SDave Chinner 	),
404455b2864SDave Chinner 	TP_printk("%ld", __entry->pages)
405455b2864SDave Chinner );
406455b2864SDave Chinner 
407455b2864SDave Chinner DECLARE_EVENT_CLASS(writeback_class,
4085634cc2aSTejun Heo 	TP_PROTO(struct bdi_writeback *wb),
4095634cc2aSTejun Heo 	TP_ARGS(wb),
4105634cc2aSTejun Heo 	TP_STRUCT__entry(
4115634cc2aSTejun Heo 		__array(char, name, 32)
412f05499a0STejun Heo 		__field(ino_t, cgroup_ino)
4135634cc2aSTejun Heo 	),
4145634cc2aSTejun Heo 	TP_fast_assign(
41568f23b89STheodore Ts'o 		strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32);
416a664edb3SYang Shi 		__entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
4175634cc2aSTejun Heo 	),
418f05499a0STejun Heo 	TP_printk("bdi %s: cgroup_ino=%lu",
4195634cc2aSTejun Heo 		  __entry->name,
42040363cf1SQian Cai 		  (unsigned long)__entry->cgroup_ino
4215634cc2aSTejun Heo 	)
4225634cc2aSTejun Heo );
4235634cc2aSTejun Heo #define DEFINE_WRITEBACK_EVENT(name) \
4245634cc2aSTejun Heo DEFINE_EVENT(writeback_class, name, \
4255634cc2aSTejun Heo 	TP_PROTO(struct bdi_writeback *wb), \
4265634cc2aSTejun Heo 	TP_ARGS(wb))
4275634cc2aSTejun Heo 
4285634cc2aSTejun Heo DEFINE_WRITEBACK_EVENT(writeback_wake_background);
4295634cc2aSTejun Heo 
4305634cc2aSTejun Heo TRACE_EVENT(writeback_bdi_register,
431455b2864SDave Chinner 	TP_PROTO(struct backing_dev_info *bdi),
432455b2864SDave Chinner 	TP_ARGS(bdi),
433455b2864SDave Chinner 	TP_STRUCT__entry(
434455b2864SDave Chinner 		__array(char, name, 32)
435455b2864SDave Chinner 	),
436455b2864SDave Chinner 	TP_fast_assign(
43768f23b89STheodore Ts'o 		strscpy_pad(__entry->name, bdi_dev_name(bdi), 32);
438455b2864SDave Chinner 	),
439455b2864SDave Chinner 	TP_printk("bdi %s",
440455b2864SDave Chinner 		__entry->name
441455b2864SDave Chinner 	)
442455b2864SDave Chinner );
443455b2864SDave Chinner 
444028c2dd1SDave Chinner DECLARE_EVENT_CLASS(wbc_class,
445028c2dd1SDave Chinner 	TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
446028c2dd1SDave Chinner 	TP_ARGS(wbc, bdi),
447028c2dd1SDave Chinner 	TP_STRUCT__entry(
448028c2dd1SDave Chinner 		__array(char, name, 32)
449028c2dd1SDave Chinner 		__field(long, nr_to_write)
450028c2dd1SDave Chinner 		__field(long, pages_skipped)
451028c2dd1SDave Chinner 		__field(int, sync_mode)
452028c2dd1SDave Chinner 		__field(int, for_kupdate)
453028c2dd1SDave Chinner 		__field(int, for_background)
454028c2dd1SDave Chinner 		__field(int, for_reclaim)
455028c2dd1SDave Chinner 		__field(int, range_cyclic)
456028c2dd1SDave Chinner 		__field(long, range_start)
457028c2dd1SDave Chinner 		__field(long, range_end)
458f05499a0STejun Heo 		__field(ino_t, cgroup_ino)
459028c2dd1SDave Chinner 	),
460028c2dd1SDave Chinner 
461028c2dd1SDave Chinner 	TP_fast_assign(
46268f23b89STheodore Ts'o 		strscpy_pad(__entry->name, bdi_dev_name(bdi), 32);
463028c2dd1SDave Chinner 		__entry->nr_to_write	= wbc->nr_to_write;
464028c2dd1SDave Chinner 		__entry->pages_skipped	= wbc->pages_skipped;
465028c2dd1SDave Chinner 		__entry->sync_mode	= wbc->sync_mode;
466028c2dd1SDave Chinner 		__entry->for_kupdate	= wbc->for_kupdate;
467028c2dd1SDave Chinner 		__entry->for_background	= wbc->for_background;
468028c2dd1SDave Chinner 		__entry->for_reclaim	= wbc->for_reclaim;
469028c2dd1SDave Chinner 		__entry->range_cyclic	= wbc->range_cyclic;
470028c2dd1SDave Chinner 		__entry->range_start	= (long)wbc->range_start;
471028c2dd1SDave Chinner 		__entry->range_end	= (long)wbc->range_end;
472a664edb3SYang Shi 		__entry->cgroup_ino	= __trace_wbc_assign_cgroup(wbc);
473028c2dd1SDave Chinner 	),
474028c2dd1SDave Chinner 
475028c2dd1SDave Chinner 	TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
476d46db3d5SWu Fengguang 		"bgrd=%d reclm=%d cyclic=%d "
477f05499a0STejun Heo 		"start=0x%lx end=0x%lx cgroup_ino=%lu",
478028c2dd1SDave Chinner 		__entry->name,
479028c2dd1SDave Chinner 		__entry->nr_to_write,
480028c2dd1SDave Chinner 		__entry->pages_skipped,
481028c2dd1SDave Chinner 		__entry->sync_mode,
482028c2dd1SDave Chinner 		__entry->for_kupdate,
483028c2dd1SDave Chinner 		__entry->for_background,
484028c2dd1SDave Chinner 		__entry->for_reclaim,
485028c2dd1SDave Chinner 		__entry->range_cyclic,
486028c2dd1SDave Chinner 		__entry->range_start,
4875634cc2aSTejun Heo 		__entry->range_end,
48840363cf1SQian Cai 		(unsigned long)__entry->cgroup_ino
4895634cc2aSTejun Heo 	)
490028c2dd1SDave Chinner )
491028c2dd1SDave Chinner 
492028c2dd1SDave Chinner #define DEFINE_WBC_EVENT(name) \
493028c2dd1SDave Chinner DEFINE_EVENT(wbc_class, name, \
494028c2dd1SDave Chinner 	TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
495028c2dd1SDave Chinner 	TP_ARGS(wbc, bdi))
4969e094383SDave Chinner DEFINE_WBC_EVENT(wbc_writepage);
497028c2dd1SDave Chinner 
498e84d0a4fSWu Fengguang TRACE_EVENT(writeback_queue_io,
499e84d0a4fSWu Fengguang 	TP_PROTO(struct bdi_writeback *wb,
500ad4e38ddSCurt Wohlgemuth 		 struct wb_writeback_work *work,
501f9cae926SJan Kara 		 unsigned long dirtied_before,
502e84d0a4fSWu Fengguang 		 int moved),
503f9cae926SJan Kara 	TP_ARGS(wb, work, dirtied_before, moved),
504e84d0a4fSWu Fengguang 	TP_STRUCT__entry(
505e84d0a4fSWu Fengguang 		__array(char,		name, 32)
506e84d0a4fSWu Fengguang 		__field(unsigned long,	older)
507e84d0a4fSWu Fengguang 		__field(long,		age)
508e84d0a4fSWu Fengguang 		__field(int,		moved)
5090e175a18SCurt Wohlgemuth 		__field(int,		reason)
510f05499a0STejun Heo 		__field(ino_t,		cgroup_ino)
511e84d0a4fSWu Fengguang 	),
512e84d0a4fSWu Fengguang 	TP_fast_assign(
51368f23b89STheodore Ts'o 		strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32);
514f9cae926SJan Kara 		__entry->older	= dirtied_before;
515f9cae926SJan Kara 		__entry->age	= (jiffies - dirtied_before) * 1000 / HZ;
516e84d0a4fSWu Fengguang 		__entry->moved	= moved;
5170e175a18SCurt Wohlgemuth 		__entry->reason	= work->reason;
518a664edb3SYang Shi 		__entry->cgroup_ino	= __trace_wb_assign_cgroup(wb);
519e84d0a4fSWu Fengguang 	),
520f05499a0STejun Heo 	TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup_ino=%lu",
521e84d0a4fSWu Fengguang 		__entry->name,
522f9cae926SJan Kara 		__entry->older,	/* dirtied_before in jiffies */
523f9cae926SJan Kara 		__entry->age,	/* dirtied_before in relative milliseconds */
5240e175a18SCurt Wohlgemuth 		__entry->moved,
5255634cc2aSTejun Heo 		__print_symbolic(__entry->reason, WB_WORK_REASON),
52640363cf1SQian Cai 		(unsigned long)__entry->cgroup_ino
527b3bba872SWu Fengguang 	)
528e84d0a4fSWu Fengguang );
529e84d0a4fSWu Fengguang 
530e1cbe236SWu Fengguang TRACE_EVENT(global_dirty_state,
531e1cbe236SWu Fengguang 
532e1cbe236SWu Fengguang 	TP_PROTO(unsigned long background_thresh,
533e1cbe236SWu Fengguang 		 unsigned long dirty_thresh
534e1cbe236SWu Fengguang 	),
535e1cbe236SWu Fengguang 
536e1cbe236SWu Fengguang 	TP_ARGS(background_thresh,
537e1cbe236SWu Fengguang 		dirty_thresh
538e1cbe236SWu Fengguang 	),
539e1cbe236SWu Fengguang 
540e1cbe236SWu Fengguang 	TP_STRUCT__entry(
541e1cbe236SWu Fengguang 		__field(unsigned long,	nr_dirty)
542e1cbe236SWu Fengguang 		__field(unsigned long,	nr_writeback)
543e1cbe236SWu Fengguang 		__field(unsigned long,	background_thresh)
544e1cbe236SWu Fengguang 		__field(unsigned long,	dirty_thresh)
545e1cbe236SWu Fengguang 		__field(unsigned long,	dirty_limit)
546e1cbe236SWu Fengguang 		__field(unsigned long,	nr_dirtied)
547e1cbe236SWu Fengguang 		__field(unsigned long,	nr_written)
548e1cbe236SWu Fengguang 	),
549e1cbe236SWu Fengguang 
550e1cbe236SWu Fengguang 	TP_fast_assign(
55111fb9989SMel Gorman 		__entry->nr_dirty	= global_node_page_state(NR_FILE_DIRTY);
55211fb9989SMel Gorman 		__entry->nr_writeback	= global_node_page_state(NR_WRITEBACK);
553c4a25635SMel Gorman 		__entry->nr_dirtied	= global_node_page_state(NR_DIRTIED);
554c4a25635SMel Gorman 		__entry->nr_written	= global_node_page_state(NR_WRITTEN);
555e1cbe236SWu Fengguang 		__entry->background_thresh = background_thresh;
556e1cbe236SWu Fengguang 		__entry->dirty_thresh	= dirty_thresh;
557dcc25ae7STejun Heo 		__entry->dirty_limit	= global_wb_domain.dirty_limit;
558e1cbe236SWu Fengguang 	),
559e1cbe236SWu Fengguang 
5608d92890bSNeilBrown 	TP_printk("dirty=%lu writeback=%lu "
561e1cbe236SWu Fengguang 		  "bg_thresh=%lu thresh=%lu limit=%lu "
562e1cbe236SWu Fengguang 		  "dirtied=%lu written=%lu",
563e1cbe236SWu Fengguang 		  __entry->nr_dirty,
564e1cbe236SWu Fengguang 		  __entry->nr_writeback,
565e1cbe236SWu Fengguang 		  __entry->background_thresh,
566e1cbe236SWu Fengguang 		  __entry->dirty_thresh,
567e1cbe236SWu Fengguang 		  __entry->dirty_limit,
568e1cbe236SWu Fengguang 		  __entry->nr_dirtied,
569e1cbe236SWu Fengguang 		  __entry->nr_written
570e1cbe236SWu Fengguang 	)
571e1cbe236SWu Fengguang );
572e1cbe236SWu Fengguang 
573b48c104dSWu Fengguang #define KBps(x)			((x) << (PAGE_SHIFT - 10))
574b48c104dSWu Fengguang 
575b48c104dSWu Fengguang TRACE_EVENT(bdi_dirty_ratelimit,
576b48c104dSWu Fengguang 
5775634cc2aSTejun Heo 	TP_PROTO(struct bdi_writeback *wb,
578b48c104dSWu Fengguang 		 unsigned long dirty_rate,
579b48c104dSWu Fengguang 		 unsigned long task_ratelimit),
580b48c104dSWu Fengguang 
5815634cc2aSTejun Heo 	TP_ARGS(wb, dirty_rate, task_ratelimit),
582b48c104dSWu Fengguang 
583b48c104dSWu Fengguang 	TP_STRUCT__entry(
584b48c104dSWu Fengguang 		__array(char,		bdi, 32)
585b48c104dSWu Fengguang 		__field(unsigned long,	write_bw)
586b48c104dSWu Fengguang 		__field(unsigned long,	avg_write_bw)
587b48c104dSWu Fengguang 		__field(unsigned long,	dirty_rate)
588b48c104dSWu Fengguang 		__field(unsigned long,	dirty_ratelimit)
589b48c104dSWu Fengguang 		__field(unsigned long,	task_ratelimit)
590b48c104dSWu Fengguang 		__field(unsigned long,	balanced_dirty_ratelimit)
591f05499a0STejun Heo 		__field(ino_t,		cgroup_ino)
592b48c104dSWu Fengguang 	),
593b48c104dSWu Fengguang 
594b48c104dSWu Fengguang 	TP_fast_assign(
59568f23b89STheodore Ts'o 		strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32);
5965634cc2aSTejun Heo 		__entry->write_bw	= KBps(wb->write_bandwidth);
5975634cc2aSTejun Heo 		__entry->avg_write_bw	= KBps(wb->avg_write_bandwidth);
598b48c104dSWu Fengguang 		__entry->dirty_rate	= KBps(dirty_rate);
5995634cc2aSTejun Heo 		__entry->dirty_ratelimit = KBps(wb->dirty_ratelimit);
600b48c104dSWu Fengguang 		__entry->task_ratelimit	= KBps(task_ratelimit);
601b48c104dSWu Fengguang 		__entry->balanced_dirty_ratelimit =
6025634cc2aSTejun Heo 					KBps(wb->balanced_dirty_ratelimit);
603a664edb3SYang Shi 		__entry->cgroup_ino	= __trace_wb_assign_cgroup(wb);
604b48c104dSWu Fengguang 	),
605b48c104dSWu Fengguang 
606b48c104dSWu Fengguang 	TP_printk("bdi %s: "
607b48c104dSWu Fengguang 		  "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
608b48c104dSWu Fengguang 		  "dirty_ratelimit=%lu task_ratelimit=%lu "
609f05499a0STejun Heo 		  "balanced_dirty_ratelimit=%lu cgroup_ino=%lu",
610b48c104dSWu Fengguang 		  __entry->bdi,
611b48c104dSWu Fengguang 		  __entry->write_bw,		/* write bandwidth */
612b48c104dSWu Fengguang 		  __entry->avg_write_bw,	/* avg write bandwidth */
613b48c104dSWu Fengguang 		  __entry->dirty_rate,		/* bdi dirty rate */
614b48c104dSWu Fengguang 		  __entry->dirty_ratelimit,	/* base ratelimit */
615b48c104dSWu Fengguang 		  __entry->task_ratelimit, /* ratelimit with position control */
6165634cc2aSTejun Heo 		  __entry->balanced_dirty_ratelimit, /* the balanced ratelimit */
61740363cf1SQian Cai 		  (unsigned long)__entry->cgroup_ino
618b48c104dSWu Fengguang 	)
619b48c104dSWu Fengguang );
620b48c104dSWu Fengguang 
621ece13ac3SWu Fengguang TRACE_EVENT(balance_dirty_pages,
622ece13ac3SWu Fengguang 
6235634cc2aSTejun Heo 	TP_PROTO(struct bdi_writeback *wb,
624ece13ac3SWu Fengguang 		 unsigned long thresh,
625ece13ac3SWu Fengguang 		 unsigned long bg_thresh,
626ece13ac3SWu Fengguang 		 unsigned long dirty,
627ece13ac3SWu Fengguang 		 unsigned long bdi_thresh,
628ece13ac3SWu Fengguang 		 unsigned long bdi_dirty,
629ece13ac3SWu Fengguang 		 unsigned long dirty_ratelimit,
630ece13ac3SWu Fengguang 		 unsigned long task_ratelimit,
631ece13ac3SWu Fengguang 		 unsigned long dirtied,
63283712358SWu Fengguang 		 unsigned long period,
633ece13ac3SWu Fengguang 		 long pause,
634ece13ac3SWu Fengguang 		 unsigned long start_time),
635ece13ac3SWu Fengguang 
6365634cc2aSTejun Heo 	TP_ARGS(wb, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
637ece13ac3SWu Fengguang 		dirty_ratelimit, task_ratelimit,
63883712358SWu Fengguang 		dirtied, period, pause, start_time),
639ece13ac3SWu Fengguang 
640ece13ac3SWu Fengguang 	TP_STRUCT__entry(
641ece13ac3SWu Fengguang 		__array(	 char,	bdi, 32)
642ece13ac3SWu Fengguang 		__field(unsigned long,	limit)
643ece13ac3SWu Fengguang 		__field(unsigned long,	setpoint)
644ece13ac3SWu Fengguang 		__field(unsigned long,	dirty)
645ece13ac3SWu Fengguang 		__field(unsigned long,	bdi_setpoint)
646ece13ac3SWu Fengguang 		__field(unsigned long,	bdi_dirty)
647ece13ac3SWu Fengguang 		__field(unsigned long,	dirty_ratelimit)
648ece13ac3SWu Fengguang 		__field(unsigned long,	task_ratelimit)
649ece13ac3SWu Fengguang 		__field(unsigned int,	dirtied)
650ece13ac3SWu Fengguang 		__field(unsigned int,	dirtied_pause)
651ece13ac3SWu Fengguang 		__field(unsigned long,	paused)
652ece13ac3SWu Fengguang 		__field(	 long,	pause)
65383712358SWu Fengguang 		__field(unsigned long,	period)
65483712358SWu Fengguang 		__field(	 long,	think)
655f05499a0STejun Heo 		__field(ino_t,		cgroup_ino)
656ece13ac3SWu Fengguang 	),
657ece13ac3SWu Fengguang 
658ece13ac3SWu Fengguang 	TP_fast_assign(
659ece13ac3SWu Fengguang 		unsigned long freerun = (thresh + bg_thresh) / 2;
66068f23b89STheodore Ts'o 		strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32);
661ece13ac3SWu Fengguang 
662dcc25ae7STejun Heo 		__entry->limit		= global_wb_domain.dirty_limit;
663dcc25ae7STejun Heo 		__entry->setpoint	= (global_wb_domain.dirty_limit +
664dcc25ae7STejun Heo 						freerun) / 2;
665ece13ac3SWu Fengguang 		__entry->dirty		= dirty;
666ece13ac3SWu Fengguang 		__entry->bdi_setpoint	= __entry->setpoint *
667ece13ac3SWu Fengguang 						bdi_thresh / (thresh + 1);
668ece13ac3SWu Fengguang 		__entry->bdi_dirty	= bdi_dirty;
669ece13ac3SWu Fengguang 		__entry->dirty_ratelimit = KBps(dirty_ratelimit);
670ece13ac3SWu Fengguang 		__entry->task_ratelimit	= KBps(task_ratelimit);
671ece13ac3SWu Fengguang 		__entry->dirtied	= dirtied;
672ece13ac3SWu Fengguang 		__entry->dirtied_pause	= current->nr_dirtied_pause;
67383712358SWu Fengguang 		__entry->think		= current->dirty_paused_when == 0 ? 0 :
67483712358SWu Fengguang 			 (long)(jiffies - current->dirty_paused_when) * 1000/HZ;
67583712358SWu Fengguang 		__entry->period		= period * 1000 / HZ;
676ece13ac3SWu Fengguang 		__entry->pause		= pause * 1000 / HZ;
677ece13ac3SWu Fengguang 		__entry->paused		= (jiffies - start_time) * 1000 / HZ;
678a664edb3SYang Shi 		__entry->cgroup_ino	= __trace_wb_assign_cgroup(wb);
679ece13ac3SWu Fengguang 	),
680ece13ac3SWu Fengguang 
681ece13ac3SWu Fengguang 
682ece13ac3SWu Fengguang 	TP_printk("bdi %s: "
683ece13ac3SWu Fengguang 		  "limit=%lu setpoint=%lu dirty=%lu "
684ece13ac3SWu Fengguang 		  "bdi_setpoint=%lu bdi_dirty=%lu "
685ece13ac3SWu Fengguang 		  "dirty_ratelimit=%lu task_ratelimit=%lu "
686ece13ac3SWu Fengguang 		  "dirtied=%u dirtied_pause=%u "
687f05499a0STejun Heo 		  "paused=%lu pause=%ld period=%lu think=%ld cgroup_ino=%lu",
688ece13ac3SWu Fengguang 		  __entry->bdi,
689ece13ac3SWu Fengguang 		  __entry->limit,
690ece13ac3SWu Fengguang 		  __entry->setpoint,
691ece13ac3SWu Fengguang 		  __entry->dirty,
692ece13ac3SWu Fengguang 		  __entry->bdi_setpoint,
693ece13ac3SWu Fengguang 		  __entry->bdi_dirty,
694ece13ac3SWu Fengguang 		  __entry->dirty_ratelimit,
695ece13ac3SWu Fengguang 		  __entry->task_ratelimit,
696ece13ac3SWu Fengguang 		  __entry->dirtied,
697ece13ac3SWu Fengguang 		  __entry->dirtied_pause,
698ece13ac3SWu Fengguang 		  __entry->paused,	/* ms */
69983712358SWu Fengguang 		  __entry->pause,	/* ms */
70083712358SWu Fengguang 		  __entry->period,	/* ms */
7015634cc2aSTejun Heo 		  __entry->think,	/* ms */
70240363cf1SQian Cai 		  (unsigned long)__entry->cgroup_ino
703ece13ac3SWu Fengguang 	  )
704ece13ac3SWu Fengguang );
705ece13ac3SWu Fengguang 
706cc1676d9SJan Kara TRACE_EVENT(writeback_sb_inodes_requeue,
707cc1676d9SJan Kara 
708cc1676d9SJan Kara 	TP_PROTO(struct inode *inode),
709cc1676d9SJan Kara 	TP_ARGS(inode),
710cc1676d9SJan Kara 
711cc1676d9SJan Kara 	TP_STRUCT__entry(
712cc1676d9SJan Kara 		__array(char, name, 32)
713f05499a0STejun Heo 		__field(ino_t, ino)
714cc1676d9SJan Kara 		__field(unsigned long, state)
715cc1676d9SJan Kara 		__field(unsigned long, dirtied_when)
716f05499a0STejun Heo 		__field(ino_t, cgroup_ino)
717cc1676d9SJan Kara 	),
718cc1676d9SJan Kara 
719cc1676d9SJan Kara 	TP_fast_assign(
720d1a445d3SQian Cai 		strscpy_pad(__entry->name,
72168f23b89STheodore Ts'o 			    bdi_dev_name(inode_to_bdi(inode)), 32);
722cc1676d9SJan Kara 		__entry->ino		= inode->i_ino;
723cc1676d9SJan Kara 		__entry->state		= inode->i_state;
724cc1676d9SJan Kara 		__entry->dirtied_when	= inode->dirtied_when;
725a664edb3SYang Shi 		__entry->cgroup_ino	= __trace_wb_assign_cgroup(inode_to_wb(inode));
726cc1676d9SJan Kara 	),
727cc1676d9SJan Kara 
728f05499a0STejun Heo 	TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu cgroup_ino=%lu",
729cc1676d9SJan Kara 		  __entry->name,
73040363cf1SQian Cai 		  (unsigned long)__entry->ino,
731cc1676d9SJan Kara 		  show_inode_state(__entry->state),
732cc1676d9SJan Kara 		  __entry->dirtied_when,
7335634cc2aSTejun Heo 		  (jiffies - __entry->dirtied_when) / HZ,
73440363cf1SQian Cai 		  (unsigned long)__entry->cgroup_ino
735cc1676d9SJan Kara 	)
736cc1676d9SJan Kara );
737cc1676d9SJan Kara 
738251d6a47SWu Fengguang DECLARE_EVENT_CLASS(writeback_single_inode_template,
739251d6a47SWu Fengguang 
740251d6a47SWu Fengguang 	TP_PROTO(struct inode *inode,
741251d6a47SWu Fengguang 		 struct writeback_control *wbc,
742251d6a47SWu Fengguang 		 unsigned long nr_to_write
743251d6a47SWu Fengguang 	),
744251d6a47SWu Fengguang 
745251d6a47SWu Fengguang 	TP_ARGS(inode, wbc, nr_to_write),
746251d6a47SWu Fengguang 
747251d6a47SWu Fengguang 	TP_STRUCT__entry(
748251d6a47SWu Fengguang 		__array(char, name, 32)
749f05499a0STejun Heo 		__field(ino_t, ino)
750251d6a47SWu Fengguang 		__field(unsigned long, state)
751c8ad6206SWu Fengguang 		__field(unsigned long, dirtied_when)
752251d6a47SWu Fengguang 		__field(unsigned long, writeback_index)
753251d6a47SWu Fengguang 		__field(long, nr_to_write)
754251d6a47SWu Fengguang 		__field(unsigned long, wrote)
755f05499a0STejun Heo 		__field(ino_t, cgroup_ino)
756251d6a47SWu Fengguang 	),
757251d6a47SWu Fengguang 
758251d6a47SWu Fengguang 	TP_fast_assign(
759d1a445d3SQian Cai 		strscpy_pad(__entry->name,
76068f23b89STheodore Ts'o 			    bdi_dev_name(inode_to_bdi(inode)), 32);
761251d6a47SWu Fengguang 		__entry->ino		= inode->i_ino;
762251d6a47SWu Fengguang 		__entry->state		= inode->i_state;
763c8ad6206SWu Fengguang 		__entry->dirtied_when	= inode->dirtied_when;
764251d6a47SWu Fengguang 		__entry->writeback_index = inode->i_mapping->writeback_index;
765251d6a47SWu Fengguang 		__entry->nr_to_write	= nr_to_write;
766251d6a47SWu Fengguang 		__entry->wrote		= nr_to_write - wbc->nr_to_write;
767a664edb3SYang Shi 		__entry->cgroup_ino	= __trace_wbc_assign_cgroup(wbc);
768251d6a47SWu Fengguang 	),
769251d6a47SWu Fengguang 
770c8ad6206SWu Fengguang 	TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
771f05499a0STejun Heo 		  "index=%lu to_write=%ld wrote=%lu cgroup_ino=%lu",
772251d6a47SWu Fengguang 		  __entry->name,
77340363cf1SQian Cai 		  (unsigned long)__entry->ino,
774251d6a47SWu Fengguang 		  show_inode_state(__entry->state),
775c8ad6206SWu Fengguang 		  __entry->dirtied_when,
776c8ad6206SWu Fengguang 		  (jiffies - __entry->dirtied_when) / HZ,
777251d6a47SWu Fengguang 		  __entry->writeback_index,
778251d6a47SWu Fengguang 		  __entry->nr_to_write,
7795634cc2aSTejun Heo 		  __entry->wrote,
78040363cf1SQian Cai 		  (unsigned long)__entry->cgroup_ino
781251d6a47SWu Fengguang 	)
782251d6a47SWu Fengguang );
783251d6a47SWu Fengguang 
7849fb0a7daSTejun Heo DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_start,
7859fb0a7daSTejun Heo 	TP_PROTO(struct inode *inode,
7869fb0a7daSTejun Heo 		 struct writeback_control *wbc,
7879fb0a7daSTejun Heo 		 unsigned long nr_to_write),
7889fb0a7daSTejun Heo 	TP_ARGS(inode, wbc, nr_to_write)
7899fb0a7daSTejun Heo );
7909fb0a7daSTejun Heo 
791251d6a47SWu Fengguang DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode,
792251d6a47SWu Fengguang 	TP_PROTO(struct inode *inode,
793251d6a47SWu Fengguang 		 struct writeback_control *wbc,
794251d6a47SWu Fengguang 		 unsigned long nr_to_write),
795251d6a47SWu Fengguang 	TP_ARGS(inode, wbc, nr_to_write)
796251d6a47SWu Fengguang );
797251d6a47SWu Fengguang 
7989a46b04fSBrian Foster DECLARE_EVENT_CLASS(writeback_inode_template,
7990ae45f63STheodore Ts'o 	TP_PROTO(struct inode *inode),
8000ae45f63STheodore Ts'o 
8010ae45f63STheodore Ts'o 	TP_ARGS(inode),
8020ae45f63STheodore Ts'o 
8030ae45f63STheodore Ts'o 	TP_STRUCT__entry(
8040ae45f63STheodore Ts'o 		__field(	dev_t,	dev			)
805f05499a0STejun Heo 		__field(	ino_t,	ino			)
8060ae45f63STheodore Ts'o 		__field(unsigned long,	state			)
8070ae45f63STheodore Ts'o 		__field(	__u16, mode			)
8080ae45f63STheodore Ts'o 		__field(unsigned long, dirtied_when		)
8090ae45f63STheodore Ts'o 	),
8100ae45f63STheodore Ts'o 
8110ae45f63STheodore Ts'o 	TP_fast_assign(
8120ae45f63STheodore Ts'o 		__entry->dev	= inode->i_sb->s_dev;
8130ae45f63STheodore Ts'o 		__entry->ino	= inode->i_ino;
8140ae45f63STheodore Ts'o 		__entry->state	= inode->i_state;
8150ae45f63STheodore Ts'o 		__entry->mode	= inode->i_mode;
8160ae45f63STheodore Ts'o 		__entry->dirtied_when = inode->dirtied_when;
8170ae45f63STheodore Ts'o 	),
8180ae45f63STheodore Ts'o 
8190ae45f63STheodore Ts'o 	TP_printk("dev %d,%d ino %lu dirtied %lu state %s mode 0%o",
8200ae45f63STheodore Ts'o 		  MAJOR(__entry->dev), MINOR(__entry->dev),
82140363cf1SQian Cai 		  (unsigned long)__entry->ino, __entry->dirtied_when,
8220ae45f63STheodore Ts'o 		  show_inode_state(__entry->state), __entry->mode)
8230ae45f63STheodore Ts'o );
8240ae45f63STheodore Ts'o 
8259a46b04fSBrian Foster DEFINE_EVENT(writeback_inode_template, writeback_lazytime,
8260ae45f63STheodore Ts'o 	TP_PROTO(struct inode *inode),
8270ae45f63STheodore Ts'o 
8280ae45f63STheodore Ts'o 	TP_ARGS(inode)
8290ae45f63STheodore Ts'o );
8300ae45f63STheodore Ts'o 
8319a46b04fSBrian Foster DEFINE_EVENT(writeback_inode_template, writeback_lazytime_iput,
8320ae45f63STheodore Ts'o 	TP_PROTO(struct inode *inode),
8330ae45f63STheodore Ts'o 
8340ae45f63STheodore Ts'o 	TP_ARGS(inode)
8350ae45f63STheodore Ts'o );
8360ae45f63STheodore Ts'o 
8379a46b04fSBrian Foster DEFINE_EVENT(writeback_inode_template, writeback_dirty_inode_enqueue,
8380ae45f63STheodore Ts'o 
8390ae45f63STheodore Ts'o 	TP_PROTO(struct inode *inode),
8400ae45f63STheodore Ts'o 
8410ae45f63STheodore Ts'o 	TP_ARGS(inode)
8420ae45f63STheodore Ts'o );
8430ae45f63STheodore Ts'o 
8449a46b04fSBrian Foster /*
8459a46b04fSBrian Foster  * Inode writeback list tracking.
8469a46b04fSBrian Foster  */
8479a46b04fSBrian Foster 
8489a46b04fSBrian Foster DEFINE_EVENT(writeback_inode_template, sb_mark_inode_writeback,
8499a46b04fSBrian Foster 	TP_PROTO(struct inode *inode),
8509a46b04fSBrian Foster 	TP_ARGS(inode)
8519a46b04fSBrian Foster );
8529a46b04fSBrian Foster 
8539a46b04fSBrian Foster DEFINE_EVENT(writeback_inode_template, sb_clear_inode_writeback,
8549a46b04fSBrian Foster 	TP_PROTO(struct inode *inode),
8559a46b04fSBrian Foster 	TP_ARGS(inode)
8569a46b04fSBrian Foster );
8579a46b04fSBrian Foster 
858455b2864SDave Chinner #endif /* _TRACE_WRITEBACK_H */
859455b2864SDave Chinner 
860455b2864SDave Chinner /* This part must be outside protection */
861455b2864SDave Chinner #include <trace/define_trace.h>
862