Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1334248 > unrolled thread
| Started by | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| First post | 2016-02-15 09:40 +0100 |
| Last post | 2016-02-15 09:50 +0100 |
| Articles | 20 on this page of 25 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH 00/23] perf tools: Several memory events updates Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 10/23] perf x86 intel: Add DATALA events into sysfs Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 11/23] perf mem: Add Intel DATALA memory events Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 18/23] perf tools: Change perf_mem__lvl_scnprintf to return nb of displayed bytes Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 13/23] perf tools: Introduce perf_mem__tlb_scnprintf function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 09/23] perf mem: Add -u/-k options Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 03/23] perf tools: Introduce cl_offset function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 06/23] perf mem: Check for memory events support Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 15/23] perf tools: Introduce perf_mem__snp_scnprintf function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 01/23] perf record: Add --all-user/--all-kernel options Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-16 18:00 +0100
Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Andi Kleen <ak@linux.intel.com> - 2016-02-17 04:20 +0100
Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-17 15:30 +0100
Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Andi Kleen <ak@linux.intel.com> - 2016-02-17 16:40 +0100
Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Jiri Olsa <jolsa@redhat.com> - 2016-02-17 15:40 +0100
Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-17 16:00 +0100
[tip:perf/core] perf record: Add --all-user/--all-kernel options tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-02-20 12:40 +0100
[PATCH 17/23] perf tools: Change perf_mem__tlb_scnprintf to return nb of displayed bytes Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 23/23] perf script: Display data_src values Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 05/23] perf mem: Add -e record option Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 14/23] perf tools: Introduce perf_mem__lvl_scnprintf function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 21/23] perf script: Add data_src and weight column definitions Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:40 +0100
[PATCH 07/23] perf mem: Introduce perf_mem_events__name function Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:50 +0100
[PATCH 04/23] perf tools: Add monitored events array Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:50 +0100
[PATCH 02/23] perf tools: Make cl_address global Jiri Olsa <jolsa@kernel.org> - 2016-02-15 09:50 +0100
Page 1 of 2 [1] 2 Next page →
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 00/23] perf tools: Several memory events updates |
| Message-ID | <r2mRk-6Rc-3@gated-at.bofh.it> |
hi,
this is generic part of the c2c patchset. It contains
several enhancements for perf mem and script commands:
- display memory events properties in perf script
- perf mem DATALA events support
- few other assorted fixes/options
Also available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/mem
thanks,
jirka
---
Jiri Olsa (23):
perf record: Add --all-user/--all-kernel options
perf tools: Make cl_address global
perf tools: Introduce cl_offset function
perf tools: Add monitored events array
perf mem: Add -e record option
perf mem: Check for memory events support
perf mem: Introduce perf_mem_events__name function
perf mem: Add -l/--ldlat option
perf mem: Add -u/-k options
perf x86 intel: Add DATALA events into sysfs
perf mem: Add Intel DATALA memory events
perf tools: Use ARRAY_SIZE in mem sort display functions
perf tools: Introduce perf_mem__tlb_scnprintf function
perf tools: Introduce perf_mem__lvl_scnprintf function
perf tools: Introduce perf_mem__snp_scnprintf function
perf tools: Introduce perf_mem__lck_scnprintf function
perf tools: Change perf_mem__tlb_scnprintf to return nb of displayed bytes
perf tools: Change perf_mem__lvl_scnprintf to return nb of displayed bytes
perf tools: Change perf_mem__snp_scnprintf to return nb of displayed bytes
perf tools: Change perf_mem__lck_scnprintf to return nb of displayed bytes
perf script: Add data_src and weight column definitions
perf script: Display addr/data_src/weight columns for raw events
perf script: Display data_src values
arch/x86/kernel/cpu/perf_event_intel.c | 39 +++++++++++++
tools/perf/Documentation/perf-record.txt | 6 ++
tools/perf/builtin-mem.c | 96 +++++++++++++++++++++++++++---
tools/perf/builtin-record.c | 4 ++
tools/perf/builtin-script.c | 41 ++++++++++++-
tools/perf/perf.h | 2 +
tools/perf/util/Build | 1 +
tools/perf/util/evsel.c | 10 ++++
tools/perf/util/mem-events.c | 289 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/mem-events.h | 56 ++++++++++++++++++
tools/perf/util/sort.c | 148 ++--------------------------------------------
tools/perf/util/sort.h | 11 ++++
12 files changed, 551 insertions(+), 152 deletions(-)
create mode 100644 tools/perf/util/mem-events.c
create mode 100644 tools/perf/util/mem-events.h
[toc] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 10/23] perf x86 intel: Add DATALA events into sysfs |
| Message-ID | <r2mRl-6Rc-19@gated-at.bofh.it> |
| In reply to | #1334248 |
Adding DATALA events into Haaswell events sysfs
directory, so it's easier to use them.
Adding all DATALA events as specified by Intel SDM
manual 18.10.3 PEBS Data Address Profiling.
Link: http://lkml.kernel.org/n/tip-dvpk5ys80v41oh5xgqvloviw@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
arch/x86/kernel/cpu/perf_event_intel.c | 39 ++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index fed2ab1f1065..aadccb782e78 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -3253,6 +3253,26 @@ static __init void intel_ht_bug(void)
EVENT_ATTR_STR(mem-loads, mem_ld_hsw, "event=0xcd,umask=0x1,ldlat=3");
EVENT_ATTR_STR(mem-stores, mem_st_hsw, "event=0xd0,umask=0x82")
+EVENT_ATTR_STR(mem-stlb-miss-loads, hsw_stlb_miss_loads, "event=0xd0,umask=0x11");
+EVENT_ATTR_STR(mem-stlb-miss-stores, hsw_stlb_miss_stores, "event=0xd0,umask=0x12");
+EVENT_ATTR_STR(mem-lock-loads, hsw_lock_loads, "event=0xd0,umask=0x21");
+EVENT_ATTR_STR(mem-split-loads, hsw_split_loads, "event=0xd0,umask=0x41");
+EVENT_ATTR_STR(mem-split-stores, hsw_split_stores, "event=0xd0,umask=0x42");
+EVENT_ATTR_STR(mem-all-loads, hsw_all_loads, "event=0xd0,umask=0x81");
+EVENT_ATTR_STR(mem-all-stores, hsw_all_stores, "event=0xd0,umask=0x82");
+EVENT_ATTR_STR(mem-load-l1-hit, hsw_load_l1_hit, "event=0xd1,umask=0x01");
+EVENT_ATTR_STR(mem-load-l2-hit, hsw_load_l2_hit, "event=0xd1,umask=0x02");
+EVENT_ATTR_STR(mem-load-l3-hit, hsw_load_l3_hit, "event=0xd1,umask=0x04");
+EVENT_ATTR_STR(mem-load-l1-miss, hsw_load_l1_miss, "event=0xd1,umask=0x08");
+EVENT_ATTR_STR(mem-load-l2-miss, hsw_load_l2_miss, "event=0xd1,umask=0x10");
+EVENT_ATTR_STR(mem-load-l3-miss, hsw_load_l3_miss, "event=0xd1,umask=0x20");
+EVENT_ATTR_STR(mem-load-hit-lfb, hsw_load_hit_lfb, "event=0xd1,umask=0x40");
+EVENT_ATTR_STR(mem-snp-miss, hsw_snp_miss, "event=0xd2,umask=0x01");
+EVENT_ATTR_STR(mem-snp-hit, hsw_snp_hit, "event=0xd2,umask=0x02");
+EVENT_ATTR_STR(mem-snp-hitm, hsw_snp_hitm, "event=0xd2,umask=0x04");
+EVENT_ATTR_STR(mem-snp-none, hsw_snp_none, "event=0xd2,umask=0x08");
+EVENT_ATTR_STR(mem-local-dram, hsw_local_dram, "event=0xd3,umask=0x01");
+
/* Haswell special events */
EVENT_ATTR_STR(tx-start, tx_start, "event=0xc9,umask=0x1");
EVENT_ATTR_STR(tx-commit, tx_commit, "event=0xc9,umask=0x2");
@@ -3282,6 +3302,25 @@ static struct attribute *hsw_events_attrs[] = {
EVENT_PTR(cycles_ct),
EVENT_PTR(mem_ld_hsw),
EVENT_PTR(mem_st_hsw),
+ EVENT_PTR(hsw_stlb_miss_loads),
+ EVENT_PTR(hsw_stlb_miss_stores),
+ EVENT_PTR(hsw_lock_loads),
+ EVENT_PTR(hsw_split_loads),
+ EVENT_PTR(hsw_split_stores),
+ EVENT_PTR(hsw_all_loads),
+ EVENT_PTR(hsw_all_stores),
+ EVENT_PTR(hsw_load_l1_hit),
+ EVENT_PTR(hsw_load_l2_hit),
+ EVENT_PTR(hsw_load_l3_hit),
+ EVENT_PTR(hsw_load_l1_miss),
+ EVENT_PTR(hsw_load_l2_miss),
+ EVENT_PTR(hsw_load_l3_miss),
+ EVENT_PTR(hsw_load_hit_lfb),
+ EVENT_PTR(hsw_snp_miss),
+ EVENT_PTR(hsw_snp_hit),
+ EVENT_PTR(hsw_snp_hitm),
+ EVENT_PTR(hsw_snp_none),
+ EVENT_PTR(hsw_local_dram),
NULL
};
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 11/23] perf mem: Add Intel DATALA memory events |
| Message-ID | <r2mRl-6Rc-35@gated-at.bofh.it> |
| In reply to | #1334248 |
Adding Intel DATALA memory events into
perf mem record command:
$ perf mem record -e list
[ok] ldlat-loads
[ok] ldlat-stores
stlb-miss-loads
stlb-miss-stores
lock-loads
split-loads
split-stores
all-loads
all-stores
l1-hit
l2-hit
l3-hit
l1-miss
l2-miss
l3-miss
lfb
snp-miss
snp-hit
snp-hitm
snp-none
local-dram
All events from above lists are compiled in, but only
those with [ok] are supported by kernel/HW. You need
previous DATALA patch to support all of them.
Link: http://lkml.kernel.org/n/tip-cximteb8r1a6750wz8sgeajh@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/mem-events.c | 19 +++++++++++++++++++
tools/perf/util/mem-events.h | 19 +++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 3772a3a8a6ee..92d3bc9914e6 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -16,6 +16,25 @@ unsigned int perf_mem_events__loads_ldlat = 30;
struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
E("ldlat-loads", "cpu/mem-loads,ldlat=%u/P", "mem-loads"),
E("ldlat-stores", "cpu/mem-stores/P", "mem-stores"),
+ E("stlb-miss-loads", "cpu/mem-stlb-miss-loads/P", "mem-stlb-miss-loads"),
+ E("stlb-miss-stores", "cpu/mem-stlb-miss-stores/P", "mem-stlb-miss-stores"),
+ E("lock-loads", "cpu/mem-lock-loads/P", "mem-lock-loads"),
+ E("split-loads", "cpu/mem-split-loads/P", "mem-split-loads"),
+ E("split-stores", "cpu/mem-split-stores/P", "mem-split-stores"),
+ E("all-loads", "cpu/mem-all-loads/P", "mem-all-loads"),
+ E("all-stores", "cpu/mem-all-stores/P", "mem-all-stores"),
+ E("l1-hit", "cpu/mem-load-l1-hit/P", "mem-load-l1-hit"),
+ E("l2-hit", "cpu/mem-load-l2-hit/P", "mem-load-l2-hit"),
+ E("l3-hit", "cpu/mem-load-l3-hit/P", "mem-load-l3-hit"),
+ E("l1-miss", "cpu/mem-load-l1-miss/P", "mem-load-l1-miss"),
+ E("l2-miss", "cpu/mem-load-l2-miss/P", "mem-load-l2-miss"),
+ E("l3-miss", "cpu/mem-load-l3-miss/P", "mem-load-l3-miss"),
+ E("lfb", "cpu/mem-load-hit-lfb/P", "mem-load-hit-lfb"),
+ E("snp-miss", "cpu/mem-snp-miss/P", "mem-snp-miss"),
+ E("snp-hit", "cpu/mem-snp-hit/P", "mem-snp-hit"),
+ E("snp-hitm", "cpu/mem-snp-hitm/P", "mem-snp-hitm"),
+ E("snp-none", "cpu/mem-snp-none/P", "mem-snp-none"),
+ E("local-dram", "cpu/mem-local-dram/P", "mem-local-dram"),
};
#undef E
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index d690907f7e50..4abf606b256b 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -14,6 +14,25 @@ struct perf_mem_event {
enum {
PERF_MEM_EVENTS__LOAD,
PERF_MEM_EVENTS__STORE,
+ PERF_MEM_EVENTS__STLB_MISS_LOADS,
+ PERF_MEM_EVENTS__STLB_MISS_STORES,
+ PERF_MEM_EVENTS__LOCK_LOADS,
+ PERF_MEM_EVENTS__SPLIT_LOADS,
+ PERF_MEM_EVENTS__SPLIT_STORES,
+ PERF_MEM_EVENTS__ALL_LOADS,
+ PERF_MEM_EVENTS__ALL_STORES,
+ PERF_MEM_EVENTS__L1_HIT,
+ PERF_MEM_EVENTS__L2_HIT,
+ PERF_MEM_EVENTS__L3_HIT,
+ PERF_MEM_EVENTS__L1_MISS,
+ PERF_MEM_EVENTS__L2_MISS,
+ PERF_MEM_EVENTS__L3_MISS,
+ PERF_MEM_EVENTS__LFB,
+ PERF_MEM_EVENTS__SNP_MISS,
+ PERF_MEM_EVENTS__SNP_HIT,
+ PERF_MEM_EVENTS__SNP_HITM,
+ PERF_MEM_EVENTS__SNP_NONE,
+ PERF_MEM_EVENTS__LOCAL_DRAM,
PERF_MEM_EVENTS__MAX,
};
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 18/23] perf tools: Change perf_mem__lvl_scnprintf to return nb of displayed bytes |
| Message-ID | <r2mRm-6Rc-37@gated-at.bofh.it> |
| In reply to | #1334248 |
Moving strncat/strcpy calls into scnprintf to easily track
number of displayed bytes. It will be used in following patch.
Link: http://lkml.kernel.org/n/tip-9q9h9trua9zljnw26c56memh@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/mem-events.c | 13 +++++++------
tools/perf/util/mem-events.h | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 440221ca4f8a..5f713d77ac8a 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -183,7 +183,7 @@ static const char * const mem_lvl[] = {
"Uncached",
};
-void perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
+int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
{
size_t i, l = 0;
u64 m = PERF_MEM_LVL_NA;
@@ -208,15 +208,16 @@ void perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
strcat(out, " or ");
l += 4;
}
- strncat(out, mem_lvl[i], sz - l);
- l += strlen(mem_lvl[i]);
+ l += scnprintf(out + l, sz - l, mem_lvl[i]);
}
if (*out == '\0')
- strcpy(out, "N/A");
+ l += scnprintf(out, sz - l, "N/A");
if (hit)
- strncat(out, " hit", sz - l);
+ l += scnprintf(out + l, sz - l, " hit");
if (miss)
- strncat(out, " miss", sz - l);
+ l += scnprintf(out + l, sz - l, " miss");
+
+ return l;
}
static const char * const snoop_access[] = {
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index ce9ed0540014..a06efff4ef09 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -46,7 +46,7 @@ char *perf_mem_events__name(int i);
struct mem_info;
int perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
-void perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
+int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
void perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
void perf_mem__lck_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 13/23] perf tools: Introduce perf_mem__tlb_scnprintf function |
| Message-ID | <r2mRl-6Rc-29@gated-at.bofh.it> |
| In reply to | #1334248 |
Move meminfo's tlb display function into mem-events.c
object, so it could be reused later from script code.
Link: http://lkml.kernel.org/n/tip-kdsvxdm3ucwknyvkluwavydh@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/mem-events.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/mem-events.h | 3 +++
tools/perf/util/sort.c | 44 ++---------------------------------------
3 files changed, 52 insertions(+), 42 deletions(-)
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 92d3bc9914e6..68f6f8e4922a 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -8,6 +8,7 @@
#include <api/fs/fs.h>
#include "mem-events.h"
#include "debug.h"
+#include "symbol.h"
unsigned int perf_mem_events__loads_ldlat = 30;
@@ -117,3 +118,49 @@ int perf_mem_events__init(void)
return found ? 0 : -ENOENT;
}
+
+static const char * const tlb_access[] = {
+ "N/A",
+ "HIT",
+ "MISS",
+ "L1",
+ "L2",
+ "Walker",
+ "Fault",
+};
+
+void perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
+{
+ size_t l = 0, i;
+ u64 m = PERF_MEM_TLB_NA;
+ u64 hit, miss;
+
+ sz -= 1; /* -1 for null termination */
+ out[0] = '\0';
+
+ if (mem_info)
+ m = mem_info->data_src.mem_dtlb;
+
+ hit = m & PERF_MEM_TLB_HIT;
+ miss = m & PERF_MEM_TLB_MISS;
+
+ /* already taken care of */
+ m &= ~(PERF_MEM_TLB_HIT|PERF_MEM_TLB_MISS);
+
+ for (i = 0; m && i < ARRAY_SIZE(tlb_access); i++, m >>= 1) {
+ if (!(m & 0x1))
+ continue;
+ if (l) {
+ strcat(out, " or ");
+ l += 4;
+ }
+ strncat(out, tlb_access[i], sz - l);
+ l += strlen(tlb_access[i]);
+ }
+ if (*out == '\0')
+ strcpy(out, "N/A");
+ if (hit)
+ strncat(out, " hit", sz - l);
+ if (miss)
+ strncat(out, " miss", sz - l);
+}
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index 4abf606b256b..1af23966e3fc 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -43,5 +43,8 @@ int perf_mem_events__parse(const char *str);
int perf_mem_events__init(void);
char *perf_mem_events__name(int i);
+
+struct mem_info;
+void perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
#endif /* __PERF_MEM_EVENTS_H */
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 5cb3e13b8f2e..b7834a5a002d 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -6,6 +6,7 @@
#include "evsel.h"
#include "evlist.h"
#include <traceevent/event-parse.h>
+#include "mem-events.h"
regex_t parent_regex;
const char default_parent_pattern[] = "^sys_|^do_page_fault";
@@ -834,53 +835,12 @@ 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 const char * const tlb_access[] = {
- "N/A",
- "HIT",
- "MISS",
- "L1",
- "L2",
- "Walker",
- "Fault",
-};
-
static int hist_entry__tlb_snprintf(struct hist_entry *he, char *bf,
size_t size, unsigned int width)
{
char out[64];
- size_t sz = sizeof(out) - 1; /* -1 for null termination */
- size_t l = 0, i;
- u64 m = PERF_MEM_TLB_NA;
- u64 hit, miss;
-
- out[0] = '\0';
-
- if (he->mem_info)
- m = he->mem_info->data_src.mem_dtlb;
-
- hit = m & PERF_MEM_TLB_HIT;
- miss = m & PERF_MEM_TLB_MISS;
-
- /* already taken care of */
- m &= ~(PERF_MEM_TLB_HIT|PERF_MEM_TLB_MISS);
-
- for (i = 0; m && i < ARRAY_SIZE(tlb_access); i++, m >>= 1) {
- if (!(m & 0x1))
- continue;
- if (l) {
- strcat(out, " or ");
- l += 4;
- }
- strncat(out, tlb_access[i], sz - l);
- l += strlen(tlb_access[i]);
- }
- if (*out == '\0')
- strcpy(out, "N/A");
- if (hit)
- strncat(out, " hit", sz - l);
- if (miss)
- strncat(out, " miss", sz - l);
+ perf_mem__tlb_scnprintf(out, sizeof(out), he->mem_info);
return repsep_snprintf(bf, size, "%-*s", width, out);
}
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 09/23] perf mem: Add -u/-k options |
| Message-ID | <r2mRm-6Rc-39@gated-at.bofh.it> |
| In reply to | #1334248 |
Add -u/-k (--all-user/--all-kernel) options to use
the perf record --all-user/--all-kernel options.
Link: http://lkml.kernel.org/n/tip-adxn5c48oe0gmjrjmq6we27q@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-mem.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 94243429bb6e..cb4aa83162a6 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -62,6 +62,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
int rec_argc, i = 0, j;
const char **rec_argv;
int ret;
+ bool all_user = false, all_kernel = false;
struct option options[] = {
OPT_CALLBACK('e', "event", &mem, "event",
"event selector. use 'perf mem record -e list' to list available events",
@@ -69,13 +70,15 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
OPT_UINTEGER('l', "ldlat", &perf_mem_events__loads_ldlat, "mem-loads latency"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
+ OPT_BOOLEAN('u', "--all-user", &all_user, "collect only user level data"),
+ OPT_BOOLEAN('k', "--all-kernel", &all_kernel, "collect only kernel level data"),
OPT_END()
};
argc = parse_options(argc, argv, options, record_mem_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
- rec_argc = argc + 7; /* max number of arguments */
+ rec_argc = argc + 9; /* max number of arguments */
rec_argv = calloc(rec_argc + 1, sizeof(char *));
if (!rec_argv)
return -1;
@@ -104,6 +107,12 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
rec_argv[i++] = perf_mem_events__name(j);
};
+ if (all_user)
+ rec_argv[i++] = "--all-user";
+
+ if (all_kernel)
+ rec_argv[i++] = "--all-kernel";
+
for (j = 0; j < argc; j++, i++)
rec_argv[i] = argv[j];
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 03/23] perf tools: Introduce cl_offset function |
| Message-ID | <r2mRm-6Rc-41@gated-at.bofh.it> |
| In reply to | #1334248 |
It'll be used in following patches.
Link: http://lkml.kernel.org/n/tip-m7dfmhya60y30hzhboeaczqk@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/sort.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 46f159f9d947..5b9c6246de6d 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -168,6 +168,12 @@ static inline u64 cl_address(u64 address)
return (address & ~(cacheline_size - 1));
}
+static inline u64 cl_offset(u64 address)
+{
+ /* return the cacheline of the address */
+ return (address & (cacheline_size - 1));
+}
+
enum sort_mode {
SORT_MODE__NORMAL,
SORT_MODE__BRANCH,
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 06/23] perf mem: Check for memory events support |
| Message-ID | <r2mRm-6Rc-45@gated-at.bofh.it> |
| In reply to | #1334248 |
Check if current kernel support available memory events
and display the status within -e list option:
$ perf mem record -e list
[ok] ldlat-loads
[ok] ldlat-stores
Link: http://lkml.kernel.org/n/tip-r8smhxjfe69q67jwt7mzs0e9@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-mem.c | 14 +++++++++++++-
tools/perf/util/mem-events.c | 35 ++++++++++++++++++++++++++++++++---
tools/perf/util/mem-events.h | 3 +++
3 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index b3f8a89ede40..e64e0aa7ba0e 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -40,7 +40,8 @@ static int parse_record_events(const struct option *opt,
for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
struct perf_mem_event *e = &perf_mem_events[j];
- fprintf(stderr, "%-20s%s",
+ fprintf(stderr, "%s%-20s%s",
+ e->supported ? "[ok] " : " ",
e->tag, verbose ? "" : "\n");
if (verbose)
fprintf(stderr, " [%s]\n", e->name);
@@ -92,6 +93,12 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
if (!perf_mem_events[j].record)
continue;
+ if (!perf_mem_events[j].supported) {
+ pr_err("failed: event '%s' not supported\n",
+ perf_mem_events[j].name);
+ return -1;
+ }
+
rec_argv[i++] = "-e";
rec_argv[i++] = perf_mem_events[j].name;
};
@@ -355,6 +362,11 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
NULL
};
+ if (perf_mem_events__init()) {
+ pr_err("failed: memory events not supported\n");
+ return -1;
+ }
+
argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
mem_usage, PARSE_OPT_STOP_AT_NON_OPTION);
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index b1507c04b257..e21853fe1312 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -2,15 +2,20 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <api/fs/fs.h>
#include "mem-events.h"
#include "debug.h"
-#define E(t, n) { .tag = t, .name = n }
+#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
- E("ldlat-loads", "cpu/mem-loads,ldlat=30/P"),
- E("ldlat-stores", "cpu/mem-stores/P"),
+ E("ldlat-loads", "cpu/mem-loads,ldlat=30/P", "mem-loads"),
+ E("ldlat-stores", "cpu/mem-stores/P", "mem-stores"),
};
+#undef E
#undef E
@@ -49,3 +54,27 @@ int perf_mem_events__parse(const char *str)
pr_err("failed: event '%s' not found, use '-e list' to get list of available events\n", str);
return -1;
}
+
+int perf_mem_events__init(void)
+{
+ const char *mnt = sysfs__mount();
+ bool found = false;
+ int j;
+
+ if (!mnt)
+ return -ENOENT;
+
+ for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
+ char path[PATH_MAX];
+ struct perf_mem_event *e = &perf_mem_events[j];
+ struct stat st;
+
+ scnprintf(path, PATH_MAX, "%s/devices/cpu/events/%s",
+ mnt, e->sysfs_name);
+
+ if (!stat(path, &st))
+ e->supported = found = true;
+ }
+
+ return found ? 0 : -ENOENT;
+}
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index 0b5247468462..b9a786346c03 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -5,8 +5,10 @@
struct perf_mem_event {
bool record;
+ bool supported;
const char *tag;
const char *name;
+ const char *sysfs_name;
};
enum {
@@ -18,6 +20,7 @@ enum {
extern struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX];
int perf_mem_events__parse(const char *str);
+int perf_mem_events__init(void);
#endif /* __PERF_MEM_EVENTS_H */
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 15/23] perf tools: Introduce perf_mem__snp_scnprintf function |
| Message-ID | <r2mRm-6Rc-43@gated-at.bofh.it> |
| In reply to | #1334248 |
Move meminfo's snp display function into mem-events.c
object, so it could be reused later from script code.
Link: http://lkml.kernel.org/n/tip-zhd9q561o49xzhrtg8cz5jui@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/mem-events.c | 34 ++++++++++++++++++++++++++++++++++
tools/perf/util/mem-events.h | 1 +
tools/perf/util/sort.c | 31 +------------------------------
3 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index f291f93ac11d..1d57defe6ea7 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -217,3 +217,37 @@ void perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
if (miss)
strncat(out, " miss", sz - l);
}
+
+static const char * const snoop_access[] = {
+ "N/A",
+ "None",
+ "Miss",
+ "Hit",
+ "HitM",
+};
+
+void perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
+{
+ size_t i, l = 0;
+ u64 m = PERF_MEM_SNOOP_NA;
+
+ sz -= 1; /* -1 for null termination */
+ out[0] = '\0';
+
+ if (mem_info)
+ m = mem_info->data_src.mem_snoop;
+
+ for (i = 0; m && i < ARRAY_SIZE(snoop_access); i++, m >>= 1) {
+ if (!(m & 0x1))
+ continue;
+ if (l) {
+ strcat(out, " or ");
+ l += 4;
+ }
+ strncat(out, snoop_access[i], sz - l);
+ l += strlen(snoop_access[i]);
+ }
+
+ if (*out == '\0')
+ strcpy(out, "N/A");
+}
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index fc6d94fc96e8..7b9e172cfa72 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -47,5 +47,6 @@ char *perf_mem_events__name(int i);
struct mem_info;
void perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
void perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
+void perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
#endif /* __PERF_MEM_EVENTS_H */
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index c7b52f4987d8..de936ce324b7 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -891,41 +891,12 @@ sort__snoop_cmp(struct hist_entry *left, struct hist_entry *right)
return (int64_t)(data_src_r.mem_snoop - data_src_l.mem_snoop);
}
-static const char * const snoop_access[] = {
- "N/A",
- "None",
- "Miss",
- "Hit",
- "HitM",
-};
-
static int hist_entry__snoop_snprintf(struct hist_entry *he, char *bf,
size_t size, unsigned int width)
{
char out[64];
- size_t sz = sizeof(out) - 1; /* -1 for null termination */
- size_t i, l = 0;
- u64 m = PERF_MEM_SNOOP_NA;
-
- out[0] = '\0';
-
- if (he->mem_info)
- m = he->mem_info->data_src.mem_snoop;
-
- for (i = 0; m && i < ARRAY_SIZE(snoop_access); i++, m >>= 1) {
- if (!(m & 0x1))
- continue;
- if (l) {
- strcat(out, " or ");
- l += 4;
- }
- strncat(out, snoop_access[i], sz - l);
- l += strlen(snoop_access[i]);
- }
-
- if (*out == '\0')
- strcpy(out, "N/A");
+ perf_mem__snp_scnprintf(out, sizeof(out), he->mem_info);
return repsep_snprintf(bf, size, "%-*s", width, out);
}
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 01/23] perf record: Add --all-user/--all-kernel options |
| Message-ID | <r2mRm-6Rc-49@gated-at.bofh.it> |
| In reply to | #1334248 |
Allow user to easily switch all events to user or
kernel space with simple --all-user or --all-kernel
options.
This will be handy within perf mem/c2c wrappers to
switch easily monitoring modes.
Link: http://lkml.kernel.org/n/tip-hdd2u0y1o8cwfpplrpzc1iqd@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/Documentation/perf-record.txt | 6 ++++++
tools/perf/builtin-record.c | 4 ++++
tools/perf/perf.h | 2 ++
tools/perf/util/evsel.c | 10 ++++++++++
4 files changed, 22 insertions(+)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index fbceb631387c..19aa17532a16 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -341,6 +341,12 @@ Specify vmlinux path which has debuginfo.
--buildid-all::
Record build-id of all DSOs regardless whether it's actually hit or not.
+--all-kernel::
+Configure all used events to run in kernel space.
+
+--all-user::
+Configure all used events to run in user space.
+
SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index caa8235ed027..b64f31a4c993 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1151,6 +1151,10 @@ struct option __record_options[] = {
"per thread proc mmap processing timeout in ms"),
OPT_BOOLEAN(0, "switch-events", &record.opts.record_switch_events,
"Record context switch events"),
+ OPT_BOOLEAN(0, "all-kernel", &record.opts.all_kernel,
+ "Configure all used events to run in kernel space."),
+ OPT_BOOLEAN(0, "all-user", &record.opts.all_user,
+ "Configure all used events to run in user space."),
OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
"clang binary to use for compiling BPF scriptlets"),
OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 90129accffbe..5381a01c0610 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -58,6 +58,8 @@ struct record_opts {
bool full_auxtrace;
bool auxtrace_snapshot_mode;
bool record_switch_events;
+ bool all_kernel;
+ bool all_user;
unsigned int freq;
unsigned int mmap_pages;
unsigned int auxtrace_mmap_pages;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 467808680ee4..6ae20d0056de 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -898,6 +898,16 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
if (evsel->precise_max)
perf_event_attr__set_max_precise_ip(attr);
+ if (opts->all_user) {
+ attr->exclude_kernel = 1;
+ attr->exclude_user = 0;
+ }
+
+ if (opts->all_kernel) {
+ attr->exclude_kernel = 0;
+ attr->exclude_user = 1;
+ }
+
/*
* Apply event specific term settings,
* it overloads any global configuration.
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-02-16 18:00 +0100 |
| Subject | Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options |
| Message-ID | <r2R8K-21y-3@gated-at.bofh.it> |
| In reply to | #1334261 |
Em Mon, Feb 15, 2016 at 09:34:31AM +0100, Jiri Olsa escreveu:
> Allow user to easily switch all events to user or
> kernel space with simple --all-user or --all-kernel
> options.
>
> This will be handy within perf mem/c2c wrappers to
> switch easily monitoring modes.
Humm, some oddities:
# perf record --all-user -e cycles -a
# perf report --tui # And then notice there are some kernel samples, zoom into kernel DSO
Samples: 7 of event 'cycles', Event count (approx.): 3158810, DSO: [kernel.vmlinux]
Overhead Comman Symbol
84.05% chrome [k] page_fault
15.73% chrome [k] entry_SYSCALL_64
0.22% chrome [k] apic_timer_interrupt
Ditto when using --all-kernel, some userspace samples are there, also perhaps we
should show "cycles:u" or "cycles:k" when this --all-user or --all-kernel features
are used.
Need to investigate why there are kernel samples when --all-user is used and
the other way around as well.
Also if I use both it quietly accepts and shows just one of them, I guess we
should bail out in case someone tries both.
- Arnaldo
> Link: http://lkml.kernel.org/n/tip-hdd2u0y1o8cwfpplrpzc1iqd@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> tools/perf/Documentation/perf-record.txt | 6 ++++++
> tools/perf/builtin-record.c | 4 ++++
> tools/perf/perf.h | 2 ++
> tools/perf/util/evsel.c | 10 ++++++++++
> 4 files changed, 22 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
> index fbceb631387c..19aa17532a16 100644
> --- a/tools/perf/Documentation/perf-record.txt
> +++ b/tools/perf/Documentation/perf-record.txt
> @@ -341,6 +341,12 @@ Specify vmlinux path which has debuginfo.
> --buildid-all::
> Record build-id of all DSOs regardless whether it's actually hit or not.
>
> +--all-kernel::
> +Configure all used events to run in kernel space.
> +
> +--all-user::
> +Configure all used events to run in user space.
> +
> SEE ALSO
> --------
> linkperf:perf-stat[1], linkperf:perf-list[1]
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index caa8235ed027..b64f31a4c993 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1151,6 +1151,10 @@ struct option __record_options[] = {
> "per thread proc mmap processing timeout in ms"),
> OPT_BOOLEAN(0, "switch-events", &record.opts.record_switch_events,
> "Record context switch events"),
> + OPT_BOOLEAN(0, "all-kernel", &record.opts.all_kernel,
> + "Configure all used events to run in kernel space."),
> + OPT_BOOLEAN(0, "all-user", &record.opts.all_user,
> + "Configure all used events to run in user space."),
> OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
> "clang binary to use for compiling BPF scriptlets"),
> OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
> diff --git a/tools/perf/perf.h b/tools/perf/perf.h
> index 90129accffbe..5381a01c0610 100644
> --- a/tools/perf/perf.h
> +++ b/tools/perf/perf.h
> @@ -58,6 +58,8 @@ struct record_opts {
> bool full_auxtrace;
> bool auxtrace_snapshot_mode;
> bool record_switch_events;
> + bool all_kernel;
> + bool all_user;
> unsigned int freq;
> unsigned int mmap_pages;
> unsigned int auxtrace_mmap_pages;
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 467808680ee4..6ae20d0056de 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -898,6 +898,16 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
> if (evsel->precise_max)
> perf_event_attr__set_max_precise_ip(attr);
>
> + if (opts->all_user) {
> + attr->exclude_kernel = 1;
> + attr->exclude_user = 0;
> + }
> +
> + if (opts->all_kernel) {
> + attr->exclude_kernel = 0;
> + attr->exclude_user = 1;
> + }
> +
> /*
> * Apply event specific term settings,
> * it overloads any global configuration.
> --
> 2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Andi Kleen <ak@linux.intel.com> |
|---|---|
| Date | 2016-02-17 04:20 +0100 |
| Subject | Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options |
| Message-ID | <r30OJ-mV-1@gated-at.bofh.it> |
| In reply to | #1335633 |
> Need to investigate why there are kernel samples when --all-user is used and > the other way around as well. This is a known issue due to skid. PEBS usually avoids it. -Andi
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-02-17 15:30 +0100 |
| Subject | Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options |
| Message-ID | <r3bh7-7Ch-1@gated-at.bofh.it> |
| In reply to | #1336029 |
Em Tue, Feb 16, 2016 at 07:10:37PM -0800, Andi Kleen escreveu: > > Need to investigate why there are kernel samples when --all-user is used and > > the other way around as well. > This is a known issue due to skid. PEBS usually avoids it. Right, thanks for pointing this out, we have to detect that :p is not being used and warn the user about this possibility, i.e. user asks for just kernel samples, tool finds user samples, tell that using :p+ may help. Now, using plain: # perf record --all-user -a sleep 2 will make it use the default which is 'cycles' with the highest precision available on the machine, and that leaves just a few samples that supposedly have the MISC_KERNEL bit set in the perf_event_attr header, those are not mapping to any mmap area known to the tool, I'm investigating what this is. I'll apply the patch as-is, we'll check later OPT_ magic to tell that those options are mutually exclusive. - Arnaldo
[toc] | [prev] | [next] | [standalone]
| From | Andi Kleen <ak@linux.intel.com> |
|---|---|
| Date | 2016-02-17 16:40 +0100 |
| Subject | Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options |
| Message-ID | <r3cmS-8kt-17@gated-at.bofh.it> |
| In reply to | #1336472 |
On Wed, Feb 17, 2016 at 11:26:16AM -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Feb 16, 2016 at 07:10:37PM -0800, Andi Kleen escreveu: > > > Need to investigate why there are kernel samples when --all-user is used and > > > the other way around as well. > > > This is a known issue due to skid. PEBS usually avoids it. > > Right, thanks for pointing this out, we have to detect that :p is not > being used and warn the user about this possibility, i.e. user asks for > just kernel samples, tool finds user samples, tell that using :p+ may > help. If you're really so worried about it the kernel driver could filter it. -Andi
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-02-17 15:40 +0100 |
| Subject | Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options |
| Message-ID | <r3bqO-7FR-15@gated-at.bofh.it> |
| In reply to | #1335633 |
On Tue, Feb 16, 2016 at 01:56:01PM -0300, Arnaldo Carvalho de Melo wrote: > Em Mon, Feb 15, 2016 at 09:34:31AM +0100, Jiri Olsa escreveu: > > Allow user to easily switch all events to user or > > kernel space with simple --all-user or --all-kernel > > options. > > > > This will be handy within perf mem/c2c wrappers to > > switch easily monitoring modes. > > Humm, some oddities: > > # perf record --all-user -e cycles -a > # perf report --tui # And then notice there are some kernel samples, zoom into kernel DSO > Samples: 7 of event 'cycles', Event count (approx.): 3158810, DSO: [kernel.vmlinux] > Overhead Comman Symbol > 84.05% chrome [k] page_fault > 15.73% chrome [k] entry_SYSCALL_64 > 0.22% chrome [k] apic_timer_interrupt > > Ditto when using --all-kernel, some userspace samples are there, also perhaps we > should show "cycles:u" or "cycles:k" when this --all-user or --all-kernel features > are used. > > Need to investigate why there are kernel samples when --all-user is used and > the other way around as well. > > Also if I use both it quietly accepts and shows just one of them, I guess we > should bail out in case someone tries both. right, that should be handled with warning and exit I'll do it in next version thanks, jirka
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-02-17 16:00 +0100 |
| Subject | Re: [PATCH 01/23] perf record: Add --all-user/--all-kernel options |
| Message-ID | <r3bKa-7NK-15@gated-at.bofh.it> |
| In reply to | #1336486 |
Em Wed, Feb 17, 2016 at 03:39:38PM +0100, Jiri Olsa escreveu:
> On Tue, Feb 16, 2016 at 01:56:01PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Feb 15, 2016 at 09:34:31AM +0100, Jiri Olsa escreveu:
> > > Allow user to easily switch all events to user or
> > > kernel space with simple --all-user or --all-kernel
> > > options.
> > >
> > > This will be handy within perf mem/c2c wrappers to
> > > switch easily monitoring modes.
> >
> > Humm, some oddities:
> >
> > # perf record --all-user -e cycles -a
> > # perf report --tui # And then notice there are some kernel samples, zoom into kernel DSO
> > Samples: 7 of event 'cycles', Event count (approx.): 3158810, DSO: [kernel.vmlinux]
> > Overhead Comman Symbol
> > 84.05% chrome [k] page_fault
> > 15.73% chrome [k] entry_SYSCALL_64
> > 0.22% chrome [k] apic_timer_interrupt
> >
> > Ditto when using --all-kernel, some userspace samples are there, also perhaps we
> > should show "cycles:u" or "cycles:k" when this --all-user or --all-kernel features
> > are used.
> >
> > Need to investigate why there are kernel samples when --all-user is used and
> > the other way around as well.
> >
> > Also if I use both it quietly accepts and shows just one of them, I guess we
> > should bail out in case someone tries both.
>
> right, that should be handled with warning and exit
> I'll do it in next version
Ok, so I'll wait for it then,
builtin-probe.c uses things like:
set_option_flag(options, 'a', "add", PARSE_OPT_EXCLUSIVE);
set_option_flag(options, 'd', "del", PARSE_OPT_EXCLUSIVE);
We have:
#define OPT_BOOLEAN_FLAG(s, l, v, h, f) { .type = OPTION_BOOLEAN,
.short_name = (s), .long_name = (l), .value = check_vtype(v, bool *),
.help = (h), .flags = (f) }
That allows setting that PARSE_OPT_EXCLUSIVE flag, but we don't have
_FLAG variants for all opt types, for instance there is no
OPT_CALLBACK_FLAG() that could be used in builtin-probe.c to avoid those
unconditional set_option_flag(EXCLUSIVE) :-\
- Arnaldo
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Jiri Olsa <tipbot@zytor.com> |
|---|---|
| Date | 2016-02-20 12:40 +0100 |
| Subject | [tip:perf/core] perf record: Add --all-user/--all-kernel options |
| Message-ID | <r4e3g-4EY-15@gated-at.bofh.it> |
| In reply to | #1334261 |
Commit-ID: 85723885feb823b4fc352b727ece0b6d00306c4d
Gitweb: http://git.kernel.org/tip/85723885feb823b4fc352b727ece0b6d00306c4d
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 15 Feb 2016 09:34:31 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 18 Feb 2016 10:48:44 -0300
perf record: Add --all-user/--all-kernel options
Allow user to easily switch all events to user or kernel space with simple
--all-user or --all-kernel options.
This will be handy within perf mem/c2c wrappers to switch easily monitoring
modes.
Committer note:
Testing it:
# perf record --all-kernel --all-user -a sleep 2
Error: option `all-user' cannot be used with all-kernel
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
--all-user Configure all used events to run in user space.
--all-kernel Configure all used events to run in kernel space.
# perf record --all-user --all-kernel -a sleep 2
Error: option `all-kernel' cannot be used with all-user
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
--all-kernel Configure all used events to run in kernel space.
--all-user Configure all used events to run in user space.
# perf record --all-user -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.416 MB perf.data (162 samples) ]
# perf report | grep '\[k\]'
# perf record --all-kernel -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.423 MB perf.data (296 samples) ]
# perf report | grep '\[\.\]'
#
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1455525293-8671-2-git-send-email-jolsa@kernel.org
[ Made those options to be mutually exclusive ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/Documentation/perf-record.txt | 6 ++++++
tools/perf/builtin-record.c | 6 ++++++
tools/perf/perf.h | 2 ++
tools/perf/util/evsel.c | 10 ++++++++++
4 files changed, 24 insertions(+)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index fbceb63..19aa175 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -341,6 +341,12 @@ Specify vmlinux path which has debuginfo.
--buildid-all::
Record build-id of all DSOs regardless whether it's actually hit or not.
+--all-kernel::
+Configure all used events to run in kernel space.
+
+--all-user::
+Configure all used events to run in user space.
+
SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 0ee0d5c..cf3a28d 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1140,6 +1140,12 @@ struct option __record_options[] = {
"per thread proc mmap processing timeout in ms"),
OPT_BOOLEAN(0, "switch-events", &record.opts.record_switch_events,
"Record context switch events"),
+ OPT_BOOLEAN_FLAG(0, "all-kernel", &record.opts.all_kernel,
+ "Configure all used events to run in kernel space.",
+ PARSE_OPT_EXCLUSIVE),
+ OPT_BOOLEAN_FLAG(0, "all-user", &record.opts.all_user,
+ "Configure all used events to run in user space.",
+ PARSE_OPT_EXCLUSIVE),
OPT_STRING(0, "clang-path", &llvm_param.clang_path, "clang path",
"clang binary to use for compiling BPF scriptlets"),
OPT_STRING(0, "clang-opt", &llvm_param.clang_opt, "clang options",
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 90129ac..5381a01 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -58,6 +58,8 @@ struct record_opts {
bool full_auxtrace;
bool auxtrace_snapshot_mode;
bool record_switch_events;
+ bool all_kernel;
+ bool all_user;
unsigned int freq;
unsigned int mmap_pages;
unsigned int auxtrace_mmap_pages;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 4678086..6ae20d0 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -898,6 +898,16 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
if (evsel->precise_max)
perf_event_attr__set_max_precise_ip(attr);
+ if (opts->all_user) {
+ attr->exclude_kernel = 1;
+ attr->exclude_user = 0;
+ }
+
+ if (opts->all_kernel) {
+ attr->exclude_kernel = 0;
+ attr->exclude_user = 1;
+ }
+
/*
* Apply event specific term settings,
* it overloads any global configuration.
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 17/23] perf tools: Change perf_mem__tlb_scnprintf to return nb of displayed bytes |
| Message-ID | <r2mRm-6Rc-53@gated-at.bofh.it> |
| In reply to | #1334248 |
Moving strncat/strcpy calls into scnprintf to easily track
number of displayed bytes. It will be used in following patch.
Link: http://lkml.kernel.org/n/tip-9q9h9trua9zljnw26c56memh@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/mem-events.c | 13 +++++++------
tools/perf/util/mem-events.h | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 915fae6ad3ee..440221ca4f8a 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -129,7 +129,7 @@ static const char * const tlb_access[] = {
"Fault",
};
-void perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
+int perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
{
size_t l = 0, i;
u64 m = PERF_MEM_TLB_NA;
@@ -154,15 +154,16 @@ void perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
strcat(out, " or ");
l += 4;
}
- strncat(out, tlb_access[i], sz - l);
- l += strlen(tlb_access[i]);
+ l += scnprintf(out + l, sz - l, tlb_access[i]);
}
if (*out == '\0')
- strcpy(out, "N/A");
+ l += scnprintf(out, sz - l, "N/A");
if (hit)
- strncat(out, " hit", sz - l);
+ l += scnprintf(out + l, sz - l, " hit");
if (miss)
- strncat(out, " miss", sz - l);
+ l += scnprintf(out + l, sz - l, " miss");
+
+ return l;
}
static const char * const mem_lvl[] = {
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index 0dd2efb37c44..ce9ed0540014 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -45,7 +45,7 @@ int perf_mem_events__init(void);
char *perf_mem_events__name(int i);
struct mem_info;
-void perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
+int perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
void perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
void perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
void perf_mem__lck_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 23/23] perf script: Display data_src values |
| Message-ID | <r2mRm-6Rc-59@gated-at.bofh.it> |
| In reply to | #1334248 |
Adding support to display data_src values,
for events with data_src data in sample.
Example:
$ perf script
...
rcuos/3 32 [002] ... 68501042 Local RAM hit|SNP None or Hit|TLB L1 or L2 hit|LCK No ...
rcuos/3 32 [002] ... 68100142 L1 hit|SNP None|TLB L1 or L2 hit|LCK No ...
swapper 0 [002] ... 68100242 LFB hit|SNP None|TLB L1 or L2 hit|LCK No ...
swapper 0 [000] ... 68100142 L1 hit|SNP None|TLB L1 or L2 hit|LCK No ...
swapper 0 [000] ... 50100142 L1 hit|SNP None|TLB L2 miss|LCK No ...
rcuos/3 32 [002] ... 68100142 L1 hit|SNP None|TLB L1 or L2 hit|LCK No ...
plugin-containe 16538 [000] ... 6a100142 L1 hit|SNP None|TLB L1 or L2 hit|LCK Yes ...
gkrellm 1736 [000] ... 68100242 LFB hit|SNP None|TLB L1 or L2 hit|LCK No ...
gkrellm 1736 [000] ... 6a100142 L1 hit|SNP None|TLB L1 or L2 hit|LCK Yes ...
^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
data_src value data_src translation
Link: http://lkml.kernel.org/n/tip-48x7lm7d765bzo3oghap376m@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-script.c | 20 +++++++++++++++++++-
tools/perf/util/mem-events.c | 15 +++++++++++++++
tools/perf/util/mem-events.h | 2 ++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index f4caf4898245..8ff5ff0fe38c 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -23,6 +23,7 @@
#include "util/stat.h"
#include <linux/bitmap.h>
#include "asm/bug.h"
+#include "util/mem-events.h"
static char const *script_name;
static char const *generate_script_lang;
@@ -649,6 +650,23 @@ static int perf_evlist__max_name_len(struct perf_evlist *evlist)
return max;
}
+static size_t data_src__printf(u64 data_src)
+{
+ struct mem_info mi = { .data_src.val = data_src };
+ char decode[100];
+ char out[100];
+ static int maxlen;
+ int len;
+
+ perf_script__meminfo_scnprintf(decode, 100, &mi);
+
+ len = scnprintf(out, 100, "%16" PRIx64 " %s", data_src, decode);
+ if (maxlen < len)
+ maxlen = len;
+
+ return printf("%-*s", maxlen, out);
+}
+
static void process_event(struct perf_script *script, union perf_event *event,
struct perf_sample *sample, struct perf_evsel *evsel,
struct addr_location *al)
@@ -689,7 +707,7 @@ static void process_event(struct perf_script *script, union perf_event *event,
print_sample_addr(event, sample, thread, attr);
if (PRINT_FIELD(DATA_SRC))
- printf("%16" PRIx64, sample->data_src);
+ data_src__printf(sample->data_src);
if (PRINT_FIELD(WEIGHT))
printf("%16" PRIu64, sample->weight);
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index 0da707da127c..31e079a1ab7b 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -272,3 +272,18 @@ int perf_mem__lck_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
return l;
}
+
+int perf_script__meminfo_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
+{
+ int i = 0;
+
+ i += perf_mem__lvl_scnprintf(out, sz, mem_info);
+ i += scnprintf(out + i, sz - i, "|SNP ");
+ i += perf_mem__snp_scnprintf(out + i, sz - i, mem_info);
+ i += scnprintf(out + i, sz - i, "|TLB ");
+ i += perf_mem__tlb_scnprintf(out + i, sz - i, mem_info);
+ i += scnprintf(out + i, sz - i, "|LCK ");
+ i += perf_mem__lck_scnprintf(out + i, sz - i, mem_info);
+
+ return i;
+}
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index 759d35da2d6a..0f63d6a1c53a 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -50,5 +50,7 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
int perf_mem__snp_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
int perf_mem__lck_scnprintf(char *out, size_t sz, struct mem_info *mem_info);
+int perf_script__meminfo_scnprintf(char *bf, size_t size, struct mem_info *mem_info);
+
#endif /* __PERF_MEM_EVENTS_H */
--
2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Date | 2016-02-15 09:40 +0100 |
| Subject | [PATCH 05/23] perf mem: Add -e record option |
| Message-ID | <r2mRn-6Rc-61@gated-at.bofh.it> |
| In reply to | #1334248 |
Adding -e option for perf mem record command,
to be able to specify memory event directly.
Get list of available events:
$ perf mem record -e list
ldlat-loads
ldlat-stores
Monitor ldlat-loads:
$ perf mem record -e ldlat-loads true
Link: http://lkml.kernel.org/n/tip-x5famenpxjfmhojzo95sf26s@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-mem.c | 63 +++++++++++++++++++++++++++++++++++++++++---
tools/perf/util/mem-events.c | 47 ++++++++++++++++++++++++++++++---
tools/perf/util/mem-events.h | 3 +++
3 files changed, 106 insertions(+), 7 deletions(-)
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 36c56a4b778b..b3f8a89ede40 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -7,6 +7,7 @@
#include "util/session.h"
#include "util/data.h"
#include "util/mem-events.h"
+#include "util/debug.h"
#define MEM_OPERATION_LOAD 0x1
#define MEM_OPERATION_STORE 0x2
@@ -22,11 +23,55 @@ struct perf_mem {
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
};
+static int parse_record_events(const struct option *opt,
+ const char *str, int unset __maybe_unused)
+{
+ struct perf_mem *mem = *(struct perf_mem **)opt->value;
+ int j;
+
+ if (strcmp(str, "list")) {
+ if (!perf_mem_events__parse(str)) {
+ mem->operation = 0;
+ return 0;
+ }
+ exit(-1);
+ }
+
+ for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
+ struct perf_mem_event *e = &perf_mem_events[j];
+
+ fprintf(stderr, "%-20s%s",
+ e->tag, verbose ? "" : "\n");
+ if (verbose)
+ fprintf(stderr, " [%s]\n", e->name);
+ }
+ exit(0);
+}
+
+static const char * const __usage[] = {
+ "perf mem record [<options>] [<command>]",
+ "perf mem record [<options>] -- <command> [<options>]",
+ NULL
+};
+
+static const char * const *record_mem_usage = __usage;
+
static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
{
int rec_argc, i = 0, j;
const char **rec_argv;
int ret;
+ struct option options[] = {
+ OPT_CALLBACK('e', "event", &mem, "event",
+ "event selector. use 'perf mem record -e list' to list available events",
+ parse_record_events),
+ OPT_INCR('v', "verbose", &verbose,
+ "be more verbose (show counter open errors, etc)"),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, options, record_mem_usage,
+ PARSE_OPT_STOP_AT_NON_OPTION);
rec_argc = argc + 7; /* max number of arguments */
rec_argv = calloc(rec_argc + 1, sizeof(char *));
@@ -35,10 +80,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
rec_argv[i++] = "record";
- if (mem->operation & MEM_OPERATION_LOAD) {
+ if (mem->operation & MEM_OPERATION_LOAD)
perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true;
+
+ if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record)
rec_argv[i++] = "-W";
- }
rec_argv[i++] = "-d";
@@ -50,9 +96,19 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
rec_argv[i++] = perf_mem_events[j].name;
};
- for (j = 1; j < argc; j++, i++)
+ for (j = 0; j < argc; j++, i++)
rec_argv[i] = argv[j];
+ if (verbose > 0) {
+ pr_debug("calling: record ");
+
+ while (rec_argv[j]) {
+ pr_debug("%s ", rec_argv[j]);
+ j++;
+ }
+ pr_debug("\n");
+ }
+
ret = cmd_record(i, rec_argv, NULL);
free(rec_argv);
return ret;
@@ -299,7 +355,6 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
NULL
};
-
argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
mem_usage, PARSE_OPT_STOP_AT_NON_OPTION);
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c
index c6ba0a19ec9a..b1507c04b257 100644
--- a/tools/perf/util/mem-events.c
+++ b/tools/perf/util/mem-events.c
@@ -1,10 +1,51 @@
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
#include "mem-events.h"
+#include "debug.h"
-#define E(n) { .name = n }
+#define E(t, n) { .tag = t, .name = n }
struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
- E("cpu/mem-loads,ldlat=30/P"),
- E("cpu/mem-stores/P"),
+ E("ldlat-loads", "cpu/mem-loads,ldlat=30/P"),
+ E("ldlat-stores", "cpu/mem-stores/P"),
};
#undef E
+
+int perf_mem_events__parse(const char *str)
+{
+ char *tok, *saveptr = NULL;
+ bool found = false;
+ char *buf;
+ int j;
+
+ /* We need buffer that we know we can write to. */
+ buf = malloc(strlen(str) + 1);
+ if (!buf)
+ return -ENOMEM;
+
+ strcpy(buf, str);
+
+ tok = strtok_r((char *)buf, ",", &saveptr);
+
+ while (tok) {
+ for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
+ struct perf_mem_event *e = &perf_mem_events[j];
+
+ if (strstr(e->tag, tok))
+ e->record = found = true;
+ }
+
+ tok = strtok_r(NULL, ",", &saveptr);
+ }
+
+ free(buf);
+
+ if (found)
+ return 0;
+
+ pr_err("failed: event '%s' not found, use '-e list' to get list of available events\n", str);
+ return -1;
+}
diff --git a/tools/perf/util/mem-events.h b/tools/perf/util/mem-events.h
index ee5fde222389..0b5247468462 100644
--- a/tools/perf/util/mem-events.h
+++ b/tools/perf/util/mem-events.h
@@ -5,6 +5,7 @@
struct perf_mem_event {
bool record;
+ const char *tag;
const char *name;
};
@@ -16,5 +17,7 @@ enum {
extern struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX];
+int perf_mem_events__parse(const char *str);
+
#endif /* __PERF_MEM_EVENTS_H */
--
2.4.3
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web