All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: acme@kernel.org
Cc: jolsa@redhat.com, namhyung@kernel.org, eranian@google.com,
	linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 09/11] perf, tools, top: Add branch annotation code to top
Date: Wed, 27 May 2015 10:51:52 -0700	[thread overview]
Message-ID: <1432749114-904-10-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1432749114-904-1-git-send-email-andi@firstfloor.org>

From: Andi Kleen <ak@linux.intel.com>

Now that we can process branch data in annotate it makes sense to support
enabling branch recording from top too. Most of the code needed for
this is already in shared code with report. But we need to add:

- The option parsing code (using shared code from the previous patch)
- Document the options
- Set up the IPC/cycles accounting state in the top session
- Call the accounting code in the hist iter callback

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/Documentation/perf-top.txt | 21 +++++++++++++++++++++
 tools/perf/builtin-top.c              | 10 +++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 9e5b07eb..fc2bffd 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -202,6 +202,27 @@ Default is to monitor all CPUS.
 	readability.  0 means no limit (default behavior).
 
 
+-b::
+--branch-any::
+	Enable taken branch stack sampling. Any type of taken branch may be sampled.
+	This is a shortcut for --branch-filter any. See --branch-filter for more infos.
+
+-j::
+--branch-filter::
+	Enable taken branch stack sampling. Each sample captures a series of consecutive
+	taken branches. The number of branches captured with each sample depends on the
+	underlying hardware, the type of branches of interest, and the executed code.
+	It is possible to select the types of branches captured by enabling filters.
+	For a full list of modifiers please see the perf record manpage.
+
+	The option requires at least one branch type among any, any_call, any_ret, ind_call, cond.
+	The privilege levels may be omitted, in which case, the privilege levels of the associated
+	event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege
+	levels are subject to permissions.  When sampling on multiple events, branch stack sampling
+	is enabled for all the sampling events. The sampled branch type is the same for all events.
+	The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
+	Note that this feature may not be available on all processors.
+
 INTERACTIVE PROMPTING KEYS
 --------------------------
 
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index a193517..b299ce4 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -40,6 +40,7 @@
 #include "util/xyarray.h"
 #include "util/sort.h"
 #include "util/intlist.h"
+#include "util/branch.h"
 #include "arch/common.h"
 
 #include "util/debug.h"
@@ -687,6 +688,8 @@ static int hist_iter__top_callback(struct hist_entry_iter *iter,
 		perf_top__record_precise_ip(top, he, evsel->idx, ip);
 	}
 
+	hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
+		     !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY));
 	return 0;
 }
 
@@ -923,7 +926,6 @@ static int perf_top__setup_sample_type(struct perf_top *top __maybe_unused)
 			return -EINVAL;
 		}
 	}
-
 	return 0;
 }
 
@@ -1159,6 +1161,12 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str,
 		   "width[,width...]",
 		   "don't try to adjust column width, use these fixed values"),
+	OPT_CALLBACK_NOOPT('b', "branch-any", &opts->branch_stack,
+		     "branch any", "sample any taken branches",
+		     parse_branch_stack),
+	OPT_CALLBACK('j', "branch-filter", &opts->branch_stack,
+		     "branch filter mask", "branch stack filter modes",
+		     parse_branch_stack),
 	OPT_END()
 	};
 	const char * const top_usage[] = {
-- 
2.1.0


  parent reply	other threads:[~2015-05-27 17:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 17:51 Cycles annotation support for perf tools v2 Andi Kleen
2015-05-27 17:51 ` [PATCH 01/11] perf, tools: Add tools support for cycles, weight branch_info field Andi Kleen
2015-06-01 14:16   ` Jiri Olsa
2015-05-27 17:51 ` [PATCH 02/11] perf, tools, report: Add flag for non ANY branch mode Andi Kleen
2015-06-01 14:16   ` Jiri Olsa
2015-05-27 17:51 ` [PATCH 03/11] perf, tools: Add symbol__get_annotation Andi Kleen
2015-05-28  9:32   ` [tip:perf/core] perf annotation: " tip-bot for Andi Kleen
2015-06-01 14:17   ` [PATCH 03/11] perf, tools: " Jiri Olsa
2015-05-27 17:51 ` [PATCH 04/11] perf, tools, report: Add infrastructure for a cycles histogram Andi Kleen
2015-06-01 14:19   ` Jiri Olsa
2015-05-27 17:51 ` [PATCH 05/11] perf, tools, report: Add processing for cycle histograms Andi Kleen
2015-06-01 14:10   ` Jiri Olsa
2015-05-27 17:51 ` [PATCH 06/11] perf, tools: Compute IPC and basic block cycles for annotate Andi Kleen
2015-05-27 17:51 ` [PATCH 07/11] perf, tools, annotate: Finally display IPC and cycle accounting Andi Kleen
2015-05-27 17:51 ` [PATCH 08/11] perf, tools, report: Move branch option parsing to own file Andi Kleen
2015-05-28  9:32   ` [tip:perf/core] perf tools: " tip-bot for Andi Kleen
2015-06-01 14:20   ` [PATCH 08/11] perf, tools, report: " Jiri Olsa
2015-05-27 17:51 ` Andi Kleen [this message]
2015-05-27 17:51 ` [PATCH 10/11] perf, tools, report: Display cycles in branch sort mode Andi Kleen
2015-05-27 17:51 ` [PATCH 11/11] test patch: Add fake branch cycles to input data in report/top Andi Kleen
2015-06-01 14:21 ` Cycles annotation support for perf tools v2 Jiri Olsa
2015-06-01 14:43   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432749114-904-10-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.