linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Jin Yao <yao.jin@linux.intel.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>,
	Kan Liang <kan.liang@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 02/86] perf annotate: Implement visual marker for macro fusion
Date: Wed, 19 Jul 2017 11:28:26 -0300	[thread overview]
Message-ID: <20170719142950.3747-3-acme@kernel.org> (raw)
In-Reply-To: <20170719142950.3747-1-acme@kernel.org>

From: Jin Yao <yao.jin@linux.intel.com>

For marking fused instructions clearly this patch adds a line before the
first instruction of pair and joins it with the arrow of the jump to its
target.

For example, when "je" is selected in annotate view, the line before
cmpl is displayed and joins the arrow of "je".

       │   ┌──cmpl   $0x0,argp_program_version_hook
 81.93 │   ├──je     20
       │   │  lock   cmpxchg %esi,0x38a9a4(%rip)
       │   │↓ jne    29
       │   │↓ jmp    43
 11.47 │20:└─→cmpxch %esi,0x38a999(%rip)

That means the cmpl+je is a fused instruction pair and they should be
considered together.

Changelog:

v3: Use Arnaldo's fix to improve the arrow origin rendering.  To get the
    evsel->evlist->env->cpuid, save the evsel in annotate_browser.

v2: new function "ins__is_fused" to check if the instructions are fused.

Signed-off-by: Yao Jin <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/1499403995-19857-3-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browser.c           | 29 +++++++++++++++++++++++++++++
 tools/perf/ui/browser.h           |  2 ++
 tools/perf/ui/browsers/annotate.c | 26 ++++++++++++++++++++++++++
 tools/perf/util/annotate.c        |  5 +++++
 tools/perf/util/annotate.h        |  1 +
 5 files changed, 63 insertions(+)

diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index 83874b0e266c..f73f3f13e01d 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -738,6 +738,35 @@ void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column,
 		__ui_browser__line_arrow_down(browser, column, start, end);
 }
 
+void ui_browser__mark_fused(struct ui_browser *browser, unsigned int column,
+			    unsigned int row, bool arrow_down)
+{
+	unsigned int end_row;
+
+	if (row >= browser->top_idx)
+		end_row = row - browser->top_idx;
+	else
+		return;
+
+	SLsmg_set_char_set(1);
+
+	if (arrow_down) {
+		ui_browser__gotorc(browser, end_row, column - 1);
+		SLsmg_write_char(SLSMG_ULCORN_CHAR);
+		ui_browser__gotorc(browser, end_row, column);
+		SLsmg_draw_hline(2);
+		ui_browser__gotorc(browser, end_row + 1, column - 1);
+		SLsmg_write_char(SLSMG_LTEE_CHAR);
+	} else {
+		ui_browser__gotorc(browser, end_row, column - 1);
+		SLsmg_write_char(SLSMG_LTEE_CHAR);
+		ui_browser__gotorc(browser, end_row, column);
+		SLsmg_draw_hline(2);
+	}
+
+	SLsmg_set_char_set(0);
+}
+
 void ui_browser__init(void)
 {
 	int i = 0;
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
index be3b70eb5fca..a12eff75638b 100644
--- a/tools/perf/ui/browser.h
+++ b/tools/perf/ui/browser.h
@@ -43,6 +43,8 @@ void ui_browser__printf(struct ui_browser *browser, const char *fmt, ...);
 void ui_browser__write_graph(struct ui_browser *browser, int graph);
 void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column,
 			      u64 start, u64 end);
+void ui_browser__mark_fused(struct ui_browser *browser, unsigned int column,
+			    unsigned int row, bool arrow_down);
 void __ui_browser__show_title(struct ui_browser *browser, const char *title);
 void ui_browser__show_title(struct ui_browser *browser, const char *title);
 int ui_browser__show(struct ui_browser *browser, const char *title,
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index c4336138b673..8d3f6f53c122 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -273,6 +273,25 @@ static bool disasm_line__is_valid_jump(struct disasm_line *dl, struct symbol *sy
 	return true;
 }
 
+static bool is_fused(struct annotate_browser *ab, struct disasm_line *cursor)
+{
+	struct disasm_line *pos = list_prev_entry(cursor, node);
+	const char *name;
+
+	if (!pos)
+		return false;
+
+	if (ins__is_lock(&pos->ins))
+		name = pos->ops.locked.ins.name;
+	else
+		name = pos->ins.name;
+
+	if (!name || !cursor->ins.name)
+		return false;
+
+	return ins__is_fused(ab->arch, name, cursor->ins.name);
+}
+
 static void annotate_browser__draw_current_jump(struct ui_browser *browser)
 {
 	struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
@@ -308,6 +327,13 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
 	ui_browser__set_color(browser, HE_COLORSET_JUMP_ARROWS);
 	__ui_browser__line_arrow(browser, pcnt_width + 2 + ab->addr_width,
 				 from, to);
+
+	if (is_fused(ab, cursor)) {
+		ui_browser__mark_fused(browser,
+				       pcnt_width + 3 + ab->addr_width,
+				       from - 1,
+				       to > from ? true : false);
+	}
 }
 
 static unsigned int annotate_browser__refresh(struct ui_browser *browser)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 8748ebb3f932..ef434b53d849 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -517,6 +517,11 @@ bool ins__is_ret(const struct ins *ins)
 	return ins->ops == &ret_ops;
 }
 
+bool ins__is_lock(const struct ins *ins)
+{
+	return ins->ops == &lock_ops;
+}
+
 static int ins__key_cmp(const void *name, const void *insp)
 {
 	const struct ins *ins = insp;
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 72d72728a0fc..bac698d7cc6a 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -52,6 +52,7 @@ struct ins_ops {
 bool ins__is_jump(const struct ins *ins);
 bool ins__is_call(const struct ins *ins);
 bool ins__is_ret(const struct ins *ins);
+bool ins__is_lock(const struct ins *ins);
 int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops);
 bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2);
 
-- 
2.9.4

  parent reply	other threads:[~2017-07-19 14:28 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 14:28 [GIT PULL 00/86] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 01/86] perf annotate: Check for fused instructions Arnaldo Carvalho de Melo
2017-07-19 14:28 ` Arnaldo Carvalho de Melo [this message]
2017-07-19 14:28 ` [PATCH 03/86] perf trace: Remove F_ from some of the fcntl command strings Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 04/86] perf trace: Beautify linux specific fcntl commands Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 05/86] tools: Update include/uapi/linux/fcntl.h copy from the kernel Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 06/86] perf trace beauty: Export the strarrays scnprintf method Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 07/86] perf trace: Only build tools/perf/trace/beauty/ when building 'perf trace' Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 08/86] perf trace beauty: Mask ignored fcntl 'arg' parameter Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 09/86] perf trace beauty: Allow accessing syscall args values in a syscall arg formatter Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 10/86] perf trace beauty: Export the "int" and "hex" syscall arg formatters Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 11/86] perf trace beauty: Introduce syscall arg beautifier for long integers Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 12/86] tools include uapi asm-generic: Grab a copy of fcntl.h Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 13/86] perf trace beauty fcntl: Basic 'arg' beautifier Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 14/86] perf trace: Beautify new write hint fcntl commands Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 15/86] perf beauty open: Detach the syscall_arg agnostic bits from the flags formatter Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 16/86] perf trace: Allow syscall_arg beautifiers to set a different return formatter Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 17/86] perf trace beauty open flags: Support O_TMPFILE and O_NOFOLLOW Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 18/86] perf trace beauty open flags: Do not depend on the system's O_LARGEFILE define Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 19/86] perf trace beauty fcntl: Beautify F_GETFL return value Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 20/86] perf trace beauty open flags: Move RDRW to the start of the output Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 21/86] perf trace beauty fcntl flags: Beautify F_SETFL arg Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 22/86] perf trace beauty fcntl: Beautify F_[GS]ETFD arg/return value Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 23/86] perf trace beauty: Give syscall return beautifier more context Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 24/86] perf trace beauty: Export the fd beautifier for use in more places Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 25/86] perf trace beauty fcntl: Augment the return of F_DUPFD(_CLOEXEC) Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 26/86] perf trace beauty: Export the pid beautifier for use in more places Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 27/86] perf trace beauty fcntl: Beautify F_GETOWN and F_SETOWN Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 28/86] perf pmu-events: Support additional POWER8+ PVR in mapfile Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 29/86] perf vendor events: Add POWER9 PMU events Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 30/86] perf vendor events: Add POWER9 PVRs to mapfile Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 31/86] tools include uapi x86: Grab a copy of unistd.h Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 32/86] tools include uapi x86: Add __NR_setns, if missing Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 33/86] tools build: Add test for setns() Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 34/86] perf symbols: Find symbols in different mount namespace Arnaldo Carvalho de Melo
2017-07-19 14:28 ` [PATCH 35/86] perf maps: Lookup maps in both intitial mountns and inner mountns Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 36/86] perf probe: Allow placing uprobes in alternate namespaces Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 37/86] perf buildid-cache: Support binary objects from other namespaces Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 38/86] perf buildid-cache: Cache debuginfo Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 39/86] perf evsel: Allow asking for max precise_ip in new_cycles() Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 40/86] perf evlist: Allow asking for max precise_ip in add_default() Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 41/86] perf record: Do not ask for precise_ip with --no-samples Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 42/86] perf test sdt: Handle realpath() failure Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 43/86] perf tests attr: Do not store failed events Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 44/86] perf tests attr: Add test_attr__ready function Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 45/86] perf tests attr: Make compare_data global Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 46/86] perf tests attr: Rename compare_data to data_equal Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 47/86] perf tests attr: Add 1s for exclude_kernel and task base bits Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 48/86] perf tests attr: Fix record dwarf test Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 49/86] perf tests attr: Fix no-delay test Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 50/86] perf tests attr: Add proper return values Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 51/86] perf tests attr: Fix cpu test disabled term setup Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 52/86] perf tests attr: Fix sample_period setup Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 53/86] perf tests attr: Fix precise_ip setup Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 54/86] perf tests attr: Fix stat sample_type setup Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 55/86] perf tests attr: Add optional term Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 56/86] perf trace beauty: Export strarray for use in per-object beautifiers Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 57/86] perf trace beauty fcntl: Beautify F_GETLEASE and F_SETLEASE arg/return Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 58/86] perf trace: Group per syscall arg formatter info into one struct Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 59/86] perf trace: Allow syscall arg formatters to request non suppression of zeros Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 60/86] perf trace beauty fcntl: Do not suppress 'cmd' when zero, should be DUPFD Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 61/86] perf trace beauty fcntl: Beautify the 'arg' for DUPFD Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 62/86] perf trace beauty: Simplify syscall return formatting Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 63/86] perf report: Enable finding kernel inline functions Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 64/86] perf header: Encapsulate read and swap Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 65/86] perf header: Add PROCESS_STR_FUN macro Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 66/86] perf header: Fail on write_padded error Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 67/86] perf util: Add const modifier to buf in "writen" function Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 68/86] perf header: Revamp do_write() Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 69/86] perf header: Add struct feat_fd for write Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 70/86] perf header: Use struct feat_fd for print Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 71/86] perf header: Use struct feat_fd to process header records Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 72/86] perf header: Don't pass struct perf_file_section to process_##_feat Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 73/86] perf header: Use struct feat_fd in read header records Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 74/86] perf header: Make write_pmu_mappings pipe-mode friendly Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 75/86] perf header: Add a buffer to struct feat_fd Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 76/86] perf header: Change FEAT_OP* macros Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 77/86] perf tool: Add show_feature_header to perf_tool Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 78/86] perf tools: Add feature header record to pipe-mode Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 79/86] perf header: Add event desc to pipe-mode header Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 80/86] perf/core: Define the common branch type classification Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 81/86] perf/x86/intel: Record branch type Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 82/86] perf record: Create a new option save_type in --branch-filter Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 83/86] perf report: Refactor the branch info printing code Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 84/86] perf util: Create branch.c/.h for common branch functions Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 85/86] perf report: Show branch type statistics for stdio mode Arnaldo Carvalho de Melo
2017-07-19 14:29 ` [PATCH 86/86] perf report: Show branch type in callchain entry Arnaldo Carvalho de Melo
2017-07-20  8:32 ` [GIT PULL 00/86] perf/core improvements and fixes Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2017-07-19 13:55 Arnaldo Carvalho de Melo
2017-07-19 13:55 ` [PATCH 02/86] perf annotate: Implement visual marker for macro fusion 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=20170719142950.3747-3-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=yao.jin@linux.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;
as well as URLs for NNTP newsgroup(s).