xref: /openbmc/linux/include/trace/events/writeback.h (revision 83712358ba0a1497ce59a4f84ce4dd0f803fe6fc)
1455b2864SDave Chinner #undef TRACE_SYSTEM
2455b2864SDave Chinner #define TRACE_SYSTEM writeback
3455b2864SDave Chinner 
4455b2864SDave Chinner #if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
5455b2864SDave Chinner #define _TRACE_WRITEBACK_H
6455b2864SDave Chinner 
7455b2864SDave Chinner #include <linux/backing-dev.h>
896dccab1SRandy Dunlap #include <linux/device.h>
9455b2864SDave Chinner #include <linux/writeback.h>
10455b2864SDave Chinner 
11251d6a47SWu Fengguang #define show_inode_state(state)					\
12251d6a47SWu Fengguang 	__print_flags(state, "|",				\
13251d6a47SWu Fengguang 		{I_DIRTY_SYNC,		"I_DIRTY_SYNC"},	\
14251d6a47SWu Fengguang 		{I_DIRTY_DATASYNC,	"I_DIRTY_DATASYNC"},	\
15251d6a47SWu Fengguang 		{I_DIRTY_PAGES,		"I_DIRTY_PAGES"},	\
16251d6a47SWu Fengguang 		{I_NEW,			"I_NEW"},		\
17251d6a47SWu Fengguang 		{I_WILL_FREE,		"I_WILL_FREE"},		\
18251d6a47SWu Fengguang 		{I_FREEING,		"I_FREEING"},		\
19251d6a47SWu Fengguang 		{I_CLEAR,		"I_CLEAR"},		\
20251d6a47SWu Fengguang 		{I_SYNC,		"I_SYNC"},		\
21251d6a47SWu Fengguang 		{I_REFERENCED,		"I_REFERENCED"}		\
22251d6a47SWu Fengguang 	)
23251d6a47SWu Fengguang 
24b3bba872SWu Fengguang #define WB_WORK_REASON							\
25b3bba872SWu Fengguang 		{WB_REASON_BACKGROUND,		"background"},		\
26b3bba872SWu Fengguang 		{WB_REASON_TRY_TO_FREE_PAGES,	"try_to_free_pages"},	\
27b3bba872SWu Fengguang 		{WB_REASON_SYNC,		"sync"},		\
28b3bba872SWu Fengguang 		{WB_REASON_PERIODIC,		"periodic"},		\
29b3bba872SWu Fengguang 		{WB_REASON_LAPTOP_TIMER,	"laptop_timer"},	\
30b3bba872SWu Fengguang 		{WB_REASON_FREE_MORE_MEM,	"free_more_memory"},	\
31b3bba872SWu Fengguang 		{WB_REASON_FS_FREE_SPACE,	"fs_free_space"},	\
32b3bba872SWu Fengguang 		{WB_REASON_FORKER_THREAD,	"forker_thread"}
33b3bba872SWu Fengguang 
34455b2864SDave Chinner struct wb_writeback_work;
35455b2864SDave Chinner 
36455b2864SDave Chinner DECLARE_EVENT_CLASS(writeback_work_class,
37455b2864SDave Chinner 	TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
38455b2864SDave Chinner 	TP_ARGS(bdi, work),
39455b2864SDave Chinner 	TP_STRUCT__entry(
40455b2864SDave Chinner 		__array(char, name, 32)
41455b2864SDave Chinner 		__field(long, nr_pages)
42455b2864SDave Chinner 		__field(dev_t, sb_dev)
43455b2864SDave Chinner 		__field(int, sync_mode)
44455b2864SDave Chinner 		__field(int, for_kupdate)
45455b2864SDave Chinner 		__field(int, range_cyclic)
46455b2864SDave Chinner 		__field(int, for_background)
470e175a18SCurt Wohlgemuth 		__field(int, reason)
48455b2864SDave Chinner 	),
49455b2864SDave Chinner 	TP_fast_assign(
50455b2864SDave Chinner 		strncpy(__entry->name, dev_name(bdi->dev), 32);
51455b2864SDave Chinner 		__entry->nr_pages = work->nr_pages;
52455b2864SDave Chinner 		__entry->sb_dev = work->sb ? work->sb->s_dev : 0;
53455b2864SDave Chinner 		__entry->sync_mode = work->sync_mode;
54455b2864SDave Chinner 		__entry->for_kupdate = work->for_kupdate;
55455b2864SDave Chinner 		__entry->range_cyclic = work->range_cyclic;
56455b2864SDave Chinner 		__entry->for_background	= work->for_background;
570e175a18SCurt Wohlgemuth 		__entry->reason = work->reason;
58455b2864SDave Chinner 	),
59455b2864SDave Chinner 	TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
600e175a18SCurt Wohlgemuth 		  "kupdate=%d range_cyclic=%d background=%d reason=%s",
61455b2864SDave Chinner 		  __entry->name,
62455b2864SDave Chinner 		  MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
63455b2864SDave Chinner 		  __entry->nr_pages,
64455b2864SDave Chinner 		  __entry->sync_mode,
65455b2864SDave Chinner 		  __entry->for_kupdate,
66455b2864SDave Chinner 		  __entry->range_cyclic,
670e175a18SCurt Wohlgemuth 		  __entry->for_background,
68b3bba872SWu Fengguang 		  __print_symbolic(__entry->reason, WB_WORK_REASON)
69455b2864SDave Chinner 	)
70455b2864SDave Chinner );
71455b2864SDave Chinner #define DEFINE_WRITEBACK_WORK_EVENT(name) \
72455b2864SDave Chinner DEFINE_EVENT(writeback_work_class, name, \
73455b2864SDave Chinner 	TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
74455b2864SDave Chinner 	TP_ARGS(bdi, work))
75455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread);
76455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
77455b2864SDave Chinner DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
78d46db3d5SWu Fengguang DEFINE_WRITEBACK_WORK_EVENT(writeback_start);
79d46db3d5SWu Fengguang DEFINE_WRITEBACK_WORK_EVENT(writeback_written);
80d46db3d5SWu Fengguang DEFINE_WRITEBACK_WORK_EVENT(writeback_wait);
81455b2864SDave Chinner 
82455b2864SDave Chinner TRACE_EVENT(writeback_pages_written,
83455b2864SDave Chinner 	TP_PROTO(long pages_written),
84455b2864SDave Chinner 	TP_ARGS(pages_written),
85455b2864SDave Chinner 	TP_STRUCT__entry(
86455b2864SDave Chinner 		__field(long,		pages)
87455b2864SDave Chinner 	),
88455b2864SDave Chinner 	TP_fast_assign(
89455b2864SDave Chinner 		__entry->pages		= pages_written;
90455b2864SDave Chinner 	),
91455b2864SDave Chinner 	TP_printk("%ld", __entry->pages)
92455b2864SDave Chinner );
93455b2864SDave Chinner 
94455b2864SDave Chinner DECLARE_EVENT_CLASS(writeback_class,
95455b2864SDave Chinner 	TP_PROTO(struct backing_dev_info *bdi),
96455b2864SDave Chinner 	TP_ARGS(bdi),
97455b2864SDave Chinner 	TP_STRUCT__entry(
98455b2864SDave Chinner 		__array(char, name, 32)
99455b2864SDave Chinner 	),
100455b2864SDave Chinner 	TP_fast_assign(
101455b2864SDave Chinner 		strncpy(__entry->name, dev_name(bdi->dev), 32);
102455b2864SDave Chinner 	),
103455b2864SDave Chinner 	TP_printk("bdi %s",
104455b2864SDave Chinner 		  __entry->name
105455b2864SDave Chinner 	)
106455b2864SDave Chinner );
107455b2864SDave Chinner #define DEFINE_WRITEBACK_EVENT(name) \
108455b2864SDave Chinner DEFINE_EVENT(writeback_class, name, \
109455b2864SDave Chinner 	TP_PROTO(struct backing_dev_info *bdi), \
110455b2864SDave Chinner 	TP_ARGS(bdi))
111455b2864SDave Chinner 
112455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_nowork);
11371927e84SWu Fengguang DEFINE_WRITEBACK_EVENT(writeback_wake_background);
11460332023SArtem Bityutskiy DEFINE_WRITEBACK_EVENT(writeback_wake_thread);
11560332023SArtem Bityutskiy DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread);
116455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
117455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister);
118455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_thread_start);
119455b2864SDave Chinner DEFINE_WRITEBACK_EVENT(writeback_thread_stop);
120455b2864SDave Chinner 
121028c2dd1SDave Chinner DECLARE_EVENT_CLASS(wbc_class,
122028c2dd1SDave Chinner 	TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
123028c2dd1SDave Chinner 	TP_ARGS(wbc, bdi),
124028c2dd1SDave Chinner 	TP_STRUCT__entry(
125028c2dd1SDave Chinner 		__array(char, name, 32)
126028c2dd1SDave Chinner 		__field(long, nr_to_write)
127028c2dd1SDave Chinner 		__field(long, pages_skipped)
128028c2dd1SDave Chinner 		__field(int, sync_mode)
129028c2dd1SDave Chinner 		__field(int, for_kupdate)
130028c2dd1SDave Chinner 		__field(int, for_background)
131028c2dd1SDave Chinner 		__field(int, for_reclaim)
132028c2dd1SDave Chinner 		__field(int, range_cyclic)
133028c2dd1SDave Chinner 		__field(long, range_start)
134028c2dd1SDave Chinner 		__field(long, range_end)
135028c2dd1SDave Chinner 	),
136028c2dd1SDave Chinner 
137028c2dd1SDave Chinner 	TP_fast_assign(
138028c2dd1SDave Chinner 		strncpy(__entry->name, dev_name(bdi->dev), 32);
139028c2dd1SDave Chinner 		__entry->nr_to_write	= wbc->nr_to_write;
140028c2dd1SDave Chinner 		__entry->pages_skipped	= wbc->pages_skipped;
141028c2dd1SDave Chinner 		__entry->sync_mode	= wbc->sync_mode;
142028c2dd1SDave Chinner 		__entry->for_kupdate	= wbc->for_kupdate;
143028c2dd1SDave Chinner 		__entry->for_background	= wbc->for_background;
144028c2dd1SDave Chinner 		__entry->for_reclaim	= wbc->for_reclaim;
145028c2dd1SDave Chinner 		__entry->range_cyclic	= wbc->range_cyclic;
146028c2dd1SDave Chinner 		__entry->range_start	= (long)wbc->range_start;
147028c2dd1SDave Chinner 		__entry->range_end	= (long)wbc->range_end;
148028c2dd1SDave Chinner 	),
149028c2dd1SDave Chinner 
150028c2dd1SDave Chinner 	TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
151d46db3d5SWu Fengguang 		"bgrd=%d reclm=%d cyclic=%d "
152028c2dd1SDave Chinner 		"start=0x%lx end=0x%lx",
153028c2dd1SDave Chinner 		__entry->name,
154028c2dd1SDave Chinner 		__entry->nr_to_write,
155028c2dd1SDave Chinner 		__entry->pages_skipped,
156028c2dd1SDave Chinner 		__entry->sync_mode,
157028c2dd1SDave Chinner 		__entry->for_kupdate,
158028c2dd1SDave Chinner 		__entry->for_background,
159028c2dd1SDave Chinner 		__entry->for_reclaim,
160028c2dd1SDave Chinner 		__entry->range_cyclic,
161028c2dd1SDave Chinner 		__entry->range_start,
162028c2dd1SDave Chinner 		__entry->range_end)
163028c2dd1SDave Chinner )
164028c2dd1SDave Chinner 
165028c2dd1SDave Chinner #define DEFINE_WBC_EVENT(name) \
166028c2dd1SDave Chinner DEFINE_EVENT(wbc_class, name, \
167028c2dd1SDave Chinner 	TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
168028c2dd1SDave Chinner 	TP_ARGS(wbc, bdi))
1699e094383SDave Chinner DEFINE_WBC_EVENT(wbc_writepage);
170028c2dd1SDave Chinner 
171e84d0a4fSWu Fengguang TRACE_EVENT(writeback_queue_io,
172e84d0a4fSWu Fengguang 	TP_PROTO(struct bdi_writeback *wb,
173ad4e38ddSCurt Wohlgemuth 		 struct wb_writeback_work *work,
174e84d0a4fSWu Fengguang 		 int moved),
175ad4e38ddSCurt Wohlgemuth 	TP_ARGS(wb, work, moved),
176e84d0a4fSWu Fengguang 	TP_STRUCT__entry(
177e84d0a4fSWu Fengguang 		__array(char,		name, 32)
178e84d0a4fSWu Fengguang 		__field(unsigned long,	older)
179e84d0a4fSWu Fengguang 		__field(long,		age)
180e84d0a4fSWu Fengguang 		__field(int,		moved)
1810e175a18SCurt Wohlgemuth 		__field(int,		reason)
182e84d0a4fSWu Fengguang 	),
183e84d0a4fSWu Fengguang 	TP_fast_assign(
184ad4e38ddSCurt Wohlgemuth 		unsigned long *older_than_this = work->older_than_this;
185e84d0a4fSWu Fengguang 		strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
186e84d0a4fSWu Fengguang 		__entry->older	= older_than_this ?  *older_than_this : 0;
187e84d0a4fSWu Fengguang 		__entry->age	= older_than_this ?
188e84d0a4fSWu Fengguang 				  (jiffies - *older_than_this) * 1000 / HZ : -1;
189e84d0a4fSWu Fengguang 		__entry->moved	= moved;
1900e175a18SCurt Wohlgemuth 		__entry->reason	= work->reason;
191e84d0a4fSWu Fengguang 	),
1920e175a18SCurt Wohlgemuth 	TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s",
193e84d0a4fSWu Fengguang 		__entry->name,
194e84d0a4fSWu Fengguang 		__entry->older,	/* older_than_this in jiffies */
195e84d0a4fSWu Fengguang 		__entry->age,	/* older_than_this in relative milliseconds */
1960e175a18SCurt Wohlgemuth 		__entry->moved,
197b3bba872SWu Fengguang 		__print_symbolic(__entry->reason, WB_WORK_REASON)
198b3bba872SWu Fengguang 	)
199e84d0a4fSWu Fengguang );
200e84d0a4fSWu Fengguang 
201e1cbe236SWu Fengguang TRACE_EVENT(global_dirty_state,
202e1cbe236SWu Fengguang 
203e1cbe236SWu Fengguang 	TP_PROTO(unsigned long background_thresh,
204e1cbe236SWu Fengguang 		 unsigned long dirty_thresh
205e1cbe236SWu Fengguang 	),
206e1cbe236SWu Fengguang 
207e1cbe236SWu Fengguang 	TP_ARGS(background_thresh,
208e1cbe236SWu Fengguang 		dirty_thresh
209e1cbe236SWu Fengguang 	),
210e1cbe236SWu Fengguang 
211e1cbe236SWu Fengguang 	TP_STRUCT__entry(
212e1cbe236SWu Fengguang 		__field(unsigned long,	nr_dirty)
213e1cbe236SWu Fengguang 		__field(unsigned long,	nr_writeback)
214e1cbe236SWu Fengguang 		__field(unsigned long,	nr_unstable)
215e1cbe236SWu Fengguang 		__field(unsigned long,	background_thresh)
216e1cbe236SWu Fengguang 		__field(unsigned long,	dirty_thresh)
217e1cbe236SWu Fengguang 		__field(unsigned long,	dirty_limit)
218e1cbe236SWu Fengguang 		__field(unsigned long,	nr_dirtied)
219e1cbe236SWu Fengguang 		__field(unsigned long,	nr_written)
220e1cbe236SWu Fengguang 	),
221e1cbe236SWu Fengguang 
222e1cbe236SWu Fengguang 	TP_fast_assign(
223e1cbe236SWu Fengguang 		__entry->nr_dirty	= global_page_state(NR_FILE_DIRTY);
224e1cbe236SWu Fengguang 		__entry->nr_writeback	= global_page_state(NR_WRITEBACK);
225e1cbe236SWu Fengguang 		__entry->nr_unstable	= global_page_state(NR_UNSTABLE_NFS);
226e1cbe236SWu Fengguang 		__entry->nr_dirtied	= global_page_state(NR_DIRTIED);
227e1cbe236SWu Fengguang 		__entry->nr_written	= global_page_state(NR_WRITTEN);
228e1cbe236SWu Fengguang 		__entry->background_thresh = background_thresh;
229e1cbe236SWu Fengguang 		__entry->dirty_thresh	= dirty_thresh;
230e1cbe236SWu Fengguang 		__entry->dirty_limit = global_dirty_limit;
231e1cbe236SWu Fengguang 	),
232e1cbe236SWu Fengguang 
233e1cbe236SWu Fengguang 	TP_printk("dirty=%lu writeback=%lu unstable=%lu "
234e1cbe236SWu Fengguang 		  "bg_thresh=%lu thresh=%lu limit=%lu "
235e1cbe236SWu Fengguang 		  "dirtied=%lu written=%lu",
236e1cbe236SWu Fengguang 		  __entry->nr_dirty,
237e1cbe236SWu Fengguang 		  __entry->nr_writeback,
238e1cbe236SWu Fengguang 		  __entry->nr_unstable,
239e1cbe236SWu Fengguang 		  __entry->background_thresh,
240e1cbe236SWu Fengguang 		  __entry->dirty_thresh,
241e1cbe236SWu Fengguang 		  __entry->dirty_limit,
242e1cbe236SWu Fengguang 		  __entry->nr_dirtied,
243e1cbe236SWu Fengguang 		  __entry->nr_written
244e1cbe236SWu Fengguang 	)
245e1cbe236SWu Fengguang );
246e1cbe236SWu Fengguang 
247b48c104dSWu Fengguang #define KBps(x)			((x) << (PAGE_SHIFT - 10))
248b48c104dSWu Fengguang 
249b48c104dSWu Fengguang TRACE_EVENT(bdi_dirty_ratelimit,
250b48c104dSWu Fengguang 
251b48c104dSWu Fengguang 	TP_PROTO(struct backing_dev_info *bdi,
252b48c104dSWu Fengguang 		 unsigned long dirty_rate,
253b48c104dSWu Fengguang 		 unsigned long task_ratelimit),
254b48c104dSWu Fengguang 
255b48c104dSWu Fengguang 	TP_ARGS(bdi, dirty_rate, task_ratelimit),
256b48c104dSWu Fengguang 
257b48c104dSWu Fengguang 	TP_STRUCT__entry(
258b48c104dSWu Fengguang 		__array(char,		bdi, 32)
259b48c104dSWu Fengguang 		__field(unsigned long,	write_bw)
260b48c104dSWu Fengguang 		__field(unsigned long,	avg_write_bw)
261b48c104dSWu Fengguang 		__field(unsigned long,	dirty_rate)
262b48c104dSWu Fengguang 		__field(unsigned long,	dirty_ratelimit)
263b48c104dSWu Fengguang 		__field(unsigned long,	task_ratelimit)
264b48c104dSWu Fengguang 		__field(unsigned long,	balanced_dirty_ratelimit)
265b48c104dSWu Fengguang 	),
266b48c104dSWu Fengguang 
267b48c104dSWu Fengguang 	TP_fast_assign(
268b48c104dSWu Fengguang 		strlcpy(__entry->bdi, dev_name(bdi->dev), 32);
269b48c104dSWu Fengguang 		__entry->write_bw	= KBps(bdi->write_bandwidth);
270b48c104dSWu Fengguang 		__entry->avg_write_bw	= KBps(bdi->avg_write_bandwidth);
271b48c104dSWu Fengguang 		__entry->dirty_rate	= KBps(dirty_rate);
272b48c104dSWu Fengguang 		__entry->dirty_ratelimit = KBps(bdi->dirty_ratelimit);
273b48c104dSWu Fengguang 		__entry->task_ratelimit	= KBps(task_ratelimit);
274b48c104dSWu Fengguang 		__entry->balanced_dirty_ratelimit =
275b48c104dSWu Fengguang 					  KBps(bdi->balanced_dirty_ratelimit);
276b48c104dSWu Fengguang 	),
277b48c104dSWu Fengguang 
278b48c104dSWu Fengguang 	TP_printk("bdi %s: "
279b48c104dSWu Fengguang 		  "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
280b48c104dSWu Fengguang 		  "dirty_ratelimit=%lu task_ratelimit=%lu "
281b48c104dSWu Fengguang 		  "balanced_dirty_ratelimit=%lu",
282b48c104dSWu Fengguang 		  __entry->bdi,
283b48c104dSWu Fengguang 		  __entry->write_bw,		/* write bandwidth */
284b48c104dSWu Fengguang 		  __entry->avg_write_bw,	/* avg write bandwidth */
285b48c104dSWu Fengguang 		  __entry->dirty_rate,		/* bdi dirty rate */
286b48c104dSWu Fengguang 		  __entry->dirty_ratelimit,	/* base ratelimit */
287b48c104dSWu Fengguang 		  __entry->task_ratelimit, /* ratelimit with position control */
288b48c104dSWu Fengguang 		  __entry->balanced_dirty_ratelimit /* the balanced ratelimit */
289b48c104dSWu Fengguang 	)
290b48c104dSWu Fengguang );
291b48c104dSWu Fengguang 
292ece13ac3SWu Fengguang TRACE_EVENT(balance_dirty_pages,
293ece13ac3SWu Fengguang 
294ece13ac3SWu Fengguang 	TP_PROTO(struct backing_dev_info *bdi,
295ece13ac3SWu Fengguang 		 unsigned long thresh,
296ece13ac3SWu Fengguang 		 unsigned long bg_thresh,
297ece13ac3SWu Fengguang 		 unsigned long dirty,
298ece13ac3SWu Fengguang 		 unsigned long bdi_thresh,
299ece13ac3SWu Fengguang 		 unsigned long bdi_dirty,
300ece13ac3SWu Fengguang 		 unsigned long dirty_ratelimit,
301ece13ac3SWu Fengguang 		 unsigned long task_ratelimit,
302ece13ac3SWu Fengguang 		 unsigned long dirtied,
303*83712358SWu Fengguang 		 unsigned long period,
304ece13ac3SWu Fengguang 		 long pause,
305ece13ac3SWu Fengguang 		 unsigned long start_time),
306ece13ac3SWu Fengguang 
307ece13ac3SWu Fengguang 	TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
308ece13ac3SWu Fengguang 		dirty_ratelimit, task_ratelimit,
309*83712358SWu Fengguang 		dirtied, period, pause, start_time),
310ece13ac3SWu Fengguang 
311ece13ac3SWu Fengguang 	TP_STRUCT__entry(
312ece13ac3SWu Fengguang 		__array(	 char,	bdi, 32)
313ece13ac3SWu Fengguang 		__field(unsigned long,	limit)
314ece13ac3SWu Fengguang 		__field(unsigned long,	setpoint)
315ece13ac3SWu Fengguang 		__field(unsigned long,	dirty)
316ece13ac3SWu Fengguang 		__field(unsigned long,	bdi_setpoint)
317ece13ac3SWu Fengguang 		__field(unsigned long,	bdi_dirty)
318ece13ac3SWu Fengguang 		__field(unsigned long,	dirty_ratelimit)
319ece13ac3SWu Fengguang 		__field(unsigned long,	task_ratelimit)
320ece13ac3SWu Fengguang 		__field(unsigned int,	dirtied)
321ece13ac3SWu Fengguang 		__field(unsigned int,	dirtied_pause)
322ece13ac3SWu Fengguang 		__field(unsigned long,	paused)
323ece13ac3SWu Fengguang 		__field(	 long,	pause)
324*83712358SWu Fengguang 		__field(unsigned long,	period)
325*83712358SWu Fengguang 		__field(	 long,	think)
326ece13ac3SWu Fengguang 	),
327ece13ac3SWu Fengguang 
328ece13ac3SWu Fengguang 	TP_fast_assign(
329ece13ac3SWu Fengguang 		unsigned long freerun = (thresh + bg_thresh) / 2;
330ece13ac3SWu Fengguang 		strlcpy(__entry->bdi, dev_name(bdi->dev), 32);
331ece13ac3SWu Fengguang 
332ece13ac3SWu Fengguang 		__entry->limit		= global_dirty_limit;
333ece13ac3SWu Fengguang 		__entry->setpoint	= (global_dirty_limit + freerun) / 2;
334ece13ac3SWu Fengguang 		__entry->dirty		= dirty;
335ece13ac3SWu Fengguang 		__entry->bdi_setpoint	= __entry->setpoint *
336ece13ac3SWu Fengguang 						bdi_thresh / (thresh + 1);
337ece13ac3SWu Fengguang 		__entry->bdi_dirty	= bdi_dirty;
338ece13ac3SWu Fengguang 		__entry->dirty_ratelimit = KBps(dirty_ratelimit);
339ece13ac3SWu Fengguang 		__entry->task_ratelimit	= KBps(task_ratelimit);
340ece13ac3SWu Fengguang 		__entry->dirtied	= dirtied;
341ece13ac3SWu Fengguang 		__entry->dirtied_pause	= current->nr_dirtied_pause;
342*83712358SWu Fengguang 		__entry->think		= current->dirty_paused_when == 0 ? 0 :
343*83712358SWu Fengguang 			 (long)(jiffies - current->dirty_paused_when) * 1000/HZ;
344*83712358SWu Fengguang 		__entry->period		= period * 1000 / HZ;
345ece13ac3SWu Fengguang 		__entry->pause		= pause * 1000 / HZ;
346ece13ac3SWu Fengguang 		__entry->paused		= (jiffies - start_time) * 1000 / HZ;
347ece13ac3SWu Fengguang 	),
348ece13ac3SWu Fengguang 
349ece13ac3SWu Fengguang 
350ece13ac3SWu Fengguang 	TP_printk("bdi %s: "
351ece13ac3SWu Fengguang 		  "limit=%lu setpoint=%lu dirty=%lu "
352ece13ac3SWu Fengguang 		  "bdi_setpoint=%lu bdi_dirty=%lu "
353ece13ac3SWu Fengguang 		  "dirty_ratelimit=%lu task_ratelimit=%lu "
354ece13ac3SWu Fengguang 		  "dirtied=%u dirtied_pause=%u "
355*83712358SWu Fengguang 		  "paused=%lu pause=%ld period=%lu think=%ld",
356ece13ac3SWu Fengguang 		  __entry->bdi,
357ece13ac3SWu Fengguang 		  __entry->limit,
358ece13ac3SWu Fengguang 		  __entry->setpoint,
359ece13ac3SWu Fengguang 		  __entry->dirty,
360ece13ac3SWu Fengguang 		  __entry->bdi_setpoint,
361ece13ac3SWu Fengguang 		  __entry->bdi_dirty,
362ece13ac3SWu Fengguang 		  __entry->dirty_ratelimit,
363ece13ac3SWu Fengguang 		  __entry->task_ratelimit,
364ece13ac3SWu Fengguang 		  __entry->dirtied,
365ece13ac3SWu Fengguang 		  __entry->dirtied_pause,
366ece13ac3SWu Fengguang 		  __entry->paused,	/* ms */
367*83712358SWu Fengguang 		  __entry->pause,	/* ms */
368*83712358SWu Fengguang 		  __entry->period,	/* ms */
369*83712358SWu Fengguang 		  __entry->think	/* ms */
370ece13ac3SWu Fengguang 	  )
371ece13ac3SWu Fengguang );
372ece13ac3SWu Fengguang 
37352bb9198SMel Gorman DECLARE_EVENT_CLASS(writeback_congest_waited_template,
37452bb9198SMel Gorman 
37552bb9198SMel Gorman 	TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
37652bb9198SMel Gorman 
37752bb9198SMel Gorman 	TP_ARGS(usec_timeout, usec_delayed),
37852bb9198SMel Gorman 
37952bb9198SMel Gorman 	TP_STRUCT__entry(
38052bb9198SMel Gorman 		__field(	unsigned int,	usec_timeout	)
38152bb9198SMel Gorman 		__field(	unsigned int,	usec_delayed	)
38252bb9198SMel Gorman 	),
38352bb9198SMel Gorman 
38452bb9198SMel Gorman 	TP_fast_assign(
38552bb9198SMel Gorman 		__entry->usec_timeout	= usec_timeout;
38652bb9198SMel Gorman 		__entry->usec_delayed	= usec_delayed;
38752bb9198SMel Gorman 	),
38852bb9198SMel Gorman 
38952bb9198SMel Gorman 	TP_printk("usec_timeout=%u usec_delayed=%u",
39052bb9198SMel Gorman 			__entry->usec_timeout,
39152bb9198SMel Gorman 			__entry->usec_delayed)
39252bb9198SMel Gorman );
39352bb9198SMel Gorman 
39452bb9198SMel Gorman DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
39552bb9198SMel Gorman 
39652bb9198SMel Gorman 	TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
39752bb9198SMel Gorman 
39852bb9198SMel Gorman 	TP_ARGS(usec_timeout, usec_delayed)
39952bb9198SMel Gorman );
40052bb9198SMel Gorman 
4010e093d99SMel Gorman DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
4020e093d99SMel Gorman 
4030e093d99SMel Gorman 	TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
4040e093d99SMel Gorman 
4050e093d99SMel Gorman 	TP_ARGS(usec_timeout, usec_delayed)
4060e093d99SMel Gorman );
4070e093d99SMel Gorman 
408251d6a47SWu Fengguang DECLARE_EVENT_CLASS(writeback_single_inode_template,
409251d6a47SWu Fengguang 
410251d6a47SWu Fengguang 	TP_PROTO(struct inode *inode,
411251d6a47SWu Fengguang 		 struct writeback_control *wbc,
412251d6a47SWu Fengguang 		 unsigned long nr_to_write
413251d6a47SWu Fengguang 	),
414251d6a47SWu Fengguang 
415251d6a47SWu Fengguang 	TP_ARGS(inode, wbc, nr_to_write),
416251d6a47SWu Fengguang 
417251d6a47SWu Fengguang 	TP_STRUCT__entry(
418251d6a47SWu Fengguang 		__array(char, name, 32)
419251d6a47SWu Fengguang 		__field(unsigned long, ino)
420251d6a47SWu Fengguang 		__field(unsigned long, state)
421c8ad6206SWu Fengguang 		__field(unsigned long, dirtied_when)
422251d6a47SWu Fengguang 		__field(unsigned long, writeback_index)
423251d6a47SWu Fengguang 		__field(long, nr_to_write)
424251d6a47SWu Fengguang 		__field(unsigned long, wrote)
425251d6a47SWu Fengguang 	),
426251d6a47SWu Fengguang 
427251d6a47SWu Fengguang 	TP_fast_assign(
428251d6a47SWu Fengguang 		strncpy(__entry->name,
429251d6a47SWu Fengguang 			dev_name(inode->i_mapping->backing_dev_info->dev), 32);
430251d6a47SWu Fengguang 		__entry->ino		= inode->i_ino;
431251d6a47SWu Fengguang 		__entry->state		= inode->i_state;
432c8ad6206SWu Fengguang 		__entry->dirtied_when	= inode->dirtied_when;
433251d6a47SWu Fengguang 		__entry->writeback_index = inode->i_mapping->writeback_index;
434251d6a47SWu Fengguang 		__entry->nr_to_write	= nr_to_write;
435251d6a47SWu Fengguang 		__entry->wrote		= nr_to_write - wbc->nr_to_write;
436251d6a47SWu Fengguang 	),
437251d6a47SWu Fengguang 
438c8ad6206SWu Fengguang 	TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
439251d6a47SWu Fengguang 		  "index=%lu to_write=%ld wrote=%lu",
440251d6a47SWu Fengguang 		  __entry->name,
441251d6a47SWu Fengguang 		  __entry->ino,
442251d6a47SWu Fengguang 		  show_inode_state(__entry->state),
443c8ad6206SWu Fengguang 		  __entry->dirtied_when,
444c8ad6206SWu Fengguang 		  (jiffies - __entry->dirtied_when) / HZ,
445251d6a47SWu Fengguang 		  __entry->writeback_index,
446251d6a47SWu Fengguang 		  __entry->nr_to_write,
447251d6a47SWu Fengguang 		  __entry->wrote
448251d6a47SWu Fengguang 	)
449251d6a47SWu Fengguang );
450251d6a47SWu Fengguang 
451251d6a47SWu Fengguang DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_requeue,
452251d6a47SWu Fengguang 	TP_PROTO(struct inode *inode,
453251d6a47SWu Fengguang 		 struct writeback_control *wbc,
454251d6a47SWu Fengguang 		 unsigned long nr_to_write),
455251d6a47SWu Fengguang 	TP_ARGS(inode, wbc, nr_to_write)
456251d6a47SWu Fengguang );
457251d6a47SWu Fengguang 
458251d6a47SWu Fengguang DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode,
459251d6a47SWu Fengguang 	TP_PROTO(struct inode *inode,
460251d6a47SWu Fengguang 		 struct writeback_control *wbc,
461251d6a47SWu Fengguang 		 unsigned long nr_to_write),
462251d6a47SWu Fengguang 	TP_ARGS(inode, wbc, nr_to_write)
463251d6a47SWu Fengguang );
464251d6a47SWu Fengguang 
465455b2864SDave Chinner #endif /* _TRACE_WRITEBACK_H */
466455b2864SDave Chinner 
467455b2864SDave Chinner /* This part must be outside protection */
468455b2864SDave Chinner #include <trace/define_trace.h>
469