public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jin Yao <yao.jin@linux.intel.com>
To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
	mingo@redhat.com, alexander.shishkin@linux.intel.com
Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com,
	kan.liang@intel.com, yao.jin@intel.com,
	Jin Yao <yao.jin@linux.intel.com>
Subject: [PATCH v1 3/9] perf diff: Check if all data files with branch stacks
Date: Mon, 20 May 2019 21:27:50 +0800	[thread overview]
Message-ID: <1558358876-32211-4-git-send-email-yao.jin@linux.intel.com> (raw)
In-Reply-To: <1558358876-32211-1-git-send-email-yao.jin@linux.intel.com>

We will expand perf diff to support diff cycles of individual programs
blocks, so it requires all data files having branch stacks.

This patch checks HEADER_BRANCH_STACK in header, and only set the flag
has_br_stack when HEADER_BRANCH_STACK are set in all data files.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/builtin-diff.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 6e79207..6023f8c 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -32,6 +32,7 @@ struct perf_diff {
 	struct perf_time_interval	*ptime_range;
 	int				 range_size;
 	int				 range_num;
+	bool				 has_br_stack;
 };
 
 /* Diff command specific HPP columns. */
@@ -873,12 +874,41 @@ static int parse_time_str(struct data__file *d, char *abstime_ostr,
 	return ret;
 }
 
+static int check_file_brstack(void)
+{
+	struct data__file *d;
+	bool has_br_stack;
+	int i;
+
+	data__for_each_file(i, d) {
+		d->session = perf_session__new(&d->data, false, &pdiff.tool);
+		if (!d->session) {
+			pr_err("Failed to open %s\n", d->data.path);
+			return -1;
+		}
+
+		has_br_stack = perf_header__has_feat(&d->session->header,
+						     HEADER_BRANCH_STACK);
+		perf_session__delete(d->session);
+		if (!has_br_stack)
+			return 0;
+	}
+
+	/* Set only all files having branch stacks */
+	pdiff.has_br_stack = true;
+	return 0;
+}
+
 static int __cmd_diff(void)
 {
 	struct data__file *d;
 	int ret, i;
 	char *abstime_ostr, *abstime_tmp;
 
+	ret = check_file_brstack();
+	if (ret)
+		return ret;
+
 	ret = abstime_str_dup(&abstime_ostr);
 	if (ret)
 		return ret;
-- 
2.7.4


  parent reply	other threads:[~2019-05-20  5:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20 13:27 [PATCH v1 0/9] perf diff: diff cycles at basic block level Jin Yao
2019-05-20 13:27 ` [PATCH v1 1/9] perf util: Create block_info structure Jin Yao
2019-05-20 13:27 ` [PATCH v1 2/9] perf util: Add block_info in hist_entry Jin Yao
2019-05-20 13:27 ` Jin Yao [this message]
2019-05-20 13:27 ` [PATCH v1 4/9] perf diff: Get a list of symbols(functions) Jin Yao
2019-05-20 13:27 ` [PATCH v1 5/9] perf diff: Use hists to manage basic blocks Jin Yao
2019-05-20 13:27 ` [PATCH v1 6/9] perf diff: Link same basic blocks among different data files Jin Yao
2019-05-20 13:27 ` [PATCH v1 7/9] perf diff: Compute cycles diff of basic blocks Jin Yao
2019-05-20 13:27 ` [PATCH v1 8/9] perf diff: Print the basic block cycles diff Jin Yao
2019-05-22 14:04   ` Jiri Olsa
2019-05-24  0:39     ` Jin, Yao
2019-05-20 13:27 ` [PATCH v1 9/9] perf diff: Documentation --basic-block option Jin Yao

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=1558358876-32211-4-git-send-email-yao.jin@linux.intel.com \
    --to=yao.jin@linux.intel.com \
    --cc=Linux-kernel@vger.kernel.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=yao.jin@intel.com \
    /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