All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] perf report: Fix a no annotate browser displayed issue
@ 2017-12-26 10:42 Jin Yao
  2018-01-04 18:45 ` Arnaldo Carvalho de Melo
  2018-01-11  6:21 ` [tip:perf/core] " tip-bot for Jin Yao
  0 siblings, 2 replies; 3+ messages in thread
From: Jin Yao @ 2017-12-26 10:42 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

v2:
--
Fix a crash bug when perform 'perf report --stdio'.

The reason is that we init the symbol annotation only in browser mode,
it doesn't allocate/init resources for stdio mode.

So now in hist_iter__branch_callback(), it will return directly if it's
not in browser mode.

initial post
------------
When enabling '-b' option in perf record, for example,

perf record -b ...
perf report

and then browsing the annotate browser from perf report, it would
be failed (annotate browser can't be displayed).

It's because the '.add_entry_cb' op of struct report is overwritten
by hist_iter__branch_callback() in builtin-report.c. But this function
doesn't do something like mapping symbols and sources. So next,
do_annotate() will return directly.

        notes = symbol__annotation(act->ms.sym);
        if (!notes->src)
                return 0;

This patch adds the lost code to hist_iter__branch_callback (
refer to hist_iter__report_callback).

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

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index eb9ce63..07827cd 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -162,12 +162,28 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter,
 	struct hist_entry *he = iter->he;
 	struct report *rep = arg;
 	struct branch_info *bi;
+	struct perf_sample *sample = iter->sample;
+	struct perf_evsel *evsel = iter->evsel;
+	int err;
+
+	if (!ui__has_annotation())
+		return 0;
+
+	hist__account_cycles(sample->branch_stack, al, sample,
+			     rep->nonany_branch_mode);
 
 	bi = he->branch_info;
+	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
+	if (err)
+		goto out;
+
+	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
+
 	branch_type_count(&rep->brtype_stat, &bi->flags,
 			  bi->from.addr, bi->to.addr);
 
-	return 0;
+out:
+	return err;
 }
 
 static int process_sample_event(struct perf_tool *tool,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] perf report: Fix a no annotate browser displayed issue
  2017-12-26 10:42 [PATCH v2] perf report: Fix a no annotate browser displayed issue Jin Yao
@ 2018-01-04 18:45 ` Arnaldo Carvalho de Melo
  2018-01-11  6:21 ` [tip:perf/core] " tip-bot for Jin Yao
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-01-04 18:45 UTC (permalink / raw)
  To: Jin Yao
  Cc: jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin

Em Tue, Dec 26, 2017 at 06:42:43PM +0800, Jin Yao escreveu:
> v2:
> --
> Fix a crash bug when perform 'perf report --stdio'.
> 
> The reason is that we init the symbol annotation only in browser mode,
> it doesn't allocate/init resources for stdio mode.
> 
> So now in hist_iter__branch_callback(), it will return directly if it's
> not in browser mode.

Thanks, tested and applied!

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/core] perf report: Fix a no annotate browser displayed issue
  2017-12-26 10:42 [PATCH v2] perf report: Fix a no annotate browser displayed issue Jin Yao
  2018-01-04 18:45 ` Arnaldo Carvalho de Melo
@ 2018-01-11  6:21 ` tip-bot for Jin Yao
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Jin Yao @ 2018-01-11  6:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, kan.liang, ak, hpa, tglx, alexander.shishkin, mingo,
	acme, jolsa, linux-kernel, yao.jin

Commit-ID:  40c39e3046411f84bab82f66783ff3593e2bcd9b
Gitweb:     https://git.kernel.org/tip/40c39e3046411f84bab82f66783ff3593e2bcd9b
Author:     Jin Yao <yao.jin@linux.intel.com>
AuthorDate: Tue, 26 Dec 2017 18:42:43 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 8 Jan 2018 11:11:57 -0300

perf report: Fix a no annotate browser displayed issue

When enabling '-b' option in perf record, for example,

  perf record -b ...
  perf report

and then browsing the annotate browser from perf report (press 'A'), it
would fail (annotate browser can't be displayed).

It's because the '.add_entry_cb' op of struct report is overwritten by
hist_iter__branch_callback() in builtin-report.c. But this function doesn't do
something like mapping symbols and sources. So next, do_annotate() will return
directly.

        notes = symbol__annotation(act->ms.sym);
        if (!notes->src)
                return 0;

This patch adds the lost code to hist_iter__branch_callback (refer to
hist_iter__report_callback).

v2:

Fix a crash bug when perform 'perf report --stdio'.

The reason is that we init the symbol annotation only in browser mode, it
doesn't allocate/init resources for stdio mode.

So now in hist_iter__branch_callback(), it will return directly if it's not in
browser mode.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1514284963-18587-1-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-report.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index eb9ce63..07827cd 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -162,12 +162,28 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter,
 	struct hist_entry *he = iter->he;
 	struct report *rep = arg;
 	struct branch_info *bi;
+	struct perf_sample *sample = iter->sample;
+	struct perf_evsel *evsel = iter->evsel;
+	int err;
+
+	if (!ui__has_annotation())
+		return 0;
+
+	hist__account_cycles(sample->branch_stack, al, sample,
+			     rep->nonany_branch_mode);
 
 	bi = he->branch_info;
+	err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
+	if (err)
+		goto out;
+
+	err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
+
 	branch_type_count(&rep->brtype_stat, &bi->flags,
 			  bi->from.addr, bi->to.addr);
 
-	return 0;
+out:
+	return err;
 }
 
 static int process_sample_event(struct perf_tool *tool,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-11  6:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-26 10:42 [PATCH v2] perf report: Fix a no annotate browser displayed issue Jin Yao
2018-01-04 18:45 ` Arnaldo Carvalho de Melo
2018-01-11  6:21 ` [tip:perf/core] " tip-bot for Jin Yao

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.