Commit bd0f8895 authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo

perf evsel: Disable branch flags/cycles for --callgraph lbr

[The kernel patch needed for this is in tip now (b16a5b52 perf/x86:
Add option to disable ...) So this user tools patch to make use of it
should be merged now]

Automatically disable collecting branch flags and cycles with
--call-graph lbr. This allows avoiding a bunch of extra MSR
reads in the PMI on Skylake.

When the kernel doesn't support the new flags they are automatically
cleared in the fallback code.

v2: Switch to use branch_sample_type instead of sample_type.
Adjust description.
Fix the fallback logic.
Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1449879144-29074-1-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent abd82868
...@@ -36,6 +36,7 @@ static struct { ...@@ -36,6 +36,7 @@ static struct {
bool cloexec; bool cloexec;
bool clockid; bool clockid;
bool clockid_wrong; bool clockid_wrong;
bool lbr_flags;
} perf_missing_features; } perf_missing_features;
static clockid_t clockid; static clockid_t clockid;
...@@ -574,7 +575,9 @@ perf_evsel__config_callgraph(struct perf_evsel *evsel, ...@@ -574,7 +575,9 @@ perf_evsel__config_callgraph(struct perf_evsel *evsel,
} else { } else {
perf_evsel__set_sample_bit(evsel, BRANCH_STACK); perf_evsel__set_sample_bit(evsel, BRANCH_STACK);
attr->branch_sample_type = PERF_SAMPLE_BRANCH_USER | attr->branch_sample_type = PERF_SAMPLE_BRANCH_USER |
PERF_SAMPLE_BRANCH_CALL_STACK; PERF_SAMPLE_BRANCH_CALL_STACK |
PERF_SAMPLE_BRANCH_NO_CYCLES |
PERF_SAMPLE_BRANCH_NO_FLAGS;
} }
} else } else
pr_warning("Cannot use LBR callstack with branch stack. " pr_warning("Cannot use LBR callstack with branch stack. "
...@@ -1337,6 +1340,9 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, ...@@ -1337,6 +1340,9 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
evsel->attr.mmap2 = 0; evsel->attr.mmap2 = 0;
if (perf_missing_features.exclude_guest) if (perf_missing_features.exclude_guest)
evsel->attr.exclude_guest = evsel->attr.exclude_host = 0; evsel->attr.exclude_guest = evsel->attr.exclude_host = 0;
if (perf_missing_features.lbr_flags)
evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS |
PERF_SAMPLE_BRANCH_NO_CYCLES);
retry_sample_id: retry_sample_id:
if (perf_missing_features.sample_id_all) if (perf_missing_features.sample_id_all)
evsel->attr.sample_id_all = 0; evsel->attr.sample_id_all = 0;
...@@ -1455,6 +1461,12 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, ...@@ -1455,6 +1461,12 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
} else if (!perf_missing_features.sample_id_all) { } else if (!perf_missing_features.sample_id_all) {
perf_missing_features.sample_id_all = true; perf_missing_features.sample_id_all = true;
goto retry_sample_id; goto retry_sample_id;
} else if (!perf_missing_features.lbr_flags &&
(evsel->attr.branch_sample_type &
(PERF_SAMPLE_BRANCH_NO_CYCLES |
PERF_SAMPLE_BRANCH_NO_FLAGS))) {
perf_missing_features.lbr_flags = true;
goto fallback_missing_features;
} }
out_close: out_close:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment