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