Skip to content

Commit 4eb0681

Browse files
Andi Kleenacmel
authored andcommitted
perf script: Make itrace script default to all calls
By default 'perf script' for itrace outputs sampled instructions or branches. In my experience this is confusing to users because it's hard to correlate with real program behavior. The sampling makes sense for tools like 'perf report' that actually sample to reduce the run time, but run time is normally not a problem for 'perf script'. It's better to give an accurate representation of the program flow. Default 'perf script' to output all calls for itrace. That's a much saner default. The old behavior can be still requested with 'perf script' --itrace=ibxwpe100000 v2: Fix ETM build failure v3: Really fix ETM build failure (Kim Phillips) Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Kim Phillips <kim.phillips@arm.com> Cc: Leo Yan <leo.yan@linaro.org> Link: http://lkml.kernel.org/r/20180920180540.14039-3-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent b585ebd commit 4eb0681

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

tools/perf/Documentation/itrace.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
l synthesize last branch entries (use with i or x)
1212
s skip initial number of events
1313

14-
The default is all events i.e. the same as --itrace=ibxwpe
14+
The default is all events i.e. the same as --itrace=ibxwpe,
15+
except for perf script where it is --itrace=ce
1516

16-
In addition, the period (default 100000) for instructions events
17-
can be specified in units of:
17+
In addition, the period (default 100000, except for perf script where it is 1)
18+
for instructions events can be specified in units of:
1819

1920
i instructions
2021
t ticks

tools/perf/builtin-script.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3131,7 +3131,10 @@ int cmd_script(int argc, const char **argv)
31313131
char *rec_script_path = NULL;
31323132
char *rep_script_path = NULL;
31333133
struct perf_session *session;
3134-
struct itrace_synth_opts itrace_synth_opts = { .set = false, };
3134+
struct itrace_synth_opts itrace_synth_opts = {
3135+
.set = false,
3136+
.default_no_sample = true,
3137+
};
31353138
char *script_path = NULL;
31363139
const char **__argv;
31373140
int i, j, err = 0;

tools/perf/util/auxtrace.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -962,16 +962,23 @@ s64 perf_event__process_auxtrace(struct perf_session *session,
962962
#define PERF_ITRACE_DEFAULT_LAST_BRANCH_SZ 64
963963
#define PERF_ITRACE_MAX_LAST_BRANCH_SZ 1024
964964

965-
void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts)
965+
void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts,
966+
bool no_sample)
966967
{
967-
synth_opts->instructions = true;
968968
synth_opts->branches = true;
969969
synth_opts->transactions = true;
970970
synth_opts->ptwrites = true;
971971
synth_opts->pwr_events = true;
972972
synth_opts->errors = true;
973-
synth_opts->period_type = PERF_ITRACE_DEFAULT_PERIOD_TYPE;
974-
synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
973+
if (no_sample) {
974+
synth_opts->period_type = PERF_ITRACE_PERIOD_INSTRUCTIONS;
975+
synth_opts->period = 1;
976+
synth_opts->calls = true;
977+
} else {
978+
synth_opts->instructions = true;
979+
synth_opts->period_type = PERF_ITRACE_DEFAULT_PERIOD_TYPE;
980+
synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
981+
}
975982
synth_opts->callchain_sz = PERF_ITRACE_DEFAULT_CALLCHAIN_SZ;
976983
synth_opts->last_branch_sz = PERF_ITRACE_DEFAULT_LAST_BRANCH_SZ;
977984
synth_opts->initial_skip = 0;
@@ -999,7 +1006,7 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str,
9991006
}
10001007

10011008
if (!str) {
1002-
itrace_synth_opts__set_default(synth_opts);
1009+
itrace_synth_opts__set_default(synth_opts, false);
10031010
return 0;
10041011
}
10051012

tools/perf/util/auxtrace.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ enum itrace_period_type {
5858
/**
5959
* struct itrace_synth_opts - AUX area tracing synthesis options.
6060
* @set: indicates whether or not options have been set
61+
* @default_no_sample: Default to no sampling.
6162
* @inject: indicates the event (not just the sample) must be fully synthesized
6263
* because 'perf inject' will write it out
6364
* @instructions: whether to synthesize 'instructions' events
@@ -82,6 +83,7 @@ enum itrace_period_type {
8283
*/
8384
struct itrace_synth_opts {
8485
bool set;
86+
bool default_no_sample;
8587
bool inject;
8688
bool instructions;
8789
bool branches;
@@ -528,7 +530,8 @@ int perf_event__process_auxtrace_error(struct perf_session *session,
528530
union perf_event *event);
529531
int itrace_parse_synth_opts(const struct option *opt, const char *str,
530532
int unset);
531-
void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts);
533+
void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts,
534+
bool no_sample);
532535

533536
size_t perf_event__fprintf_auxtrace_error(union perf_event *event, FILE *fp);
534537
void perf_session__auxtrace_error_inc(struct perf_session *session,

tools/perf/util/cs-etm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,8 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
14321432
if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
14331433
etm->synth_opts = *session->itrace_synth_opts;
14341434
} else {
1435-
itrace_synth_opts__set_default(&etm->synth_opts);
1435+
itrace_synth_opts__set_default(&etm->synth_opts,
1436+
session->itrace_synth_opts->default_no_sample);
14361437
etm->synth_opts.callchain = false;
14371438
}
14381439

tools/perf/util/intel-bts.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,8 @@ int intel_bts_process_auxtrace_info(union perf_event *event,
910910
if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
911911
bts->synth_opts = *session->itrace_synth_opts;
912912
} else {
913-
itrace_synth_opts__set_default(&bts->synth_opts);
913+
itrace_synth_opts__set_default(&bts->synth_opts,
914+
session->itrace_synth_opts->default_no_sample);
914915
if (session->itrace_synth_opts)
915916
bts->synth_opts.thread_stack =
916917
session->itrace_synth_opts->thread_stack;

tools/perf/util/intel-pt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,8 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
25592559
if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
25602560
pt->synth_opts = *session->itrace_synth_opts;
25612561
} else {
2562-
itrace_synth_opts__set_default(&pt->synth_opts);
2562+
itrace_synth_opts__set_default(&pt->synth_opts,
2563+
session->itrace_synth_opts->default_no_sample);
25632564
if (use_browser != -1) {
25642565
pt->synth_opts.branches = false;
25652566
pt->synth_opts.callchain = true;

0 commit comments

Comments
 (0)