1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM filemap
5 #if !defined(_TRACE_FILEMAP_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_FILEMAP_H
8 #include <linux/types.h>
9 #include <linux/tracepoint.h>
11 #include <linux/memcontrol.h>
12 #include <linux/device.h>
13 #include <linux/kdev_t.h>
14 #include <linux/errseq.h>
16 DECLARE_EVENT_CLASS(mm_filemap_op_page_cache
,
18 TP_PROTO(struct folio
*folio
),
23 __field(unsigned long, pfn
)
24 __field(unsigned long, i_ino
)
25 __field(unsigned long, index
)
27 __field(unsigned char, order
)
31 __entry
->pfn
= folio_pfn(folio
);
32 __entry
->i_ino
= folio
->mapping
->host
->i_ino
;
33 __entry
->index
= folio
->index
;
34 if (folio
->mapping
->host
->i_sb
)
35 __entry
->s_dev
= folio
->mapping
->host
->i_sb
->s_dev
;
37 __entry
->s_dev
= folio
->mapping
->host
->i_rdev
;
38 __entry
->order
= folio_order(folio
);
41 TP_printk("dev %d:%d ino %lx pfn=0x%lx ofs=%lu order=%u",
42 MAJOR(__entry
->s_dev
), MINOR(__entry
->s_dev
),
45 __entry
->index
<< PAGE_SHIFT
,
49 DEFINE_EVENT(mm_filemap_op_page_cache
, mm_filemap_delete_from_page_cache
,
50 TP_PROTO(struct folio
*folio
),
54 DEFINE_EVENT(mm_filemap_op_page_cache
, mm_filemap_add_to_page_cache
,
55 TP_PROTO(struct folio
*folio
),
59 DECLARE_EVENT_CLASS(mm_filemap_op_page_cache_range
,
62 struct address_space
*mapping
,
67 TP_ARGS(mapping
, index
, last_index
),
70 __field(unsigned long, i_ino
)
72 __field(unsigned long, index
)
73 __field(unsigned long, last_index
)
77 __entry
->i_ino
= mapping
->host
->i_ino
;
78 if (mapping
->host
->i_sb
)
80 mapping
->host
->i_sb
->s_dev
;
82 __entry
->s_dev
= mapping
->host
->i_rdev
;
83 __entry
->index
= index
;
84 __entry
->last_index
= last_index
;
88 "dev=%d:%d ino=%lx ofs=%lld-%lld",
89 MAJOR(__entry
->s_dev
),
90 MINOR(__entry
->s_dev
), __entry
->i_ino
,
91 ((loff_t
)__entry
->index
) << PAGE_SHIFT
,
92 ((((loff_t
)__entry
->last_index
+ 1) << PAGE_SHIFT
) - 1)
96 DEFINE_EVENT(mm_filemap_op_page_cache_range
, mm_filemap_get_pages
,
98 struct address_space
*mapping
,
102 TP_ARGS(mapping
, index
, last_index
)
105 DEFINE_EVENT(mm_filemap_op_page_cache_range
, mm_filemap_map_pages
,
107 struct address_space
*mapping
,
111 TP_ARGS(mapping
, index
, last_index
)
114 TRACE_EVENT(mm_filemap_fault
,
115 TP_PROTO(struct address_space
*mapping
, pgoff_t index
),
117 TP_ARGS(mapping
, index
),
120 __field(unsigned long, i_ino
)
121 __field(dev_t
, s_dev
)
122 __field(unsigned long, index
)
126 __entry
->i_ino
= mapping
->host
->i_ino
;
127 if (mapping
->host
->i_sb
)
129 mapping
->host
->i_sb
->s_dev
;
131 __entry
->s_dev
= mapping
->host
->i_rdev
;
132 __entry
->index
= index
;
136 "dev=%d:%d ino=%lx ofs=%lld",
137 MAJOR(__entry
->s_dev
),
138 MINOR(__entry
->s_dev
), __entry
->i_ino
,
139 ((loff_t
)__entry
->index
) << PAGE_SHIFT
143 TRACE_EVENT(filemap_set_wb_err
,
144 TP_PROTO(struct address_space
*mapping
, errseq_t eseq
),
146 TP_ARGS(mapping
, eseq
),
149 __field(unsigned long, i_ino
)
150 __field(dev_t
, s_dev
)
151 __field(errseq_t
, errseq
)
155 __entry
->i_ino
= mapping
->host
->i_ino
;
156 __entry
->errseq
= eseq
;
157 if (mapping
->host
->i_sb
)
158 __entry
->s_dev
= mapping
->host
->i_sb
->s_dev
;
160 __entry
->s_dev
= mapping
->host
->i_rdev
;
163 TP_printk("dev=%d:%d ino=0x%lx errseq=0x%x",
164 MAJOR(__entry
->s_dev
), MINOR(__entry
->s_dev
),
165 __entry
->i_ino
, __entry
->errseq
)
168 TRACE_EVENT(file_check_and_advance_wb_err
,
169 TP_PROTO(struct file
*file
, errseq_t old
),
174 __field(struct file
*, file
)
175 __field(unsigned long, i_ino
)
176 __field(dev_t
, s_dev
)
177 __field(errseq_t
, old
)
178 __field(errseq_t
, new)
182 __entry
->file
= file
;
183 __entry
->i_ino
= file
->f_mapping
->host
->i_ino
;
184 if (file
->f_mapping
->host
->i_sb
)
186 file
->f_mapping
->host
->i_sb
->s_dev
;
189 file
->f_mapping
->host
->i_rdev
;
191 __entry
->new = file
->f_wb_err
;
194 TP_printk("file=%p dev=%d:%d ino=0x%lx old=0x%x new=0x%x",
195 __entry
->file
, MAJOR(__entry
->s_dev
),
196 MINOR(__entry
->s_dev
), __entry
->i_ino
, __entry
->old
,
199 #endif /* _TRACE_FILEMAP_H */
201 /* This part must be outside protection */
202 #include <trace/define_trace.h>