Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf script: Enhance sample flags for trace begin / end

Allow for different combinations of sample flags with "trace begin" or
"trace end".

Previously, the Intel PT decoder would indicate begin / end by a branch
from / to zero. That hides useful information, in particular when a
trace ends with a call. Before remedying that, prepare 'perf script' to
display sample flags with more combinations that include trace begin /
end. In those cases display 'tr start' and 'tr end' separately.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20180920130048.31432-2-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
62cb1b88 035c450f

+27 -9
+27 -9
tools/perf/builtin-script.c
··· 1262 1262 {0, NULL} 1263 1263 }; 1264 1264 1265 + static const char *sample_flags_to_name(u32 flags) 1266 + { 1267 + int i; 1268 + 1269 + for (i = 0; sample_flags[i].name ; i++) { 1270 + if (sample_flags[i].flags == flags) 1271 + return sample_flags[i].name; 1272 + } 1273 + 1274 + return NULL; 1275 + } 1276 + 1265 1277 static int perf_sample__fprintf_flags(u32 flags, FILE *fp) 1266 1278 { 1267 1279 const char *chars = PERF_IP_FLAG_CHARS; ··· 1283 1271 char str[33]; 1284 1272 int i, pos = 0; 1285 1273 1286 - for (i = 0; sample_flags[i].name ; i++) { 1287 - if (sample_flags[i].flags == (flags & ~PERF_IP_FLAG_IN_TX)) { 1288 - name = sample_flags[i].name; 1289 - break; 1290 - } 1274 + name = sample_flags_to_name(flags & ~PERF_IP_FLAG_IN_TX); 1275 + if (name) 1276 + return fprintf(fp, " %-15s%4s ", name, in_tx ? "(x)" : ""); 1277 + 1278 + if (flags & PERF_IP_FLAG_TRACE_BEGIN) { 1279 + name = sample_flags_to_name(flags & ~(PERF_IP_FLAG_IN_TX | PERF_IP_FLAG_TRACE_BEGIN)); 1280 + if (name) 1281 + return fprintf(fp, " tr strt %-7s%4s ", name, in_tx ? "(x)" : ""); 1282 + } 1283 + 1284 + if (flags & PERF_IP_FLAG_TRACE_END) { 1285 + name = sample_flags_to_name(flags & ~(PERF_IP_FLAG_IN_TX | PERF_IP_FLAG_TRACE_END)); 1286 + if (name) 1287 + return fprintf(fp, " tr end %-7s%4s ", name, in_tx ? "(x)" : ""); 1291 1288 } 1292 1289 1293 1290 for (i = 0; i < n; i++, flags >>= 1) { ··· 1309 1288 } 1310 1289 str[pos] = 0; 1311 1290 1312 - if (name) 1313 - return fprintf(fp, " %-7s%4s ", name, in_tx ? "(x)" : ""); 1314 - 1315 - return fprintf(fp, " %-11s ", str); 1291 + return fprintf(fp, " %-19s ", str); 1316 1292 } 1317 1293 1318 1294 struct printer_data {