aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/blktrace.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2009-04-01 04:19:19 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-12 09:32:46 -0400
commit66de7792c02693b49671afe58c771fde3b092fc7 (patch)
treede50b82ef212c6f9a3f950282b45485e8d87b0a3 /kernel/trace/blktrace.c
parentb78825d608f30a47e3154ab6872a03f0de0c9d45 (diff)
blktrace: fix output of BLK_TC_PC events
BLK_TC_PC events should be treated differently with BLK_TC_FS events. Before this patch: # echo 1 > /sys/block/sda/sda1/trace/enable # echo pc > /sys/block/sda/sda1/trace/act_mask # echo blk > /debugfs/tracing/current_tracer # (generate some BLK_TC_PC events) # cat trace bash-2184 [000] 1774.275413: 8,7 I N [bash] bash-2184 [000] 1774.275435: 8,7 D N [bash] bash-2184 [000] 1774.275540: 8,7 I R [bash] bash-2184 [000] 1774.275547: 8,7 D R [bash] ksoftirqd/0-4 [000] 1774.275580: 8,7 C N 0 [0] bash-2184 [000] 1774.275648: 8,7 I R [bash] bash-2184 [000] 1774.275653: 8,7 D R [bash] ksoftirqd/0-4 [000] 1774.275682: 8,7 C N 0 [0] bash-2184 [000] 1774.275739: 8,7 I R [bash] bash-2184 [000] 1774.275744: 8,7 D R [bash] ksoftirqd/0-4 [000] 1774.275771: 8,7 C N 0 [0] bash-2184 [000] 1774.275804: 8,7 I R [bash] bash-2184 [000] 1774.275808: 8,7 D R [bash] ksoftirqd/0-4 [000] 1774.275836: 8,7 C N 0 [0] After this patch: # cat trace bash-2263 [000] 366.782149: 8,7 I N 0 (00 ..) [bash] bash-2263 [000] 366.782323: 8,7 D N 0 (00 ..) [bash] bash-2263 [000] 366.782557: 8,7 I R 8 (25 00 ..) [bash] bash-2263 [000] 366.782560: 8,7 D R 8 (25 00 ..) [bash] ksoftirqd/0-4 [000] 366.782582: 8,7 C N (25 00 ..) [0] bash-2263 [000] 366.782648: 8,7 I R 8 (5a 00 3f 00) [bash] bash-2263 [000] 366.782650: 8,7 D R 8 (5a 00 3f 00) [bash] ksoftirqd/0-4 [000] 366.782669: 8,7 C N (5a 00 3f 00) [0] bash-2263 [000] 366.782710: 8,7 I R 8 (5a 00 08 00) [bash] bash-2263 [000] 366.782713: 8,7 D R 8 (5a 00 08 00) [bash] ksoftirqd/0-4 [000] 366.782730: 8,7 C N (5a 00 08 00) [0] bash-2263 [000] 366.783375: 8,7 I R 36 (5a 00 08 00) [bash] bash-2263 [000] 366.783379: 8,7 D R 36 (5a 00 08 00) [bash] ksoftirqd/0-4 [000] 366.783404: 8,7 C N (5a 00 08 00) [0] This is what we do with PC events in user-space blktrace. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jens Axboe <jens.axboe@oracle.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <49D32387.9040106@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/blktrace.c')
-rw-r--r--kernel/trace/blktrace.c88
1 files changed, 80 insertions, 8 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index e45e1af13563..2b98195b338b 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -971,6 +971,16 @@ static inline const void *pdu_start(const struct trace_entry *ent)
971 return te_blk_io_trace(ent) + 1; 971 return te_blk_io_trace(ent) + 1;
972} 972}
973 973
974static inline u32 t_action(const struct trace_entry *ent)
975{
976 return te_blk_io_trace(ent)->action;
977}
978
979static inline u32 t_bytes(const struct trace_entry *ent)
980{
981 return te_blk_io_trace(ent)->bytes;
982}
983
974static inline u32 t_sec(const struct trace_entry *ent) 984static inline u32 t_sec(const struct trace_entry *ent)
975{ 985{
976 return te_blk_io_trace(ent)->bytes >> 9; 986 return te_blk_io_trace(ent)->bytes >> 9;
@@ -1031,25 +1041,87 @@ static int blk_log_action(struct trace_iterator *iter, const char *act)
1031 MAJOR(t->device), MINOR(t->device), act, rwbs); 1041 MAJOR(t->device), MINOR(t->device), act, rwbs);
1032} 1042}
1033 1043
1044static int blk_log_dump_pdu(struct trace_seq *s, const struct trace_entry *ent)
1045{
1046 const char *pdu_buf;
1047 int pdu_len;
1048 int i, end, ret;
1049
1050 pdu_buf = pdu_start(ent);
1051 pdu_len = te_blk_io_trace(ent)->pdu_len;
1052
1053 if (!pdu_len)
1054 return 1;
1055
1056 /* find the last zero that needs to be printed */
1057 for (end = pdu_len - 1; end >= 0; end--)
1058 if (pdu_buf[end])
1059 break;
1060 end++;
1061
1062 if (!trace_seq_putc(s, '('))
1063 return 0;
1064
1065 for (i = 0; i < pdu_len; i++) {
1066
1067 ret = trace_seq_printf(s, "%s%02x",
1068 i == 0 ? "" : " ", pdu_buf[i]);
1069 if (!ret)
1070 return ret;
1071
1072 /*
1073 * stop when the rest is just zeroes and indicate so
1074 * with a ".." appended
1075 */
1076 if (i == end && end != pdu_len - 1)
1077 return trace_seq_puts(s, " ..) ");
1078 }
1079
1080 return trace_seq_puts(s, ") ");
1081}
1082
1034static int blk_log_generic(struct trace_seq *s, const struct trace_entry *ent) 1083static int blk_log_generic(struct trace_seq *s, const struct trace_entry *ent)
1035{ 1084{
1036 char cmd[TASK_COMM_LEN]; 1085 char cmd[TASK_COMM_LEN];
1037 1086
1038 trace_find_cmdline(ent->pid, cmd); 1087 trace_find_cmdline(ent->pid, cmd);
1039 1088
1040 if (t_sec(ent)) 1089 if (t_action(ent) & BLK_TC_ACT(BLK_TC_PC)) {
1041 return trace_seq_printf(s, "%llu + %u [%s]\n", 1090 int ret;
1042 t_sector(ent), t_sec(ent), cmd); 1091
1043 return trace_seq_printf(s, "[%s]\n", cmd); 1092 ret = trace_seq_printf(s, "%u ", t_bytes(ent));
1093 if (!ret)
1094 return 0;
1095 ret = blk_log_dump_pdu(s, ent);
1096 if (!ret)
1097 return 0;
1098 return trace_seq_printf(s, "[%s]\n", cmd);
1099 } else {
1100 if (t_sec(ent))
1101 return trace_seq_printf(s, "%llu + %u [%s]\n",
1102 t_sector(ent), t_sec(ent), cmd);
1103 return trace_seq_printf(s, "[%s]\n", cmd);
1104 }
1044} 1105}
1045 1106
1046static int blk_log_with_error(struct trace_seq *s, 1107static int blk_log_with_error(struct trace_seq *s,
1047 const struct trace_entry *ent) 1108 const struct trace_entry *ent)
1048{ 1109{
1049 if (t_sec(ent)) 1110 if (t_action(ent) & BLK_TC_ACT(BLK_TC_PC)) {
1050 return trace_seq_printf(s, "%llu + %u [%d]\n", t_sector(ent), 1111 int ret;
1051 t_sec(ent), t_error(ent)); 1112
1052 return trace_seq_printf(s, "%llu [%d]\n", t_sector(ent), t_error(ent)); 1113 ret = blk_log_dump_pdu(s, ent);
1114 if (ret)
1115 return trace_seq_printf(s, "[%d]\n", t_error(ent));
1116 return 0;
1117 } else {
1118 if (t_sec(ent))
1119 return trace_seq_printf(s, "%llu + %u [%d]\n",
1120 t_sector(ent),
1121 t_sec(ent), t_error(ent));
1122 return trace_seq_printf(s, "%llu [%d]\n",
1123 t_sector(ent), t_error(ent));
1124 }
1053} 1125}
1054 1126
1055static int blk_log_remap(struct trace_seq *s, const struct trace_entry *ent) 1127static int blk_log_remap(struct trace_seq *s, const struct trace_entry *ent)