Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1290026 > unrolled thread

[PATCH] perf, tools: Disable branch flags/cycles for --callgraph lbr

Started byAndi Kleen <andi@firstfloor.org>
First post2015-12-12 01:20 +0100
Last post2015-12-18 09:50 +0100
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf, tools: Disable branch flags/cycles for --callgraph lbr Andi Kleen <andi@firstfloor.org> - 2015-12-12 01:20 +0100
    Re: [PATCH] perf, tools: Disable branch flags/cycles for --callgraph  lbr Jiri Olsa <jolsa@redhat.com> - 2015-12-14 11:00 +0100
      Re: [PATCH] perf, tools: Disable branch flags/cycles for --callgraph  lbr Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-12-14 16:20 +0100
    [tip:perf/core] perf evsel: Disable branch flags/  cycles for --callgraph lbr tip-bot for Andi Kleen <tipbot@zytor.com> - 2015-12-18 09:50 +0100

#1290026 — [PATCH] perf, tools: Disable branch flags/cycles for --callgraph lbr

FromAndi Kleen <andi@firstfloor.org>
Date2015-12-12 01:20 +0100
Subject[PATCH] perf, tools: Disable branch flags/cycles for --callgraph lbr
Message-ID<qEG4N-3aW-3@gated-at.bofh.it>
From: Andi Kleen <ak@linux.intel.com>

[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.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/util/evsel.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 47f0330..544e440 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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:
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1291018 — Re: [PATCH] perf, tools: Disable branch flags/cycles for --callgraph lbr

FromJiri Olsa <jolsa@redhat.com>
Date2015-12-14 11:00 +0100
SubjectRe: [PATCH] perf, tools: Disable branch flags/cycles for --callgraph lbr
Message-ID<qFy5c-4ms-1@gated-at.bofh.it>
In reply to#1290026
On Fri, Dec 11, 2015 at 04:12:24PM -0800, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> [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.
> Signed-off-by: Andi Kleen <ak@linux.intel.com>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1291262 — Re: [PATCH] perf, tools: Disable branch flags/cycles for --callgraph lbr

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-12-14 16:20 +0100
SubjectRe: [PATCH] perf, tools: Disable branch flags/cycles for --callgraph lbr
Message-ID<qFD4S-7Rv-27@gated-at.bofh.it>
In reply to#1291018
Em Mon, Dec 14, 2015 at 10:55:38AM +0100, Jiri Olsa escreveu:
> On Fri, Dec 11, 2015 at 04:12:24PM -0800, Andi Kleen wrote:
> > From: Andi Kleen <ak@linux.intel.com>
> > 
> > [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.
> > Signed-off-by: Andi Kleen <ak@linux.intel.com>
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied to perf/core.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1294516 — [tip:perf/core] perf evsel: Disable branch flags/ cycles for --callgraph lbr

Fromtip-bot for Andi Kleen <tipbot@zytor.com>
Date2015-12-18 09:50 +0100
Subject[tip:perf/core] perf evsel: Disable branch flags/ cycles for --callgraph lbr
Message-ID<qGYTE-3jm-25@gated-at.bofh.it>
In reply to#1290026
Commit-ID:  bd0f889536f80630c1c4a414f2de90744d2c87d0
Gitweb:     http://git.kernel.org/tip/bd0f889536f80630c1c4a414f2de90744d2c87d0
Author:     Andi Kleen <ak@linux.intel.com>
AuthorDate: Fri, 11 Dec 2015 16:12:24 -0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1449879144-29074-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 47f0330..544e440 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web