From: kan.liang@intel.com
To: peterz@infradead.org, acme@kernel.org
Cc: eranian@google.com, ak@linux.intel.com, jolsa@kernel.org,
namhyung@kernel.org, linux-kernel@vger.kernel.org,
Kan Liang <kan.liang@intel.com>
Subject: [PATCH 3/8] perf tools: add sort option phys_daddr
Date: Wed, 6 Jan 2016 06:04:32 -0500 [thread overview]
Message-ID: <1452078277-15520-3-git-send-email-kan.liang@intel.com> (raw)
In-Reply-To: <1452078277-15520-1-git-send-email-kan.liang@intel.com>
From: Kan Liang <kan.liang@intel.com>
Add a new sort option phys_daddr for --mem-mode sort. With this option
applied, perf can sort and report by sample's physical address.
Signed-off-by: Kan Liang <kan.liang@intel.com>
---
tools/perf/Documentation/perf-report.txt | 1 +
tools/perf/util/hist.c | 3 +++
tools/perf/util/hist.h | 1 +
tools/perf/util/machine.c | 7 ++++--
tools/perf/util/sort.c | 42 ++++++++++++++++++++++++++++++++
tools/perf/util/sort.h | 1 +
tools/perf/util/symbol.h | 1 +
7 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 8a301f6..91c387e 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -163,6 +163,7 @@ OPTIONS
- mem: type of memory access for the data at the time of sample
- snoop: type of snoop (if any) for the data at the time of sample
- dcacheline: the cacheline the data address is on at the time of sample
+ - phys_daddr: physical address of data being executed on at the time of sample
And default sort keys are changed to local_weight, mem, sym, dso,
symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index afc9b8f..3051f15 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -152,6 +152,9 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
symlen = unresolved_col_width + 4 + 2;
hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
}
+
+ hists__new_col_len(hists, HISTC_MEM_PHYS_DADDR, unresolved_col_width + 4 + 2);
+
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index cb8f373..3bb574a 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -44,6 +44,7 @@ enum hist_column {
HISTC_GLOBAL_WEIGHT,
HISTC_MEM_DADDR_SYMBOL,
HISTC_MEM_DADDR_DSO,
+ HISTC_MEM_PHYS_DADDR,
HISTC_MEM_LOCKED,
HISTC_MEM_TLB,
HISTC_MEM_LVL,
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index ad79297..6a516cc 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1560,10 +1560,12 @@ static void ip__resolve_ams(struct thread *thread,
ams->al_addr = al.addr;
ams->sym = al.sym;
ams->map = al.map;
+ ams->phys_addr = 0;
}
static void ip__resolve_data(struct thread *thread,
- u8 m, struct addr_map_symbol *ams, u64 addr)
+ u8 m, struct addr_map_symbol *ams,
+ u64 addr, u64 phys_addr)
{
struct addr_location al;
@@ -1583,6 +1585,7 @@ static void ip__resolve_data(struct thread *thread,
ams->al_addr = al.addr;
ams->sym = al.sym;
ams->map = al.map;
+ ams->phys_addr = phys_addr;
}
struct mem_info *sample__resolve_mem(struct perf_sample *sample,
@@ -1594,7 +1597,7 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
return NULL;
ip__resolve_ams(al->thread, &mi->iaddr, sample->ip);
- ip__resolve_data(al->thread, al->cpumode, &mi->daddr, sample->addr);
+ ip__resolve_data(al->thread, al->cpumode, &mi->daddr, sample->addr, sample->phys_addr);
mi->data_src.val = sample->data_src;
return mi;
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index a8a9588..4ce6827 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -832,6 +832,40 @@ sort__tlb_cmp(struct hist_entry *left, struct hist_entry *right)
return (int64_t)(data_src_r.mem_dtlb - data_src_l.mem_dtlb);
}
+static int64_t
+sort__phys_daddr_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+ uint64_t l = 0, r = 0;
+
+ if (left->mem_info)
+ l = left->mem_info->daddr.phys_addr;
+ if (right->mem_info)
+ r = right->mem_info->daddr.phys_addr;
+
+ return (int64_t)(r - l);
+}
+
+static int hist_entry__phys_daddr_snprintf(struct hist_entry *he, char *bf,
+ size_t size, unsigned int width)
+{
+ uint64_t addr = 0;
+ size_t ret = 0;
+ size_t len = BITS_PER_LONG / 4;
+
+ addr = he->mem_info->daddr.phys_addr;
+
+ ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", he->level);
+
+ ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx", len, addr);
+
+ ret += repsep_snprintf(bf + ret, size - ret, "%-*s", width - ret, "");
+
+ if (ret > width)
+ bf[width] = '\0';
+
+ return width;
+}
+
static const char * const tlb_access[] = {
"N/A",
"HIT",
@@ -1222,6 +1256,13 @@ struct sort_entry sort_mem_dcacheline = {
.se_width_idx = HISTC_MEM_DCACHELINE,
};
+struct sort_entry sort_mem_phys_daddr = {
+ .se_header = "Data Physical Address",
+ .se_cmp = sort__phys_daddr_cmp,
+ .se_snprintf = hist_entry__phys_daddr_snprintf,
+ .se_width_idx = HISTC_MEM_PHYS_DADDR,
+};
+
static int64_t
sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
{
@@ -1410,6 +1451,7 @@ static struct sort_dimension memory_sort_dimensions[] = {
DIM(SORT_MEM_LVL, "mem", sort_mem_lvl),
DIM(SORT_MEM_SNOOP, "snoop", sort_mem_snoop),
DIM(SORT_MEM_DCACHELINE, "dcacheline", sort_mem_dcacheline),
+ DIM(SORT_MEM_PHYS_DADDR, "phys_daddr", sort_mem_phys_daddr),
};
#undef DIM
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index dec536b..f6e1781 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -207,6 +207,7 @@ enum sort_type {
SORT_MEM_SNOOP,
SORT_MEM_DCACHELINE,
SORT_MEM_IADDR_SYMBOL,
+ SORT_MEM_PHYS_DADDR,
};
/*
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index ccd1caa..c35c3f0 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -170,6 +170,7 @@ struct addr_map_symbol {
struct symbol *sym;
u64 addr;
u64 al_addr;
+ u64 phys_addr;
};
struct branch_info {
--
1.8.3.1
next prev parent reply other threads:[~2016-01-06 18:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-06 11:04 [PATCH 1/8] perf: Add PERF_SAMPLE_PHYS_ADDR kan.liang
2016-01-06 11:04 ` [PATCH 2/8] perf tools: add option to record sample physical address kan.liang
2016-01-07 9:56 ` Jiri Olsa
2016-01-06 11:04 ` kan.liang [this message]
2016-01-06 11:04 ` [PATCH 4/8] perf mem: add option phys-data to record " kan.liang
2016-01-06 11:04 ` [PATCH 5/8] perf mem: report physical addresses kan.liang
2016-01-07 8:27 ` Jiri Olsa
2016-01-06 11:04 ` [PATCH 6/8] perf mem: dump " kan.liang
2016-01-06 11:04 ` [PATCH 7/8] perf script: support physical addresses in script kan.liang
2016-01-07 9:54 ` Jiri Olsa
2016-01-06 11:04 ` [PATCH 8/8] perf test: add test case for PERF_SAMPLE_PHYS_ADDR kan.liang
2016-01-06 19:21 ` [PATCH 1/8] perf: Add PERF_SAMPLE_PHYS_ADDR Stephane Eranian
2016-01-07 8:33 ` Jiri Olsa
2016-01-07 15:55 ` Liang, Kan
2016-01-07 19:31 ` Jiri Olsa
2016-01-07 21:50 ` Stephane Eranian
2016-01-08 21:12 ` Liang, Kan
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=1452078277-15520-3-git-send-email-kan.liang@intel.com \
--to=kan.liang@intel.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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
Powered by JetHome