diff options
author | Jiri Olsa <jolsa@kernel.org> | 2016-02-24 11:46:46 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-02-24 16:20:08 +0300 |
commit | 0c877d759d3a62a01d75dc6de4a923a686bb285a (patch) | |
tree | 3bda106da2feea8dd3f727cd5b6ec4eb7c24ef0c /tools/perf/util/mem-events.c | |
parent | 2ba7ac5814a6952aad647ce31696b893772cbe83 (diff) | |
download | linux-0c877d759d3a62a01d75dc6de4a923a686bb285a.tar.xz |
perf tools: Introduce perf_mem__tlb_scnprintf function
Move meminfo's tlb display function into mem-events.c object, so it
could be reused later from script code.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
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/1456303616-26926-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/mem-events.c')
-rw-r--r-- | tools/perf/util/mem-events.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index 2330db510976..4be3eb74001b 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" #define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s } @@ -83,3 +84,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); +} |