This patch adds tracepoints which would be useful for analyzing segment usage from a perspective of high level sufile manipulation (check, alloc, free). sufile is an important in-place updated metadata file, so analyzing the behavior would be useful for performance turning. example of usage (a case of allocation): $ sudo bin/tpoint nilfs2:nilfs2_segment_usage_allocated Tracing nilfs2:nilfs2_segment_usage_allocated. Ctrl-C to end. segctord-17800 [002] ...1 10671.867294: nilfs2_segment_usage_allocated: sufile = ffff880054f908a8 segnum = 2 segctord-17800 [002] ...1 10675.073477: nilfs2_segment_usage_allocated: sufile = ffff880054f908a8 segnum = 3
Unified · Split
| @@ -30,6 +30,8 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "mdt.h" |
| 31 | 31 | #include "sufile.h" |
| 32 | 32 | |
| 33 | +#include <trace/events/nilfs2.h> | |
| 34 | + | |
| 33 | 35 | /** |
| 34 | 36 | * struct nilfs_sufile_info - on-memory private data of sufile |
| 35 | 37 | * @mi: on-memory private data of metadata file |
| @@ -358,6 +360,7 @@ int nilfs_sufile_alloc(struct inode *sufile, __u64 *segnump) · 322 unmodified lines | ||
| 358 | 360 | break; /* never happens */ |
| 359 | 361 | } |
| 360 | 362 | } |
| 363 | + trace_nilfs2_segment_usage_check(sufile, segnum, cnt); | |
| 361 | 364 | ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 1, |
| 362 | 365 | &su_bh); |
| 363 | 366 | if (ret < 0) |
| @@ -388,6 +391,9 @@ int nilfs_sufile_alloc(struct inode *sufile, __u64 *segnump) · 24 unmodified lines | ||
| 388 | 391 | nilfs_mdt_mark_dirty(sufile); |
| 389 | 392 | brelse(su_bh); |
| 390 | 393 | *segnump = segnum; |
| 394 | + | |
| 395 | + trace_nilfs2_segment_usage_allocated(sufile, segnum); | |
| 396 | + | |
| 391 | 397 | goto out_header; |
| 392 | 398 | } |
| 393 | 399 | |
| @@ -490,6 +496,8 @@ void nilfs_sufile_do_free(struct inode *sufile, __u64 segnum, · 96 unmodified lines | ||
| 490 | 496 | NILFS_SUI(sufile)->ncleansegs++; |
| 491 | 497 | |
| 492 | 498 | nilfs_mdt_mark_dirty(sufile); |
| 499 | + | |
| 500 | + trace_nilfs2_segment_usage_freed(sufile, segnum); | |
| 493 | 501 | } |
| 494 | 502 | |
| 495 | 503 | /** |
| @@ -95,6 +95,73 @@ TRACE_EVENT(nilfs2_transaction_transition, · 94 unmodified lines | ||
| 95 | 95 | show_transaction_state(__entry->state)) |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | +TRACE_EVENT(nilfs2_segment_usage_check, | |
| 99 | + TP_PROTO(struct inode *sufile, | |
| 100 | + __u64 segnum, | |
| 101 | + unsigned long cnt), | |
| 102 | + | |
| 103 | + TP_ARGS(sufile, segnum, cnt), | |
| 104 | + | |
| 105 | + TP_STRUCT__entry( | |
| 106 | + __field(struct inode *, sufile) | |
| 107 | + __field(__u64, segnum) | |
| 108 | + __field(unsigned long, cnt) | |
| 109 | + ), | |
| 110 | + | |
| 111 | + TP_fast_assign( | |
| 112 | + __entry->sufile = sufile; | |
| 113 | + __entry->segnum = segnum; | |
| 114 | + __entry->cnt = cnt; | |
| 115 | + ), | |
| 116 | + | |
| 117 | + TP_printk("sufile = %p segnum = %llu cnt = %lu", | |
| 118 | + __entry->sufile, | |
| 119 | + __entry->segnum, | |
| 120 | + __entry->cnt) | |
| 121 | +); | |
| 122 | + | |
| 123 | +TRACE_EVENT(nilfs2_segment_usage_allocated, | |
| 124 | + TP_PROTO(struct inode *sufile, | |
| 125 | + __u64 segnum), | |
| 126 | + | |
| 127 | + TP_ARGS(sufile, segnum), | |
| 128 | + | |
| 129 | + TP_STRUCT__entry( | |
| 130 | + __field(struct inode *, sufile) | |
| 131 | + __field(__u64, segnum) | |
| 132 | + ), | |
| 133 | + | |
| 134 | + TP_fast_assign( | |
| 135 | + __entry->sufile = sufile; | |
| 136 | + __entry->segnum = segnum; | |
| 137 | + ), | |
| 138 | + | |
| 139 | + TP_printk("sufile = %p segnum = %llu", | |
| 140 | + __entry->sufile, | |
| 141 | + __entry->segnum) | |
| 142 | +); | |
| 143 | + | |
| 144 | +TRACE_EVENT(nilfs2_segment_usage_freed, | |
| 145 | + TP_PROTO(struct inode *sufile, | |
| 146 | + __u64 segnum), | |
| 147 | + | |
| 148 | + TP_ARGS(sufile, segnum), | |
| 149 | + | |
| 150 | + TP_STRUCT__entry( | |
| 151 | + __field(struct inode *, sufile) | |
| 152 | + __field(__u64, segnum) | |
| 153 | + ), | |
| 154 | + | |
| 155 | + TP_fast_assign( | |
| 156 | + __entry->sufile = sufile; | |
| 157 | + __entry->segnum = segnum; | |
| 158 | + ), | |
| 159 | + | |
| 160 | + TP_printk("sufile = %p segnum = %llu", | |
| 161 | + __entry->sufile, | |
| 162 | + __entry->segnum) | |
| 163 | +); | |
| 164 | + | |
| 98 | 165 | #endif /* _TRACE_NILFS2_H */ |
| 99 | 166 | |
| 100 | 167 | /* This part must be outside protection */ |