linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Don Zickus <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, dzickus@redhat.com, hpa@zytor.com,
	dsahern@gmail.com, a.p.zijlstra@chello.nl, jolsa@kernel.org,
	tglx@linutronix.de, namhyung@kernel.org, acme@redhat.com,
	linux-kernel@vger.kernel.org, kan.liang@intel.com
Subject: [tip:perf/core] perf tools: Add support for sorting on the iaddr
Date: Tue, 6 Oct 2015 00:14:52 -0700	[thread overview]
Message-ID: <tip-28e6db205b3ed3f1d86a00c69b3304190377da5f@git.kernel.org> (raw)
In-Reply-To: <1444068369-20978-8-git-send-email-jolsa@kernel.org>

Commit-ID:  28e6db205b3ed3f1d86a00c69b3304190377da5f
Gitweb:     http://git.kernel.org/tip/28e6db205b3ed3f1d86a00c69b3304190377da5f
Author:     Don Zickus <dzickus@redhat.com>
AuthorDate: Mon, 5 Oct 2015 20:06:07 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 5 Oct 2015 16:32:00 -0300

perf tools: Add support for sorting on the iaddr

Sorting on 'symbol' gives to broad a resolution as it can cover a range
of IP address.  Use the iaddr instead to get proper sorting on IP
addresses.  Need to use the 'mem_sort' feature of perf record.

New sort option is: symbol_iaddr, header label is 'Code Symbol'.

  $ perf mem report --stdio -F +symbol_iaddr
  # Overhead       Samples  Code Symbol              Local Weight
  # ........  ............  ........................ ............
  #
      54.08%             1  [k] nmi_handle           192
       4.51%             1  [k] finish_task_switch   16
       3.66%             1  [.] malloc               13
       3.10%             1  [.] __strcoll_l          11

Signed-off-by: Don Zickus <dzickus@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1444068369-20978-8-git-send-email-jolsa@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/hist.h |  1 +
 tools/perf/util/sort.c | 37 +++++++++++++++++++++++++++++++++++++
 tools/perf/util/sort.h |  1 +
 3 files changed, 39 insertions(+)

diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 8c20a8f..a48a207 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -49,6 +49,7 @@ enum hist_column {
 	HISTC_MEM_LVL,
 	HISTC_MEM_SNOOP,
 	HISTC_MEM_DCACHELINE,
+	HISTC_MEM_IADDR_SYMBOL,
 	HISTC_TRANSACTION,
 	HISTC_CYCLES,
 	HISTC_NR_COLS, /* Last entry */
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 6b9556d..ee94b72 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -655,6 +655,35 @@ static int hist_entry__daddr_snprintf(struct hist_entry *he, char *bf,
 }
 
 static int64_t
+sort__iaddr_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+	uint64_t l = 0, r = 0;
+
+	if (left->mem_info)
+		l = left->mem_info->iaddr.addr;
+	if (right->mem_info)
+		r = right->mem_info->iaddr.addr;
+
+	return (int64_t)(r - l);
+}
+
+static int hist_entry__iaddr_snprintf(struct hist_entry *he, char *bf,
+				    size_t size, unsigned int width)
+{
+	uint64_t addr = 0;
+	struct map *map = NULL;
+	struct symbol *sym = NULL;
+
+	if (he->mem_info) {
+		addr = he->mem_info->iaddr.addr;
+		map  = he->mem_info->iaddr.map;
+		sym  = he->mem_info->iaddr.sym;
+	}
+	return _hist_entry__sym_snprintf(map, sym, addr, he->level, bf, size,
+					 width);
+}
+
+static int64_t
 sort__dso_daddr_cmp(struct hist_entry *left, struct hist_entry *right)
 {
 	struct map *map_l = NULL;
@@ -1077,6 +1106,13 @@ struct sort_entry sort_mem_daddr_sym = {
 	.se_width_idx	= HISTC_MEM_DADDR_SYMBOL,
 };
 
+struct sort_entry sort_mem_iaddr_sym = {
+	.se_header	= "Code Symbol",
+	.se_cmp		= sort__iaddr_cmp,
+	.se_snprintf	= hist_entry__iaddr_snprintf,
+	.se_width_idx	= HISTC_MEM_IADDR_SYMBOL,
+};
+
 struct sort_entry sort_mem_daddr_dso = {
 	.se_header	= "Data Object",
 	.se_cmp		= sort__dso_daddr_cmp,
@@ -1299,6 +1335,7 @@ static struct sort_dimension bstack_sort_dimensions[] = {
 
 static struct sort_dimension memory_sort_dimensions[] = {
 	DIM(SORT_MEM_DADDR_SYMBOL, "symbol_daddr", sort_mem_daddr_sym),
+	DIM(SORT_MEM_IADDR_SYMBOL, "symbol_iaddr", sort_mem_iaddr_sym),
 	DIM(SORT_MEM_DADDR_DSO, "dso_daddr", sort_mem_daddr_dso),
 	DIM(SORT_MEM_LOCKED, "locked", sort_mem_locked),
 	DIM(SORT_MEM_TLB, "tlb", sort_mem_tlb),
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index c06b757..33b3d30 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -201,6 +201,7 @@ enum sort_type {
 	SORT_MEM_LVL,
 	SORT_MEM_SNOOP,
 	SORT_MEM_DCACHELINE,
+	SORT_MEM_IADDR_SYMBOL,
 };
 
 /*

  reply	other threads:[~2015-10-06  7:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-05 18:06 [PATCH 0/9] perf tools: Various fixes Jiri Olsa
2015-10-05 18:06 ` [PATCH 1/9] tools lib api fs: Do not use PATH_MAX + 1 Jiri Olsa
2015-10-06  7:12   ` [tip:perf/core] tools lib api fs: No need to " tip-bot for Jiri Olsa
2015-10-05 18:06 ` [PATCH 2/9] perf evlist: Display DATA_SRC sample type bit Jiri Olsa
2015-10-06  7:13   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-10-05 18:06 ` [PATCH 3/9] perf annotate: Fix sizeof_sym_hist overflow issue Jiri Olsa
2015-10-06  7:13   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-10-05 18:06 ` [PATCH 4/9] perf tools: Make perf_event_attr__set_max_precise_ip global Jiri Olsa
2015-10-06  7:13   ` [tip:perf/core] perf tools: Export perf_event_attr__set_max_precise_ip() tip-bot for Jiri Olsa
2015-10-05 18:06 ` [PATCH 5/9] perf tools: Introduce 'P' modifier Jiri Olsa
2015-10-05 18:13   ` David Ahern
2015-10-05 18:38     ` Jiri Olsa
2015-10-05 19:08       ` Arnaldo Carvalho de Melo
2015-10-05 19:20   ` Arnaldo Carvalho de Melo
2015-10-06  7:01     ` Jiri Olsa
2015-10-06  7:14   ` [tip:perf/core] perf tools: Introduce 'P' modifier to request max precision tip-bot for Jiri Olsa
2015-10-05 18:06 ` [PATCH 6/9] perf tests: Add parsing test for 'P' modifier Jiri Olsa
2015-10-06  7:14   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-10-05 18:06 ` [PATCH 7/9] perf tools: Add support for sorting on the iaddr Jiri Olsa
2015-10-06  7:14   ` tip-bot for Don Zickus [this message]
2015-10-05 18:06 ` [PATCH 8/9] perf tools: Setup proper width for symbol_iaddr field Jiri Olsa
2015-10-06  7:15   ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-10-05 18:06 ` [PATCH 9/9] perf tools: Handle -h and -v options Jiri Olsa
2015-10-06  7:15   ` [tip:perf/core] " tip-bot for Jiri Olsa

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-28e6db205b3ed3f1d86a00c69b3304190377da5f@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=dzickus@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).