perf mem: Add --ldlat option
authorJiri Olsa <jolsa@kernel.org>
Tue, 14 Jun 2016 18:19:11 +0000 (20:19 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 15 Jun 2016 13:35:27 +0000 (10:35 -0300)
Adding --ldlat option to specify desired latency for loads event.

Specify 50 as loads event latency:

  $ perf mem record -e ldlat-loads -v --ldlat 50 true
  calling: record -W -d -e cpu/mem-loads,ldlat=50/P true

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1465928361-2442-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-mem.txt
tools/perf/builtin-mem.c
tools/perf/util/mem-events.c
tools/perf/util/mem-events.h

index 1d6092c460dd085401cbe084fed2166d84de105c..73496320fca3f871ac50024aff4a5e1b7def582b 100644 (file)
@@ -56,6 +56,9 @@ OPTIONS
 --all-user::
        Configure all used events to run in user space.
 
+--ldload::
+       Specify desired latency for loads event.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
index 1dc140c5481d61a1639de2fb5bcb2e1021b0dfc5..d608a2c9e48cd219e82697bdfa9331a477e9eeed 100644 (file)
@@ -67,6 +67,7 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
        OPT_CALLBACK('e', "event", &mem, "event",
                     "event selector. use 'perf mem record -e list' to list available events",
                     parse_record_events),
+       OPT_UINTEGER(0, "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"),
index 75465f89a4131bca863e389da525e1d51b90aae2..bbc368e7d1e4f7f9a53a329fac26d28785db9efc 100644 (file)
 #include "debug.h"
 #include "symbol.h"
 
+unsigned int perf_mem_events__loads_ldlat = 30;
+
 #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",     "mem-loads"),
+       E("ldlat-loads",        "cpu/mem-loads,ldlat=%u/P",     "mem-loads"),
        E("ldlat-stores",       "cpu/mem-stores/P",             "mem-stores"),
 };
 #undef E
 
 #undef E
 
+static char mem_loads_name[100];
+static bool mem_loads_name__init;
+
 char *perf_mem_events__name(int i)
 {
+       if (i == PERF_MEM_EVENTS__LOAD) {
+               if (!mem_loads_name__init) {
+                       mem_loads_name__init = true;
+                       scnprintf(mem_loads_name, sizeof(mem_loads_name),
+                                 perf_mem_events[i].name,
+                                 perf_mem_events__loads_ldlat);
+               }
+               return mem_loads_name;
+       }
+
        return (char *)perf_mem_events[i].name;
 }
 
index 5d6d93066a6e80e492634d6add9ad85f153211e6..7f69bf9d789da77cecd13e432874ca6e689e2a8a 100644 (file)
@@ -18,6 +18,7 @@ enum {
 };
 
 extern struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX];
+extern unsigned int perf_mem_events__loads_ldlat;
 
 int perf_mem_events__parse(const char *str);
 int perf_mem_events__init(void);