From: Don Zickus <dzickus@redhat.com>
To: acme@ghostprotocols.net
Cc: LKML <linux-kernel@vger.kernel.org>,
jolsa@redhat.com, jmario@redhat.com, fowles@inreach.com,
eranian@google.com, Arnaldo Carvalho de Melo <acme@redhat.com>,
David Ahern <dsahern@gmail.com>, Don Zickus <dzickus@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Mike Galbraith <efault@gmx.de>, Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <peterz@infradead.org>,
Richard Fowles <rfowles@redhat.com>
Subject: [PATCH 09/19] perf c2c: Dump raw records, decode data_src bits
Date: Fri, 28 Feb 2014 12:42:58 -0500 [thread overview]
Message-ID: <1393609388-40489-10-git-send-email-dzickus@redhat.com> (raw)
In-Reply-To: <1393609388-40489-1-git-send-email-dzickus@redhat.com>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
>From the c2c prototype:
[root@sandy ~]# perf c2c -r report | head -7
T Status Pid Tid CPU Inst Adrs Virt Data Adrs Phys Data Adrs Cycles Source Decoded Source ObJect:Symbol
--------------------------------------------------------------------------------------------------------------------------------------------
raw input 779 779 7 0xffffffff810865dd 0xffff8803f4d75ec8 0 370 0x68080882 [LOAD,LCL_LLC,MISS,SNP NA] [kernel.kallsyms]:try_to_wake_up
raw input 779 779 7 0xffffffff8107acb3 0xffff8802a5b73158 0 297 0x6a100142 [LOAD,L1,HIT,SNP NONE,LOCKED] [kernel.kallsyms]:up_read
raw input 779 779 7 0x3b7e009814 0x7fff87429ea0 0 925 0x68100142 [LOAD,L1,HIT,SNP NONE] ???:???
raw input 0 0 1 0xffffffff8108bf81 0xffff8803eafebf50 0 172 0x68800842 [LOAD,LCL_LLC,HIT,SNP HITM] [kernel.kallsyms]:update_stats_wait_end
raw input 779 779 7 0x3b7e0097cc 0x7fac94b69068 0 228 0x68100242 [LOAD,LFB,HIT,SNP NONE] ???:???
[root@sandy ~]#
The "Phys Data Adrs" column is not available at this point.
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Richard Fowles <rfowles@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-c2c.c | 148 +++++++++++++++++++++++++++++++++++++++--------
1 file changed, 125 insertions(+), 23 deletions(-)
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 2935484..7082913 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -11,51 +11,148 @@
struct perf_c2c {
struct perf_tool tool;
+ bool raw_records;
};
-static int perf_sample__fprintf(struct perf_sample *sample,
- struct perf_evsel *evsel,
- struct addr_location *al, FILE *fp)
+enum { OP, LVL, SNP, LCK, TLB };
+
+static int perf_c2c__scnprintf_data_src(char *bf, size_t size, uint64_t val)
{
- return fprintf(fp, "%25.25s: %5d %5d 0x%016" PRIx64 " 0x016%" PRIx64 " %5" PRIu64 " 0x%06" PRIx64 " %s:%s\n",
- perf_evsel__name(evsel),
- sample->pid, sample->tid, sample->ip, sample->addr,
- sample->weight, sample->data_src,
- al->map ? (al->map->dso ? al->map->dso->long_name : "???") : "???",
- al->sym ? al->sym->name : "???");
+#define PREFIX "["
+#define SUFFIX "]"
+#define ELLIPSIS "..."
+ static const struct {
+ uint64_t bit;
+ int64_t field;
+ const char *name;
+ } decode_bits[] = {
+ { PERF_MEM_OP_LOAD, OP, "LOAD" },
+ { PERF_MEM_OP_STORE, OP, "STORE" },
+ { PERF_MEM_OP_NA, OP, "OP_NA" },
+ { PERF_MEM_LVL_LFB, LVL, "LFB" },
+ { PERF_MEM_LVL_L1, LVL, "L1" },
+ { PERF_MEM_LVL_L2, LVL, "L2" },
+ { PERF_MEM_LVL_L3, LVL, "LCL_LLC" },
+ { PERF_MEM_LVL_LOC_RAM, LVL, "LCL_RAM" },
+ { PERF_MEM_LVL_REM_RAM1, LVL, "RMT_RAM" },
+ { PERF_MEM_LVL_REM_RAM2, LVL, "RMT_RAM" },
+ { PERF_MEM_LVL_REM_CCE1, LVL, "RMT_LLC" },
+ { PERF_MEM_LVL_REM_CCE2, LVL, "RMT_LLC" },
+ { PERF_MEM_LVL_IO, LVL, "I/O" },
+ { PERF_MEM_LVL_UNC, LVL, "UNCACHED" },
+ { PERF_MEM_LVL_NA, LVL, "N" },
+ { PERF_MEM_LVL_HIT, LVL, "HIT" },
+ { PERF_MEM_LVL_MISS, LVL, "MISS" },
+ { PERF_MEM_SNOOP_NONE, SNP, "SNP NONE" },
+ { PERF_MEM_SNOOP_HIT, SNP, "SNP HIT" },
+ { PERF_MEM_SNOOP_MISS, SNP, "SNP MISS" },
+ { PERF_MEM_SNOOP_HITM, SNP, "SNP HITM" },
+ { PERF_MEM_SNOOP_NA, SNP, "SNP NA" },
+ { PERF_MEM_LOCK_LOCKED, LCK, "LOCKED" },
+ { PERF_MEM_LOCK_NA, LCK, "LOCK_NA" },
+ };
+ union perf_mem_data_src dsrc = { .val = val, };
+ int printed = scnprintf(bf, size, PREFIX);
+ size_t i;
+ bool first_present = true;
+
+ for (i = 0; i < ARRAY_SIZE(decode_bits); i++) {
+ int bitval;
+
+ switch (decode_bits[i].field) {
+ case OP: bitval = decode_bits[i].bit & dsrc.mem_op; break;
+ case LVL: bitval = decode_bits[i].bit & dsrc.mem_lvl; break;
+ case SNP: bitval = decode_bits[i].bit & dsrc.mem_snoop; break;
+ case LCK: bitval = decode_bits[i].bit & dsrc.mem_lock; break;
+ case TLB: bitval = decode_bits[i].bit & dsrc.mem_dtlb; break;
+ default: bitval = 0; break;
+ }
+
+ if (!bitval)
+ continue;
+
+ if (strlen(decode_bits[i].name) + !!i > size - printed - sizeof(SUFFIX)) {
+ sprintf(bf + size - sizeof(SUFFIX) - sizeof(ELLIPSIS) + 1, ELLIPSIS);
+ printed = size - sizeof(SUFFIX);
+ break;
+ }
+
+ printed += scnprintf(bf + printed, size - printed, "%s%s",
+ first_present ? "" : ",", decode_bits[i].name);
+ first_present = false;
+ }
+
+ printed += scnprintf(bf + printed, size - printed, SUFFIX);
+ return printed;
}
-static int perf_c2c__process_load(struct perf_evsel *evsel,
- struct perf_sample *sample,
- struct addr_location *al)
+static int perf_c2c__fprintf_header(FILE *fp)
{
- perf_sample__fprintf(sample, evsel, al, stdout);
- return 0;
+ int printed = fprintf(fp, "%c %-16s %6s %6s %4s %18s %18s %18s %6s %-10s %-60s %s\n",
+ 'T',
+ "Status",
+ "Pid",
+ "Tid",
+ "CPU",
+ "Inst Adrs",
+ "Virt Data Adrs",
+ "Phys Data Adrs",
+ "Cycles",
+ "Source",
+ " Decoded Source",
+ "ObJect:Symbol");
+ return printed + fprintf(fp, "%-*.*s\n", printed, printed, graph_dotted_line);
+}
+
+static int perf_sample__fprintf(struct perf_sample *sample, char tag,
+ const char *reason, struct addr_location *al, FILE *fp)
+{
+ char data_src[61];
+
+ perf_c2c__scnprintf_data_src(data_src, sizeof(data_src), sample->data_src);
+
+ return fprintf(fp, "%c %-16s %6d %6d %4d %#18" PRIx64 " %#18" PRIx64 " %#18" PRIx64 " %6" PRIu64 " %#10" PRIx64 " %-60.60s %s:%s\n",
+ tag,
+ reason ?: "valid record",
+ sample->pid,
+ sample->tid,
+ sample->cpu,
+ sample->ip,
+ sample->addr,
+ 0UL,
+ sample->weight,
+ sample->data_src,
+ data_src,
+ al->map ? (al->map->dso ? al->map->dso->long_name : "???") : "???",
+ al->sym ? al->sym->name : "???");
}
-static int perf_c2c__process_store(struct perf_evsel *evsel,
- struct perf_sample *sample,
- struct addr_location *al)
+static int perf_c2c__process_load_store(struct perf_c2c *c2c,
+ struct perf_sample *sample,
+ struct addr_location *al)
{
- perf_sample__fprintf(sample, evsel, al, stdout);
+ if (c2c->raw_records)
+ perf_sample__fprintf(sample, ' ', "raw input", al, stdout);
+
return 0;
}
static const struct perf_evsel_str_handler handlers[] = {
- { "cpu/mem-loads,ldlat=30/pp", perf_c2c__process_load, },
- { "cpu/mem-stores/pp", perf_c2c__process_store, },
+ { "cpu/mem-loads,ldlat=30/pp", perf_c2c__process_load_store, },
+ { "cpu/mem-stores/pp", perf_c2c__process_load_store, },
};
-typedef int (*sample_handler)(struct perf_evsel *evsel,
+typedef int (*sample_handler)(struct perf_c2c *c2c,
struct perf_sample *sample,
struct addr_location *al);
-static int perf_c2c__process_sample(struct perf_tool *tool __maybe_unused,
+static int perf_c2c__process_sample(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct machine *machine)
{
+ struct perf_c2c *c2c = container_of(tool, struct perf_c2c, tool);
struct addr_location al;
int err = 0;
@@ -67,7 +164,7 @@ static int perf_c2c__process_sample(struct perf_tool *tool __maybe_unused,
if (evsel->handler != NULL) {
sample_handler f = evsel->handler;
- err = f(evsel, sample, &al);
+ err = f(c2c, sample, &al);
}
return err;
@@ -111,6 +208,10 @@ out:
static int perf_c2c__report(struct perf_c2c *c2c)
{
setup_pager();
+
+ if (c2c->raw_records)
+ perf_c2c__fprintf_header(stdout);
+
return perf_c2c__read_events(c2c);
}
@@ -161,6 +262,7 @@ int cmd_c2c(int argc, const char **argv, const char *prefix __maybe_unused)
},
};
const struct option c2c_options[] = {
+ OPT_BOOLEAN('r', "raw_records", &c2c.raw_records, "dump raw events"),
OPT_END()
};
const char * const c2c_usage[] = {
--
1.7.11.7
next prev parent reply other threads:[~2014-02-28 17:44 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 17:42 [PATCH 00/19 V2] perf, c2c: Add new tool to analyze cacheline contention on NUMA systems Don Zickus
2014-02-28 17:42 ` [PATCH 01/19] Revert "perf: Disable PERF_RECORD_MMAP2 support" Don Zickus
2014-02-28 17:42 ` [PATCH 02/19] perf, sort: Add physid sorting based on mmap2 data Don Zickus
2014-03-19 10:45 ` Jiri Olsa
2014-03-19 13:36 ` Don Zickus
2014-02-28 17:42 ` [PATCH 03/19] perf, sort: Allow unique sorting instead of combining hist_entries Don Zickus
2014-02-28 17:42 ` [PATCH 04/19] perf: Allow ability to map cpus to nodes easily Don Zickus
2014-03-19 12:48 ` Jiri Olsa
2014-03-19 13:38 ` Don Zickus
2014-03-19 13:22 ` Jiri Olsa
2014-02-28 17:42 ` [PATCH 05/19] perf, kmem: Utilize the new generic cpunode_map Don Zickus
2014-02-28 17:42 ` [PATCH 06/19] perf: Fix stddev calculation Don Zickus
2014-02-28 17:42 ` [PATCH 07/19] perf, callchain: Add generic callchain print handler for stdio Don Zickus
2014-02-28 17:42 ` [PATCH 08/19] perf c2c: Shared data analyser Don Zickus
2014-02-28 19:08 ` Andi Kleen
2014-02-28 19:46 ` Don Zickus
2014-02-28 21:03 ` Davidlohr Bueso
2014-02-28 22:28 ` Joe Mario
2014-03-01 0:50 ` Andi Kleen
2014-03-03 14:13 ` Don Zickus
2014-03-03 15:05 ` Don Zickus
2014-03-03 17:23 ` Andi Kleen
2014-03-03 18:07 ` Joe Mario
2014-03-03 18:41 ` Peter Zijlstra
2014-03-03 18:58 ` Andi Kleen
2014-03-03 19:48 ` Peter Zijlstra
2014-03-03 20:32 ` Don Zickus
2014-03-03 21:38 ` Andi Kleen
2014-03-03 21:41 ` Don Zickus
2014-03-03 20:30 ` Don Zickus
2014-03-03 20:26 ` Don Zickus
2014-03-03 21:36 ` Andi Kleen
2014-03-04 9:42 ` Peter Zijlstra
2014-03-03 18:21 ` Davidlohr Bueso
2014-02-28 17:42 ` Don Zickus [this message]
2014-02-28 17:42 ` [PATCH 10/19] perf, c2c: Rework setup code to prepare for features Don Zickus
2014-02-28 17:43 ` [PATCH 11/19] perf, c2c: Add in sort on physid Don Zickus
2014-02-28 18:59 ` Andi Kleen
2014-02-28 19:44 ` Don Zickus
2014-03-01 1:07 ` Andi Kleen
2014-03-01 1:27 ` Namhyung Kim
2014-02-28 17:43 ` [PATCH 12/19] perf, c2c: Add stats to track data source bits and cpu to node maps Don Zickus
2014-02-28 17:43 ` [PATCH 13/19] perf, c2c: Sort based on hottest cache line Don Zickus
2014-02-28 17:43 ` [PATCH 14/19] perf, c2c: Display cacheline HITM analysis to stdout Don Zickus
2014-02-28 17:43 ` [PATCH 15/19] perf, c2c: Add callchain support Don Zickus
2014-03-19 13:00 ` Jiri Olsa
2014-03-19 13:53 ` Don Zickus
2014-03-19 14:05 ` Jiri Olsa
2014-02-28 17:43 ` [PATCH 16/19] perf, c2c: Output summary stats Don Zickus
2014-02-28 17:43 ` [PATCH 17/19] perf, c2c: Dump rbtree for debugging Don Zickus
2014-02-28 17:43 ` [PATCH 18/19] perf, c2c: Add symbol count table Don Zickus
2014-02-28 17:43 ` [PATCH 19/19] perf, c2c: Add shared cachline summary table Don Zickus
2014-02-28 18:57 ` [PATCH 00/19 V2] perf, c2c: Add new tool to analyze cacheline contention on NUMA systems Andi Kleen
2014-02-28 19:42 ` Don Zickus
2014-02-28 21:54 ` Andi Kleen
2014-03-03 14:04 ` Don Zickus
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=1393609388-40489-10-git-send-email-dzickus@redhat.com \
--to=dzickus@redhat.com \
--cc=acme@ghostprotocols.net \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=efault@gmx.de \
--cc=eranian@google.com \
--cc=fowles@inreach.com \
--cc=fweisbec@gmail.com \
--cc=jmario@redhat.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
--cc=rfowles@redhat.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).