perf, tools: Disable branch flags/cycles for --callgraph lbr
PATCH 1/1 perf, tools: Disable branch flags/cycles for --callgraph lbr
From: Andi Kleen <[email protected]>
[The kernel patch needed for this is in tip now (b16a5b52eb9 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.
--- tools/perf/util/evsel.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +13 -1
@@ -36,6 +36,7 @@ static struct {bool cloexec;bool clockid;bool clockid_wrong; +bool lbr_flags; } perf_missing_features;static clockid_t clockid;
@@ -574,7 +575,9 @@ perf_evsel__config_callgraph(struct perf_evsel *evsel, }else {perf_evsel__set_sample_bit (evsel,BRANCH_STACK ); 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 pr_warning("Cannot use LBR callstack with branch stack. "
@@ -1337,6 +1340,9 @@ fallback_missing_features: evsel->attr.mmap2 =0 ;if (perf_missing_features.exclude_guest) 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:if (perf_missing_features.sample_id_all) evsel->attr.sample_id_all =0 ;
@@ -1455,6 +1461,12 @@ try_fallback: }else if (!perf_missing_features.sample_id_all) { perf_missing_features.sample_id_all = true; 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:
Signature · 1 line
2.4.3
Quoted 10 lines · Andi Kleen
From: Andi Kleen <[email protected]>
[The kernel patch needed for this is in tip now (
b16a5b52eb9perf/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.
Quoted 7 lines
When the kernel doesn't support the new flags they are automatically cleared in the fallback code.
v2: Switch to use
branch_sample_typeinstead ofsample_type. Adjust description.
Fix the fallback logic.Signed-off-by Andi Kleen <[email protected]>
thanks,
jirka
Em Mon, Dec 14, 2015 at 10:55:38AM +0100, Jiri Olsa escreveu:
Quoted 14 lines · Andi Kleen
Quoted 13 lines
From: Andi Kleen <[email protected]>
[The kernel patch needed for this is in tip now (
b16a5b52eb9perf/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.
Quoted 6 lines
Quoted 4 lines
v2: Switch to use
branch_sample_typeinstead ofsample_type. Adjust description.
Fix the fallback logic.Signed-off-by Andi Kleen <[email protected]>Acked-by Jiri Olsa <[email protected]>
Thanks, applied to perf/core.
- Arnaldo
tip-bot for Andi Kleen
merge bot[tip:perf/core] perf evsel: Disable branch flags/ cycles for --callgraph lbr
In reply to Andi Kleenperf evsel: Disable branch flags/cycles for --callgraph lbr
Commit-ID: bd0f889536f80630c1c4a414f2de90744d2c87d0 Gitweb: http://git.kernel.org/tip/bd0f889536f80630c1c4a414f2de90744d2c87d0 Author: Andi Kleen <[email protected]> AuthorDate: Fri, 11 Dec 2015 16:12:24 -0800 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 14 Dec 2015 12:11:22 -0300
perf evsel: Disable branch flags/cycles for --callgraph lbr
[The kernel patch needed for this is in tip now (b16a5b52eb9 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.
--- tools/perf/util/evsel.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +13 -1
@@ -36,6 +36,7 @@ static struct {bool cloexec;bool clockid;bool clockid_wrong; +bool lbr_flags; } perf_missing_features;static clockid_t clockid;
@@ -574,7 +575,9 @@ perf_evsel__config_callgraph(struct perf_evsel *evsel, }else {perf_evsel__set_sample_bit (evsel,BRANCH_STACK ); 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 pr_warning("Cannot use LBR callstack with branch stack. "
@@ -1337,6 +1340,9 @@ fallback_missing_features: evsel->attr.mmap2 =0 ;if (perf_missing_features.exclude_guest) 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:if (perf_missing_features.sample_id_all) evsel->attr.sample_id_all =0 ;
@@ -1455,6 +1461,12 @@ try_fallback: }else if (!perf_missing_features.sample_id_all) { perf_missing_features.sample_id_all = true; 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: