blob: 981acf74b14f1fdbf00fc2c7bd915c82a9b37c3c [file] [log] [blame]
Kent Overstreetcafe5632013-03-23 16:11:31 -07001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM bcache
3
4#if !defined(_TRACE_BCACHE_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_BCACHE_H
6
7#include <linux/tracepoint.h>
8
Kent Overstreetcafe5632013-03-23 16:11:31 -07009DECLARE_EVENT_CLASS(bcache_request,
Kent Overstreet220bb382013-09-10 19:02:45 -070010 TP_PROTO(struct bcache_device *d, struct bio *bio),
11 TP_ARGS(d, bio),
Kent Overstreetcafe5632013-03-23 16:11:31 -070012
13 TP_STRUCT__entry(
14 __field(dev_t, dev )
15 __field(unsigned int, orig_major )
16 __field(unsigned int, orig_minor )
17 __field(sector_t, sector )
18 __field(dev_t, orig_sector )
19 __field(unsigned int, nr_sector )
20 __array(char, rwbs, 6 )
Kent Overstreetcafe5632013-03-23 16:11:31 -070021 ),
22
23 TP_fast_assign(
24 __entry->dev = bio->bi_bdev->bd_dev;
Kent Overstreet220bb382013-09-10 19:02:45 -070025 __entry->orig_major = d->disk->major;
26 __entry->orig_minor = d->disk->first_minor;
Kent Overstreet4f024f32013-10-11 15:44:27 -070027 __entry->sector = bio->bi_iter.bi_sector;
28 __entry->orig_sector = bio->bi_iter.bi_sector - 16;
29 __entry->nr_sector = bio->bi_iter.bi_size >> 9;
30 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_iter.bi_size);
Kent Overstreetcafe5632013-03-23 16:11:31 -070031 ),
32
Kent Overstreetc37511b2013-04-26 15:39:55 -070033 TP_printk("%d,%d %s %llu + %u (from %d,%d @ %llu)",
Kent Overstreetcafe5632013-03-23 16:11:31 -070034 MAJOR(__entry->dev), MINOR(__entry->dev),
Kent Overstreetc37511b2013-04-26 15:39:55 -070035 __entry->rwbs, (unsigned long long)__entry->sector,
36 __entry->nr_sector, __entry->orig_major, __entry->orig_minor,
Kent Overstreetcafe5632013-03-23 16:11:31 -070037 (unsigned long long)__entry->orig_sector)
38);
39
Kent Overstreetc37511b2013-04-26 15:39:55 -070040DECLARE_EVENT_CLASS(bkey,
41 TP_PROTO(struct bkey *k),
42 TP_ARGS(k),
43
44 TP_STRUCT__entry(
45 __field(u32, size )
46 __field(u32, inode )
47 __field(u64, offset )
48 __field(bool, dirty )
49 ),
50
51 TP_fast_assign(
52 __entry->inode = KEY_INODE(k);
53 __entry->offset = KEY_OFFSET(k);
54 __entry->size = KEY_SIZE(k);
55 __entry->dirty = KEY_DIRTY(k);
56 ),
57
58 TP_printk("%u:%llu len %u dirty %u", __entry->inode,
59 __entry->offset, __entry->size, __entry->dirty)
60);
61
62DECLARE_EVENT_CLASS(btree_node,
63 TP_PROTO(struct btree *b),
64 TP_ARGS(b),
65
66 TP_STRUCT__entry(
67 __field(size_t, bucket )
68 ),
69
70 TP_fast_assign(
71 __entry->bucket = PTR_BUCKET_NR(b->c, &b->key, 0);
72 ),
73
74 TP_printk("bucket %zu", __entry->bucket)
75);
76
77/* request.c */
78
Kent Overstreetcafe5632013-03-23 16:11:31 -070079DEFINE_EVENT(bcache_request, bcache_request_start,
Kent Overstreet220bb382013-09-10 19:02:45 -070080 TP_PROTO(struct bcache_device *d, struct bio *bio),
81 TP_ARGS(d, bio)
Kent Overstreetcafe5632013-03-23 16:11:31 -070082);
83
84DEFINE_EVENT(bcache_request, bcache_request_end,
Kent Overstreet220bb382013-09-10 19:02:45 -070085 TP_PROTO(struct bcache_device *d, struct bio *bio),
86 TP_ARGS(d, bio)
Kent Overstreetcafe5632013-03-23 16:11:31 -070087);
88
89DECLARE_EVENT_CLASS(bcache_bio,
Kent Overstreetcafe5632013-03-23 16:11:31 -070090 TP_PROTO(struct bio *bio),
Kent Overstreetcafe5632013-03-23 16:11:31 -070091 TP_ARGS(bio),
92
93 TP_STRUCT__entry(
94 __field(dev_t, dev )
95 __field(sector_t, sector )
96 __field(unsigned int, nr_sector )
97 __array(char, rwbs, 6 )
Kent Overstreetcafe5632013-03-23 16:11:31 -070098 ),
99
100 TP_fast_assign(
101 __entry->dev = bio->bi_bdev->bd_dev;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700102 __entry->sector = bio->bi_iter.bi_sector;
103 __entry->nr_sector = bio->bi_iter.bi_size >> 9;
104 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_iter.bi_size);
Kent Overstreetcafe5632013-03-23 16:11:31 -0700105 ),
106
Kent Overstreetc37511b2013-04-26 15:39:55 -0700107 TP_printk("%d,%d %s %llu + %u",
108 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
109 (unsigned long long)__entry->sector, __entry->nr_sector)
Kent Overstreetcafe5632013-03-23 16:11:31 -0700110);
111
Kent Overstreetc37511b2013-04-26 15:39:55 -0700112DEFINE_EVENT(bcache_bio, bcache_bypass_sequential,
Kent Overstreetcafe5632013-03-23 16:11:31 -0700113 TP_PROTO(struct bio *bio),
Kent Overstreetcafe5632013-03-23 16:11:31 -0700114 TP_ARGS(bio)
115);
116
Kent Overstreetc37511b2013-04-26 15:39:55 -0700117DEFINE_EVENT(bcache_bio, bcache_bypass_congested,
Kent Overstreetcafe5632013-03-23 16:11:31 -0700118 TP_PROTO(struct bio *bio),
Kent Overstreetcafe5632013-03-23 16:11:31 -0700119 TP_ARGS(bio)
120);
121
Kent Overstreetc37511b2013-04-26 15:39:55 -0700122TRACE_EVENT(bcache_read,
123 TP_PROTO(struct bio *bio, bool hit, bool bypass),
124 TP_ARGS(bio, hit, bypass),
Kent Overstreetcafe5632013-03-23 16:11:31 -0700125
126 TP_STRUCT__entry(
127 __field(dev_t, dev )
Kent Overstreetcafe5632013-03-23 16:11:31 -0700128 __field(sector_t, sector )
Kent Overstreetcafe5632013-03-23 16:11:31 -0700129 __field(unsigned int, nr_sector )
130 __array(char, rwbs, 6 )
Kent Overstreetc37511b2013-04-26 15:39:55 -0700131 __field(bool, cache_hit )
132 __field(bool, bypass )
Kent Overstreetcafe5632013-03-23 16:11:31 -0700133 ),
134
135 TP_fast_assign(
136 __entry->dev = bio->bi_bdev->bd_dev;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700137 __entry->sector = bio->bi_iter.bi_sector;
138 __entry->nr_sector = bio->bi_iter.bi_size >> 9;
139 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_iter.bi_size);
Kent Overstreetc37511b2013-04-26 15:39:55 -0700140 __entry->cache_hit = hit;
141 __entry->bypass = bypass;
Kent Overstreetcafe5632013-03-23 16:11:31 -0700142 ),
143
Kent Overstreetc37511b2013-04-26 15:39:55 -0700144 TP_printk("%d,%d %s %llu + %u hit %u bypass %u",
Kent Overstreetcafe5632013-03-23 16:11:31 -0700145 MAJOR(__entry->dev), MINOR(__entry->dev),
Kent Overstreetc37511b2013-04-26 15:39:55 -0700146 __entry->rwbs, (unsigned long long)__entry->sector,
147 __entry->nr_sector, __entry->cache_hit, __entry->bypass)
Kent Overstreetcafe5632013-03-23 16:11:31 -0700148);
149
Kent Overstreetc37511b2013-04-26 15:39:55 -0700150TRACE_EVENT(bcache_write,
Slava Pestov60ae81e2014-05-22 12:14:24 -0700151 TP_PROTO(struct cache_set *c, u64 inode, struct bio *bio,
152 bool writeback, bool bypass),
153 TP_ARGS(c, inode, bio, writeback, bypass),
Kent Overstreetcafe5632013-03-23 16:11:31 -0700154
155 TP_STRUCT__entry(
Slava Pestov60ae81e2014-05-22 12:14:24 -0700156 __array(char, uuid, 16 )
157 __field(u64, inode )
Kent Overstreetc37511b2013-04-26 15:39:55 -0700158 __field(sector_t, sector )
159 __field(unsigned int, nr_sector )
160 __array(char, rwbs, 6 )
161 __field(bool, writeback )
162 __field(bool, bypass )
Kent Overstreetcafe5632013-03-23 16:11:31 -0700163 ),
164
165 TP_fast_assign(
Slava Pestov60ae81e2014-05-22 12:14:24 -0700166 memcpy(__entry->uuid, c->sb.set_uuid, 16);
167 __entry->inode = inode;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700168 __entry->sector = bio->bi_iter.bi_sector;
169 __entry->nr_sector = bio->bi_iter.bi_size >> 9;
170 blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_iter.bi_size);
Kent Overstreetc37511b2013-04-26 15:39:55 -0700171 __entry->writeback = writeback;
172 __entry->bypass = bypass;
173 ),
174
Slava Pestov60ae81e2014-05-22 12:14:24 -0700175 TP_printk("%pU inode %llu %s %llu + %u hit %u bypass %u",
176 __entry->uuid, __entry->inode,
Kent Overstreetc37511b2013-04-26 15:39:55 -0700177 __entry->rwbs, (unsigned long long)__entry->sector,
178 __entry->nr_sector, __entry->writeback, __entry->bypass)
179);
180
181DEFINE_EVENT(bcache_bio, bcache_read_retry,
182 TP_PROTO(struct bio *bio),
183 TP_ARGS(bio)
184);
185
186DEFINE_EVENT(bkey, bcache_cache_insert,
187 TP_PROTO(struct bkey *k),
188 TP_ARGS(k)
189);
190
191/* Journal */
192
193DECLARE_EVENT_CLASS(cache_set,
194 TP_PROTO(struct cache_set *c),
195 TP_ARGS(c),
196
197 TP_STRUCT__entry(
198 __array(char, uuid, 16 )
199 ),
200
201 TP_fast_assign(
202 memcpy(__entry->uuid, c->sb.set_uuid, 16);
Kent Overstreetcafe5632013-03-23 16:11:31 -0700203 ),
204
205 TP_printk("%pU", __entry->uuid)
206);
207
Kent Overstreetc37511b2013-04-26 15:39:55 -0700208DEFINE_EVENT(bkey, bcache_journal_replay_key,
209 TP_PROTO(struct bkey *k),
210 TP_ARGS(k)
Kent Overstreetcafe5632013-03-23 16:11:31 -0700211);
212
Kent Overstreetc37511b2013-04-26 15:39:55 -0700213DEFINE_EVENT(cache_set, bcache_journal_full,
214 TP_PROTO(struct cache_set *c),
215 TP_ARGS(c)
216);
Kent Overstreetcafe5632013-03-23 16:11:31 -0700217
Kent Overstreetc37511b2013-04-26 15:39:55 -0700218DEFINE_EVENT(cache_set, bcache_journal_entry_full,
219 TP_PROTO(struct cache_set *c),
220 TP_ARGS(c)
221);
Kent Overstreetcafe5632013-03-23 16:11:31 -0700222
Kent Overstreetc37511b2013-04-26 15:39:55 -0700223DEFINE_EVENT(bcache_bio, bcache_journal_write,
224 TP_PROTO(struct bio *bio),
225 TP_ARGS(bio)
226);
227
228/* Btree */
229
230DEFINE_EVENT(cache_set, bcache_btree_cache_cannibalize,
231 TP_PROTO(struct cache_set *c),
232 TP_ARGS(c)
233);
234
235DEFINE_EVENT(btree_node, bcache_btree_read,
236 TP_PROTO(struct btree *b),
237 TP_ARGS(b)
238);
239
240TRACE_EVENT(bcache_btree_write,
241 TP_PROTO(struct btree *b),
242 TP_ARGS(b),
243
244 TP_STRUCT__entry(
245 __field(size_t, bucket )
246 __field(unsigned, block )
247 __field(unsigned, keys )
248 ),
249
250 TP_fast_assign(
251 __entry->bucket = PTR_BUCKET_NR(b->c, &b->key, 0);
252 __entry->block = b->written;
Kent Overstreeta85e9682013-12-20 17:28:16 -0800253 __entry->keys = b->keys.set[b->keys.nsets].data->keys;
Kent Overstreetc37511b2013-04-26 15:39:55 -0700254 ),
255
256 TP_printk("bucket %zu", __entry->bucket)
257);
258
259DEFINE_EVENT(btree_node, bcache_btree_node_alloc,
260 TP_PROTO(struct btree *b),
261 TP_ARGS(b)
262);
263
Slava Pestov913dc332014-05-23 11:18:35 -0700264DEFINE_EVENT(cache_set, bcache_btree_node_alloc_fail,
265 TP_PROTO(struct cache_set *c),
266 TP_ARGS(c)
Kent Overstreetc37511b2013-04-26 15:39:55 -0700267);
268
269DEFINE_EVENT(btree_node, bcache_btree_node_free,
270 TP_PROTO(struct btree *b),
271 TP_ARGS(b)
272);
273
274TRACE_EVENT(bcache_btree_gc_coalesce,
275 TP_PROTO(unsigned nodes),
276 TP_ARGS(nodes),
277
278 TP_STRUCT__entry(
279 __field(unsigned, nodes )
280 ),
281
282 TP_fast_assign(
283 __entry->nodes = nodes;
284 ),
285
286 TP_printk("coalesced %u nodes", __entry->nodes)
287);
288
289DEFINE_EVENT(cache_set, bcache_gc_start,
290 TP_PROTO(struct cache_set *c),
291 TP_ARGS(c)
292);
293
294DEFINE_EVENT(cache_set, bcache_gc_end,
295 TP_PROTO(struct cache_set *c),
296 TP_ARGS(c)
297);
298
299DEFINE_EVENT(bkey, bcache_gc_copy,
300 TP_PROTO(struct bkey *k),
301 TP_ARGS(k)
302);
303
304DEFINE_EVENT(bkey, bcache_gc_copy_collision,
305 TP_PROTO(struct bkey *k),
306 TP_ARGS(k)
307);
308
Kent Overstreet85b14922013-05-14 20:33:16 -0700309TRACE_EVENT(bcache_btree_insert_key,
310 TP_PROTO(struct btree *b, struct bkey *k, unsigned op, unsigned status),
311 TP_ARGS(b, k, op, status),
312
313 TP_STRUCT__entry(
314 __field(u64, btree_node )
315 __field(u32, btree_level )
316 __field(u32, inode )
317 __field(u64, offset )
318 __field(u32, size )
319 __field(u8, dirty )
320 __field(u8, op )
321 __field(u8, status )
322 ),
323
324 TP_fast_assign(
325 __entry->btree_node = PTR_BUCKET_NR(b->c, &b->key, 0);
326 __entry->btree_level = b->level;
327 __entry->inode = KEY_INODE(k);
328 __entry->offset = KEY_OFFSET(k);
329 __entry->size = KEY_SIZE(k);
330 __entry->dirty = KEY_DIRTY(k);
331 __entry->op = op;
332 __entry->status = status;
333 ),
334
335 TP_printk("%u for %u at %llu(%u): %u:%llu len %u dirty %u",
336 __entry->status, __entry->op,
337 __entry->btree_node, __entry->btree_level,
338 __entry->inode, __entry->offset,
339 __entry->size, __entry->dirty)
340);
341
Kent Overstreetc37511b2013-04-26 15:39:55 -0700342DECLARE_EVENT_CLASS(btree_split,
343 TP_PROTO(struct btree *b, unsigned keys),
344 TP_ARGS(b, keys),
345
346 TP_STRUCT__entry(
347 __field(size_t, bucket )
348 __field(unsigned, keys )
349 ),
350
351 TP_fast_assign(
352 __entry->bucket = PTR_BUCKET_NR(b->c, &b->key, 0);
353 __entry->keys = keys;
354 ),
355
356 TP_printk("bucket %zu keys %u", __entry->bucket, __entry->keys)
357);
358
359DEFINE_EVENT(btree_split, bcache_btree_node_split,
360 TP_PROTO(struct btree *b, unsigned keys),
361 TP_ARGS(b, keys)
362);
363
364DEFINE_EVENT(btree_split, bcache_btree_node_compact,
365 TP_PROTO(struct btree *b, unsigned keys),
366 TP_ARGS(b, keys)
367);
368
369DEFINE_EVENT(btree_node, bcache_btree_set_root,
370 TP_PROTO(struct btree *b),
371 TP_ARGS(b)
372);
373
Kent Overstreet48a915a2013-10-31 15:43:22 -0700374TRACE_EVENT(bcache_keyscan,
375 TP_PROTO(unsigned nr_found,
376 unsigned start_inode, uint64_t start_offset,
377 unsigned end_inode, uint64_t end_offset),
378 TP_ARGS(nr_found,
379 start_inode, start_offset,
380 end_inode, end_offset),
381
382 TP_STRUCT__entry(
383 __field(__u32, nr_found )
384 __field(__u32, start_inode )
385 __field(__u64, start_offset )
386 __field(__u32, end_inode )
387 __field(__u64, end_offset )
388 ),
389
390 TP_fast_assign(
391 __entry->nr_found = nr_found;
392 __entry->start_inode = start_inode;
393 __entry->start_offset = start_offset;
394 __entry->end_inode = end_inode;
395 __entry->end_offset = end_offset;
396 ),
397
398 TP_printk("found %u keys from %u:%llu to %u:%llu", __entry->nr_found,
399 __entry->start_inode, __entry->start_offset,
400 __entry->end_inode, __entry->end_offset)
401);
402
Kent Overstreetc37511b2013-04-26 15:39:55 -0700403/* Allocator */
404
Kent Overstreet7159b1a2014-02-12 18:43:32 -0800405TRACE_EVENT(bcache_invalidate,
406 TP_PROTO(struct cache *ca, size_t bucket),
407 TP_ARGS(ca, bucket),
Kent Overstreetc37511b2013-04-26 15:39:55 -0700408
409 TP_STRUCT__entry(
Kent Overstreet7159b1a2014-02-12 18:43:32 -0800410 __field(unsigned, sectors )
411 __field(dev_t, dev )
412 __field(__u64, offset )
Kent Overstreetc37511b2013-04-26 15:39:55 -0700413 ),
414
415 TP_fast_assign(
Kent Overstreet7159b1a2014-02-12 18:43:32 -0800416 __entry->dev = ca->bdev->bd_dev;
417 __entry->offset = bucket << ca->set->bucket_bits;
418 __entry->sectors = GC_SECTORS_USED(&ca->buckets[bucket]);
Kent Overstreetc37511b2013-04-26 15:39:55 -0700419 ),
420
Kent Overstreet7159b1a2014-02-12 18:43:32 -0800421 TP_printk("invalidated %u sectors at %d,%d sector=%llu",
422 __entry->sectors, MAJOR(__entry->dev),
423 MINOR(__entry->dev), __entry->offset)
424);
425
426TRACE_EVENT(bcache_alloc,
427 TP_PROTO(struct cache *ca, size_t bucket),
428 TP_ARGS(ca, bucket),
429
430 TP_STRUCT__entry(
431 __field(dev_t, dev )
432 __field(__u64, offset )
433 ),
434
435 TP_fast_assign(
436 __entry->dev = ca->bdev->bd_dev;
437 __entry->offset = bucket << ca->set->bucket_bits;
438 ),
439
440 TP_printk("allocated %d,%d sector=%llu", MAJOR(__entry->dev),
441 MINOR(__entry->dev), __entry->offset)
Kent Overstreetc37511b2013-04-26 15:39:55 -0700442);
443
444TRACE_EVENT(bcache_alloc_fail,
Kent Overstreet78365412013-12-17 01:29:34 -0800445 TP_PROTO(struct cache *ca, unsigned reserve),
446 TP_ARGS(ca, reserve),
Kent Overstreetc37511b2013-04-26 15:39:55 -0700447
448 TP_STRUCT__entry(
Kent Overstreet7159b1a2014-02-12 18:43:32 -0800449 __field(dev_t, dev )
Kent Overstreetc37511b2013-04-26 15:39:55 -0700450 __field(unsigned, free )
451 __field(unsigned, free_inc )
Kent Overstreetc37511b2013-04-26 15:39:55 -0700452 __field(unsigned, blocked )
453 ),
454
455 TP_fast_assign(
Kent Overstreet7159b1a2014-02-12 18:43:32 -0800456 __entry->dev = ca->bdev->bd_dev;
Kent Overstreet78365412013-12-17 01:29:34 -0800457 __entry->free = fifo_used(&ca->free[reserve]);
Kent Overstreetc37511b2013-04-26 15:39:55 -0700458 __entry->free_inc = fifo_used(&ca->free_inc);
Kent Overstreetc37511b2013-04-26 15:39:55 -0700459 __entry->blocked = atomic_read(&ca->set->prio_blocked);
460 ),
461
Kent Overstreet2531d9ee2014-03-17 16:55:55 -0700462 TP_printk("alloc fail %d,%d free %u free_inc %u blocked %u",
Kent Overstreet7159b1a2014-02-12 18:43:32 -0800463 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->free,
Kent Overstreet2531d9ee2014-03-17 16:55:55 -0700464 __entry->free_inc, __entry->blocked)
Kent Overstreetc37511b2013-04-26 15:39:55 -0700465);
466
467/* Background writeback */
468
469DEFINE_EVENT(bkey, bcache_writeback,
470 TP_PROTO(struct bkey *k),
471 TP_ARGS(k)
472);
473
474DEFINE_EVENT(bkey, bcache_writeback_collision,
475 TP_PROTO(struct bkey *k),
476 TP_ARGS(k)
Kent Overstreetcafe5632013-03-23 16:11:31 -0700477);
478
479#endif /* _TRACE_BCACHE_H */
480
481/* This part must be outside protection */
482#include <trace/define_trace.h>