xref: /openbmc/linux/fs/iomap/trace.h (revision 59b4412f)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2009-2019 Christoph Hellwig
4  *
5  * NOTE: none of these tracepoints shall be consider a stable kernel ABI
6  * as they can change at any time.
7  */
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM iomap
10 
11 #if !defined(_IOMAP_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
12 #define _IOMAP_TRACE_H
13 
14 #include <linux/tracepoint.h>
15 
16 struct inode;
17 
18 DECLARE_EVENT_CLASS(iomap_readpage_class,
19 	TP_PROTO(struct inode *inode, int nr_pages),
20 	TP_ARGS(inode, nr_pages),
21 	TP_STRUCT__entry(
22 		__field(dev_t, dev)
23 		__field(u64, ino)
24 		__field(int, nr_pages)
25 	),
26 	TP_fast_assign(
27 		__entry->dev = inode->i_sb->s_dev;
28 		__entry->ino = inode->i_ino;
29 		__entry->nr_pages = nr_pages;
30 	),
31 	TP_printk("dev %d:%d ino 0x%llx nr_pages %d",
32 		  MAJOR(__entry->dev), MINOR(__entry->dev),
33 		  __entry->ino,
34 		  __entry->nr_pages)
35 )
36 
37 #define DEFINE_READPAGE_EVENT(name)		\
38 DEFINE_EVENT(iomap_readpage_class, name,	\
39 	TP_PROTO(struct inode *inode, int nr_pages), \
40 	TP_ARGS(inode, nr_pages))
41 DEFINE_READPAGE_EVENT(iomap_readpage);
42 DEFINE_READPAGE_EVENT(iomap_readahead);
43 
44 DECLARE_EVENT_CLASS(iomap_range_class,
45 	TP_PROTO(struct inode *inode, unsigned long off, unsigned int len),
46 	TP_ARGS(inode, off, len),
47 	TP_STRUCT__entry(
48 		__field(dev_t, dev)
49 		__field(u64, ino)
50 		__field(loff_t, size)
51 		__field(unsigned long, offset)
52 		__field(unsigned int, length)
53 	),
54 	TP_fast_assign(
55 		__entry->dev = inode->i_sb->s_dev;
56 		__entry->ino = inode->i_ino;
57 		__entry->size = i_size_read(inode);
58 		__entry->offset = off;
59 		__entry->length = len;
60 	),
61 	TP_printk("dev %d:%d ino 0x%llx size 0x%llx offset %lx "
62 		  "length %x",
63 		  MAJOR(__entry->dev), MINOR(__entry->dev),
64 		  __entry->ino,
65 		  __entry->size,
66 		  __entry->offset,
67 		  __entry->length)
68 )
69 
70 #define DEFINE_RANGE_EVENT(name)		\
71 DEFINE_EVENT(iomap_range_class, name,	\
72 	TP_PROTO(struct inode *inode, unsigned long off, unsigned int len),\
73 	TP_ARGS(inode, off, len))
74 DEFINE_RANGE_EVENT(iomap_writepage);
75 DEFINE_RANGE_EVENT(iomap_releasepage);
76 DEFINE_RANGE_EVENT(iomap_invalidatepage);
77 
78 #define IOMAP_TYPE_STRINGS \
79 	{ IOMAP_HOLE,		"HOLE" }, \
80 	{ IOMAP_DELALLOC,	"DELALLOC" }, \
81 	{ IOMAP_MAPPED,		"MAPPED" }, \
82 	{ IOMAP_UNWRITTEN,	"UNWRITTEN" }, \
83 	{ IOMAP_INLINE,		"INLINE" }
84 
85 #define IOMAP_FLAGS_STRINGS \
86 	{ IOMAP_WRITE,		"WRITE" }, \
87 	{ IOMAP_ZERO,		"ZERO" }, \
88 	{ IOMAP_REPORT,		"REPORT" }, \
89 	{ IOMAP_FAULT,		"FAULT" }, \
90 	{ IOMAP_DIRECT,		"DIRECT" }, \
91 	{ IOMAP_NOWAIT,		"NOWAIT" }
92 
93 #define IOMAP_F_FLAGS_STRINGS \
94 	{ IOMAP_F_NEW,		"NEW" }, \
95 	{ IOMAP_F_DIRTY,	"DIRTY" }, \
96 	{ IOMAP_F_SHARED,	"SHARED" }, \
97 	{ IOMAP_F_MERGED,	"MERGED" }, \
98 	{ IOMAP_F_BUFFER_HEAD,	"BH" }, \
99 	{ IOMAP_F_SIZE_CHANGED,	"SIZE_CHANGED" }
100 
101 DECLARE_EVENT_CLASS(iomap_class,
102 	TP_PROTO(struct inode *inode, struct iomap *iomap),
103 	TP_ARGS(inode, iomap),
104 	TP_STRUCT__entry(
105 		__field(dev_t, dev)
106 		__field(u64, ino)
107 		__field(u64, addr)
108 		__field(loff_t, offset)
109 		__field(u64, length)
110 		__field(u16, type)
111 		__field(u16, flags)
112 		__field(dev_t, bdev)
113 	),
114 	TP_fast_assign(
115 		__entry->dev = inode->i_sb->s_dev;
116 		__entry->ino = inode->i_ino;
117 		__entry->addr = iomap->addr;
118 		__entry->offset = iomap->offset;
119 		__entry->length = iomap->length;
120 		__entry->type = iomap->type;
121 		__entry->flags = iomap->flags;
122 		__entry->bdev = iomap->bdev ? iomap->bdev->bd_dev : 0;
123 	),
124 	TP_printk("dev %d:%d ino 0x%llx bdev %d:%d addr %lld offset %lld "
125 		  "length %llu type %s flags %s",
126 		  MAJOR(__entry->dev), MINOR(__entry->dev),
127 		  __entry->ino,
128 		  MAJOR(__entry->bdev), MINOR(__entry->bdev),
129 		  __entry->addr,
130 		  __entry->offset,
131 		  __entry->length,
132 		  __print_symbolic(__entry->type, IOMAP_TYPE_STRINGS),
133 		  __print_flags(__entry->flags, "|", IOMAP_F_FLAGS_STRINGS))
134 )
135 
136 #define DEFINE_IOMAP_EVENT(name)		\
137 DEFINE_EVENT(iomap_class, name,	\
138 	TP_PROTO(struct inode *inode, struct iomap *iomap), \
139 	TP_ARGS(inode, iomap))
140 DEFINE_IOMAP_EVENT(iomap_apply_dstmap);
141 DEFINE_IOMAP_EVENT(iomap_apply_srcmap);
142 
143 TRACE_EVENT(iomap_apply,
144 	TP_PROTO(struct inode *inode, loff_t pos, loff_t length,
145 		unsigned int flags, const void *ops, void *actor,
146 		unsigned long caller),
147 	TP_ARGS(inode, pos, length, flags, ops, actor, caller),
148 	TP_STRUCT__entry(
149 		__field(dev_t, dev)
150 		__field(u64, ino)
151 		__field(loff_t, pos)
152 		__field(loff_t, length)
153 		__field(unsigned int, flags)
154 		__field(const void *, ops)
155 		__field(void *, actor)
156 		__field(unsigned long, caller)
157 	),
158 	TP_fast_assign(
159 		__entry->dev = inode->i_sb->s_dev;
160 		__entry->ino = inode->i_ino;
161 		__entry->pos = pos;
162 		__entry->length = length;
163 		__entry->flags = flags;
164 		__entry->ops = ops;
165 		__entry->actor = actor;
166 		__entry->caller = caller;
167 	),
168 	TP_printk("dev %d:%d ino 0x%llx pos %lld length %lld flags %s (0x%x) "
169 		  "ops %ps caller %pS actor %ps",
170 		  MAJOR(__entry->dev), MINOR(__entry->dev),
171 		   __entry->ino,
172 		   __entry->pos,
173 		   __entry->length,
174 		   __print_flags(__entry->flags, "|", IOMAP_FLAGS_STRINGS),
175 		   __entry->flags,
176 		   __entry->ops,
177 		   (void *)__entry->caller,
178 		   __entry->actor)
179 );
180 
181 #endif /* _IOMAP_TRACE_H */
182 
183 #undef TRACE_INCLUDE_PATH
184 #define TRACE_INCLUDE_PATH .
185 #define TRACE_INCLUDE_FILE trace
186 #include <trace/define_trace.h>
187