public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Stephane Eranian <eranian@google.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, eranian@google.com, hpa@zytor.com,
	mingo@redhat.com, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perf/hw-branch-sampling] perf record: Add HEADER_BRANCH_STACK tag
Date: Fri, 9 Mar 2012 05:34:07 -0800	[thread overview]
Message-ID: <tip-330aa675b4f92a422cb6d3acbbfd16a628017520@git.kernel.org> (raw)
In-Reply-To: <1331246868-19905-3-git-send-email-eranian@google.com>

Commit-ID:  330aa675b4f92a422cb6d3acbbfd16a628017520
Gitweb:     http://git.kernel.org/tip/330aa675b4f92a422cb6d3acbbfd16a628017520
Author:     Stephane Eranian <eranian@google.com>
AuthorDate: Thu, 8 Mar 2012 23:47:46 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 9 Mar 2012 08:26:08 +0100

perf record: Add HEADER_BRANCH_STACK tag

This patch adds a new feature bit, namely,
HEADER_BRANCH_STACK.  When present, it indicates
that sample records may contain branch stack.

This could be useful to a viewer to switch to
branch mode without having to parse all the
samples or without a specific cmdline option.

This will be used in a subsequent patch to
enhance perf report with branch stacks.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: peterz@infradead.org
Cc: acme@redhat.com
Cc: asharma@fb.com
Cc: ravitillo@lbl.gov
Cc: vweaver1@eecs.utk.edu
Cc: khandual@linux.vnet.ibm.com
Cc: dsahern@gmail.com
Link: http://lkml.kernel.org/r/1331246868-19905-3-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/builtin-record.c |    3 +++
 tools/perf/util/header.c    |   13 +++++++++++++
 tools/perf/util/header.h    |    2 +-
 3 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index a7c53a9..be4e1ee 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -473,6 +473,9 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
 	if (!have_tracepoints(&evsel_list->entries))
 		perf_header__clear_feat(&session->header, HEADER_TRACE_INFO);
 
+	if (!rec->opts.branch_stack)
+		perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
+
 	if (!rec->file_new) {
 		err = perf_session__read_header(session, output);
 		if (err < 0)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c851495..0d9b6da 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1023,6 +1023,12 @@ write_it:
 	return do_write_string(fd, buffer);
 }
 
+static int write_branch_stack(int fd __used, struct perf_header *h __used,
+		       struct perf_evlist *evlist __used)
+{
+	return 0;
+}
+
 static void print_hostname(struct perf_header *ph, int fd, FILE *fp)
 {
 	char *str = do_read_string(fd, ph);
@@ -1315,6 +1321,12 @@ static void print_cpuid(struct perf_header *ph, int fd, FILE *fp)
 	free(str);
 }
 
+static void print_branch_stack(struct perf_header *ph __used, int fd __used,
+			       FILE *fp)
+{
+	fprintf(fp, "# contains samples with branch stack\n");
+}
+
 static int __event_process_build_id(struct build_id_event *bev,
 				    char *filename,
 				    struct perf_session *session)
@@ -1519,6 +1531,7 @@ static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
 	FEAT_OPA(HEADER_CMDLINE,	cmdline),
 	FEAT_OPF(HEADER_CPU_TOPOLOGY,	cpu_topology),
 	FEAT_OPF(HEADER_NUMA_TOPOLOGY,	numa_topology),
+	FEAT_OPA(HEADER_BRANCH_STACK,	branch_stack),
 };
 
 struct header_print_data {
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index e68f617..21a6be0 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -27,7 +27,7 @@ enum {
 	HEADER_EVENT_DESC,
 	HEADER_CPU_TOPOLOGY,
 	HEADER_NUMA_TOPOLOGY,
-
+	HEADER_BRANCH_STACK,
 	HEADER_LAST_FEATURE,
 	HEADER_FEAT_BITS	= 256,
 };

  reply	other threads:[~2012-03-09 13:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-08 22:47 [PATCH 0/4] perf tools: improve branch stack sampling Stephane Eranian
2012-03-08 22:47 ` [PATCH 1/4] perf record: provide default branch stack sampling mode option Stephane Eranian
2012-03-09 13:33   ` [tip:perf/hw-branch-sampling] perf record: Provide " tip-bot for Stephane Eranian
2012-03-08 22:47 ` [PATCH 2/4] perf record: add HEADER_BRANCH_STACK tag Stephane Eranian
2012-03-09 13:34   ` tip-bot for Stephane Eranian [this message]
2012-03-08 22:47 ` [PATCH 3/4] perf report: auto-detect branch stack sampling mode Stephane Eranian
2012-03-09 13:34   ` [tip:perf/hw-branch-sampling] perf report: Auto-detect " tip-bot for Stephane Eranian
2012-03-08 22:47 ` [PATCH 4/4] perf report: enable TUI in branch view mode Stephane Eranian
2012-03-09 13:35   ` [tip:perf/hw-branch-sampling] perf report: Enable " tip-bot for Stephane Eranian
2012-03-09  9:48 ` [PATCH 0/4] perf tools: improve branch stack sampling Ingo Molnar

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=tip-330aa675b4f92a422cb6d3acbbfd16a628017520@git.kernel.org \
    --to=eranian@google.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox