提交 2c07af13 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

perf tools: Introduce perf_mem__snp_scnprintf function

Move meminfo's snp display function into mem-events.c object, so it
could be reused later from script code.
Signed-off-by: NJiri 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-8-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 071e9a1e
...@@ -183,3 +183,37 @@ void perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info) ...@@ -183,3 +183,37 @@ void perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
if (miss) if (miss)
strncat(out, " miss", sz - l); 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");
}
...@@ -27,4 +27,5 @@ char *perf_mem_events__name(int i); ...@@ -27,4 +27,5 @@ char *perf_mem_events__name(int i);
struct mem_info; struct mem_info;
void perf_mem__tlb_scnprintf(char *out, size_t sz, struct mem_info *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__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 */ #endif /* __PERF_MEM_EVENTS_H */
...@@ -886,41 +886,12 @@ sort__snoop_cmp(struct hist_entry *left, struct hist_entry *right) ...@@ -886,41 +886,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); 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, static int hist_entry__snoop_snprintf(struct hist_entry *he, char *bf,
size_t size, unsigned int width) size_t size, unsigned int width)
{ {
char out[64]; 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); return repsep_snprintf(bf, size, "%-*s", width, out);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册