aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-02-02 17:30:40 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-03 08:03:53 -0500
commit08a06b83ff8b2779289f733348c669f31cb65d51 (patch)
treec8d5c13361ff9aa8e45cd660fbcad264b8310100 /block
parent2c9b238eb325895d3312dad64e2685783575e474 (diff)
blkftrace: binary tracing, synthesizing old format
Impact: new feature With this and a blkrawverify modified not to verify the sequence numbers we can start using the userspace tools to verify that the data produced with the ftrace plugin works as expected. Example: [root@f10-1 ~]# echo 1 > /sys/block/sda/sda1/trace/enable [root@f10-1 ~]# echo bin > /d/tracing/trace_options [root@f10-1 ~]# echo blk > /d/tracing/current_tracer [root@f10-1 ~]# cat /d/tracing/trace_pipe > sda1.blktrace.0 ^C [root@f10-1 ~]# ./blkrawverify --noseq sda1 Verifying sda1 CPU 0 Wrote output to sda1.verify.out [root@f10-1 ~]# cat sda1.verify.out --------------- Verifying sda1 --------------------- Summary for cpu 0: 1349 valid + 0 invalid (100.0%) processed [root@f10-1 ~]# Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'block')
-rw-r--r--block/blktrace.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/block/blktrace.c b/block/blktrace.c
index 570cd3c40bd1..4f45b343690a 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -219,9 +219,16 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
219 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION; 219 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
220 t->sequence = ++(*sequence); 220 t->sequence = ++(*sequence);
221 t->time = ktime_to_ns(ktime_get()); 221 t->time = ktime_to_ns(ktime_get());
222 t->cpu = cpu;
223 t->pid = pid;
224record_it: 222record_it:
223 /*
224 * These two are not needed in ftrace as they are in the
225 * generic trace_entry, filled by tracing_generic_entry_update,
226 * but for the trace_event->bin() synthesizer benefit we do it
227 * here too.
228 */
229 t->cpu = cpu;
230 t->pid = pid;
231
225 t->sector = sector; 232 t->sector = sector;
226 t->bytes = bytes; 233 t->bytes = bytes;
227 t->action = what; 234 t->action = what;
@@ -1086,6 +1093,7 @@ static void blk_tracer_start(struct trace_array *tr)
1086 if (blk_register_tracepoints()) 1093 if (blk_register_tracepoints())
1087 atomic_dec(&blk_probes_ref); 1094 atomic_dec(&blk_probes_ref);
1088 mutex_unlock(&blk_probe_mutex); 1095 mutex_unlock(&blk_probe_mutex);
1096 trace_flags &= ~TRACE_ITER_CONTEXT_INFO;
1089} 1097}
1090 1098
1091static int blk_tracer_init(struct trace_array *tr) 1099static int blk_tracer_init(struct trace_array *tr)
@@ -1100,6 +1108,7 @@ static int blk_tracer_init(struct trace_array *tr)
1100 1108
1101static void blk_tracer_stop(struct trace_array *tr) 1109static void blk_tracer_stop(struct trace_array *tr)
1102{ 1110{
1111 trace_flags |= TRACE_ITER_CONTEXT_INFO;
1103 mutex_lock(&blk_probe_mutex); 1112 mutex_lock(&blk_probe_mutex);
1104 if (atomic_dec_and_test(&blk_probes_ref)) 1113 if (atomic_dec_and_test(&blk_probes_ref))
1105 blk_unregister_tracepoints(); 1114 blk_unregister_tracepoints();
@@ -1147,6 +1156,9 @@ static int blk_trace_event_print(struct trace_iterator *iter, int flags)
1147 const u16 what = t->action & ((1 << BLK_TC_SHIFT) - 1); 1156 const u16 what = t->action & ((1 << BLK_TC_SHIFT) - 1);
1148 int ret; 1157 int ret;
1149 1158
1159 if (trace_print_context(iter))
1160 return TRACE_TYPE_PARTIAL_LINE;
1161
1150 if (unlikely(what == 0 || what > ARRAY_SIZE(what2act))) 1162 if (unlikely(what == 0 || what > ARRAY_SIZE(what2act)))
1151 ret = trace_seq_printf(s, "Bad pc action %x\n", what); 1163 ret = trace_seq_printf(s, "Bad pc action %x\n", what);
1152 else { 1164 else {
@@ -1159,6 +1171,28 @@ static int blk_trace_event_print(struct trace_iterator *iter, int flags)
1159 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE; 1171 return ret ? TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
1160} 1172}
1161 1173
1174static int blk_trace_synthesize_old_trace(struct trace_iterator *iter)
1175{
1176 struct trace_seq *s = &iter->seq;
1177 struct blk_io_trace *t = (struct blk_io_trace *)iter->ent;
1178 const int offset = offsetof(struct blk_io_trace, sector);
1179 struct blk_io_trace old = {
1180 .magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION,
1181 .time = ns2usecs(iter->ts),
1182 };
1183
1184 if (!trace_seq_putmem(s, &old, offset))
1185 return 0;
1186 return trace_seq_putmem(s, &t->sector,
1187 sizeof(old) - offset + t->pdu_len);
1188}
1189
1190static int blk_trace_event_print_binary(struct trace_iterator *iter, int flags)
1191{
1192 return blk_trace_synthesize_old_trace(iter) ?
1193 TRACE_TYPE_HANDLED : TRACE_TYPE_PARTIAL_LINE;
1194}
1195
1162static enum print_line_t blk_tracer_print_line(struct trace_iterator *iter) 1196static enum print_line_t blk_tracer_print_line(struct trace_iterator *iter)
1163{ 1197{
1164 const struct blk_io_trace *t; 1198 const struct blk_io_trace *t;
@@ -1200,7 +1234,7 @@ static struct trace_event trace_blk_event = {
1200 .latency_trace = blk_trace_event_print, 1234 .latency_trace = blk_trace_event_print,
1201 .raw = trace_nop_print, 1235 .raw = trace_nop_print,
1202 .hex = trace_nop_print, 1236 .hex = trace_nop_print,
1203 .binary = trace_nop_print, 1237 .binary = blk_trace_event_print_binary,
1204}; 1238};
1205 1239
1206static int __init init_blk_tracer(void) 1240static int __init init_blk_tracer(void)