Re: [PATCH v5 3/4] perf, tools: Add support for printing new mem_info encodings

Jiri Olsa
2017-08-23T13:01:51Z

On Wed, Aug 16, 2017 at 03:21:55PM -0700, Andi Kleen wrote:

SNIP

> 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;
> u64 hit, miss;
> + int printed;
>
> if (mem_info)
> m = mem_info->data_src.mem_lvl;
> @@ -184,17 +193,37 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)
> /* already taken care of */
> m &= ~(PERF_MEM_LVL_HIT|PERF_MEM_LVL_MISS);
>
> +
> + if (mem_info && mem_info->data_src.mem_remote) {
> + strcat(out, "Remote ");
> + l += 7;
> + }

Andi,
how is this 'Remote' different from the remote levels in mem_lvl?

"Remote RAM (1 hop)",
"Remote RAM (2 hops)",
"Remote Cache (1 hop)",
"Remote Cache (2 hops)",

thanks,
jirka

> +
> + printed = 0;
> for (i = 0; m && i < ARRAY_SIZE(mem_lvl); i++, m >>= 1) {
> if (!(m & 0x1))
> continue;
> - if (l) {
> + if (printed++) {
> strcat(out, " or ");
> l += 4;
> }
> l += scnprintf(out + l, sz - l, mem_lvl[i]);
> }
> - if (*out == '\0')
> - l += scnprintf(out, sz - l, "N/A");
> +
> + if (mem_info && mem_info->data_src.mem_lvl_num) {
> + int lvl = mem_info->data_src.mem_lvl_num;
> + if (printed++) {
> + strcat(out, " or ");
> + l += 4;
> + }
> + if (mem_lvlnum[lvl])
> + l += scnprintf(out + l, sz - l, mem_lvlnum[lvl]);
> + else
> + l += scnprintf(out + l, sz - l, "L%d", lvl);
> + }