Skip to content

Commit cb97143

Browse files
ahunter6acmel
authored andcommitted
perf auxtrace: Add optional error flags to the itrace 'e' option
Allow the 'e' option to be followed by flags which will affect what errors will or will not be reported. Each flag must be preceded by either '+' or '-'. The flags are: o overflow l trace data lost Signed-off-by: Adrian Hunter <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Cc: Jiri Olsa <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 1e8f786 commit cb97143

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

tools/perf/Documentation/itrace.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@
4747
--itrace=i0nss1000000
4848

4949
skips the first million instructions.
50+
51+
The 'e' option may be followed by flags which affect what errors will or
52+
will not be reported. Each flag must be preceded by either '+' or '-'.
53+
The flags are:
54+
o overflow
55+
l trace data lost

tools/perf/util/auxtrace.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,47 @@ void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts,
13491349
synth_opts->initial_skip = 0;
13501350
}
13511351

1352+
static int get_flag(const char **ptr, unsigned int *flags)
1353+
{
1354+
while (1) {
1355+
char c = **ptr;
1356+
1357+
if (c >= 'a' && c <= 'z') {
1358+
*flags |= 1 << (c - 'a');
1359+
++*ptr;
1360+
return 0;
1361+
} else if (c == ' ') {
1362+
++*ptr;
1363+
continue;
1364+
} else {
1365+
return -1;
1366+
}
1367+
}
1368+
}
1369+
1370+
static int get_flags(const char **ptr, unsigned int *plus_flags, unsigned int *minus_flags)
1371+
{
1372+
while (1) {
1373+
switch (**ptr) {
1374+
case '+':
1375+
++*ptr;
1376+
if (get_flag(ptr, plus_flags))
1377+
return -1;
1378+
break;
1379+
case '-':
1380+
++*ptr;
1381+
if (get_flag(ptr, minus_flags))
1382+
return -1;
1383+
break;
1384+
case ' ':
1385+
++*ptr;
1386+
break;
1387+
default:
1388+
return 0;
1389+
}
1390+
}
1391+
}
1392+
13521393
/*
13531394
* Please check tools/perf/Documentation/perf-script.txt for information
13541395
* about the options parsed here, which is introduced after this cset,
@@ -1436,6 +1477,9 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str,
14361477
break;
14371478
case 'e':
14381479
synth_opts->errors = true;
1480+
if (get_flags(&p, &synth_opts->error_plus_flags,
1481+
&synth_opts->error_minus_flags))
1482+
goto out_err;
14391483
break;
14401484
case 'd':
14411485
synth_opts->log = true;

tools/perf/util/auxtrace.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ enum itrace_period_type {
5555
PERF_ITRACE_PERIOD_NANOSECS,
5656
};
5757

58+
#define AUXTRACE_ERR_FLG_OVERFLOW (1 << ('o' - 'a'))
59+
#define AUXTRACE_ERR_FLG_DATA_LOST (1 << ('l' - 'a'))
60+
5861
/**
5962
* struct itrace_synth_opts - AUX area tracing synthesis options.
6063
* @set: indicates whether or not options have been set
@@ -91,6 +94,8 @@ enum itrace_period_type {
9194
* @cpu_bitmap: CPUs for which to synthesize events, or NULL for all
9295
* @ptime_range: time intervals to trace or NULL
9396
* @range_num: number of time intervals to trace
97+
* @error_plus_flags: flags to affect what errors are reported
98+
* @error_minus_flags: flags to affect what errors are reported
9499
*/
95100
struct itrace_synth_opts {
96101
bool set;
@@ -124,6 +129,8 @@ struct itrace_synth_opts {
124129
unsigned long *cpu_bitmap;
125130
struct perf_time_interval *ptime_range;
126131
int range_num;
132+
unsigned int error_plus_flags;
133+
unsigned int error_minus_flags;
127134
};
128135

129136
/**
@@ -613,7 +620,10 @@ bool auxtrace__evsel_is_auxtrace(struct perf_session *session,
613620
" p: synthesize power events\n" \
614621
" o: synthesize other events recorded due to the use\n" \
615622
" of aux-output (refer to perf record)\n" \
616-
" e: synthesize error events\n" \
623+
" e[flags]: synthesize error events\n" \
624+
" each flag must be preceded by + or -\n" \
625+
" error flags are: o (overflow)\n" \
626+
" l (data lost)\n" \
617627
" d: create a debug log\n" \
618628
" f: synthesize first level cache events\n" \
619629
" m: synthesize last level cache events\n" \

0 commit comments

Comments
 (0)