2019-11-16 07:55:31

by Qi Liu

[permalink] [raw]
Subject: [PATCH] Perf stat: Fix the ratio comments of miss-events

From: Qi Liu <[email protected]>

Perf stat displays miss ratio of L1-dcache, L1-icache, dTLB cache,
iTLB cache and LL-cache. Take L1-dcache for example, its miss ratio
is caculated as "L1-dcache-load-misses/L1-dcache-loads". So "of all
L1-dcache hits" is unsuitable to describe it, and "of all L1-dcache
accesses" seems better. The comments of L1-icache, dTLB cache, iTLB
cache and LL-cache are fixed in the same way.

Signed-off-by: Qi Liu <[email protected]>
---
tools/perf/util/stat-shadow.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 2c41d47..a3bdf2b 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -506,7 +506,8 @@ static void print_l1_dcache_misses(struct perf_stat_config *config,

color = get_ratio_color(GRC_CACHE_MISSES, ratio);

- out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%",
+ "of all L1-dcache accesses", ratio);
}

static void print_l1_icache_misses(struct perf_stat_config *config,
@@ -527,7 +528,8 @@ static void print_l1_icache_misses(struct perf_stat_config *config,
ratio = avg / total * 100.0;

color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-icache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%",
+ "of all L1-icache accesses", ratio);
}

static void print_dtlb_cache_misses(struct perf_stat_config *config,
@@ -547,7 +549,8 @@ static void print_dtlb_cache_misses(struct perf_stat_config *config,
ratio = avg / total * 100.0;

color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(config, out->ctx, color, "%7.2f%%", "of all dTLB cache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%",
+ "of all dTLB cache accesses", ratio);
}

static void print_itlb_cache_misses(struct perf_stat_config *config,
@@ -567,7 +570,8 @@ static void print_itlb_cache_misses(struct perf_stat_config *config,
ratio = avg / total * 100.0;

color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(config, out->ctx, color, "%7.2f%%", "of all iTLB cache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%",
+ "of all iTLB cache accesses", ratio);
}

static void print_ll_cache_misses(struct perf_stat_config *config,
@@ -587,7 +591,8 @@ static void print_ll_cache_misses(struct perf_stat_config *config,
ratio = avg / total * 100.0;

color = get_ratio_color(GRC_CACHE_MISSES, ratio);
- out->print_metric(config, out->ctx, color, "%7.2f%%", "of all LL-cache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%",
+ "of all LL-cache accesses", ratio);
}

/*
@@ -872,7 +877,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
if (runtime_stat_n(st, STAT_L1_DCACHE, ctx, cpu) != 0)
print_l1_dcache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(config, ctxp, NULL, NULL, "of all L1-dcache hits", 0);
+ print_metric(config, ctxp, NULL, NULL,
+ "of all L1-dcache accesses", 0);
} else if (
evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_L1I |
@@ -882,7 +888,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
if (runtime_stat_n(st, STAT_L1_ICACHE, ctx, cpu) != 0)
print_l1_icache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(config, ctxp, NULL, NULL, "of all L1-icache hits", 0);
+ print_metric(config, ctxp, NULL, NULL,
+ "of all L1-icache accesses", 0);
} else if (
evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_DTLB |
@@ -892,7 +899,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
if (runtime_stat_n(st, STAT_DTLB_CACHE, ctx, cpu) != 0)
print_dtlb_cache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(config, ctxp, NULL, NULL, "of all dTLB cache hits", 0);
+ print_metric(config, ctxp, NULL, NULL,
+ "of all dTLB cache accesses", 0);
} else if (
evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_ITLB |
@@ -902,7 +910,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
if (runtime_stat_n(st, STAT_ITLB_CACHE, ctx, cpu) != 0)
print_itlb_cache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(config, ctxp, NULL, NULL, "of all iTLB cache hits", 0);
+ print_metric(config, ctxp, NULL, NULL,
+ "of all iTLB cache accesses", 0);
} else if (
evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_LL |
@@ -912,7 +921,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
if (runtime_stat_n(st, STAT_LL_CACHE, ctx, cpu) != 0)
print_ll_cache_misses(config, cpu, evsel, avg, out, st);
else
- print_metric(config, ctxp, NULL, NULL, "of all LL-cache hits", 0);
+ print_metric(config, ctxp, NULL, NULL,
+ "of all LL-cache accesses", 0);
} else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES)) {
total = runtime_stat_avg(st, STAT_CACHEREFS, ctx, cpu);

--
2.8.1


2019-11-16 14:46:44

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] Perf stat: Fix the ratio comments of miss-events

lqqq341 <[email protected]> writes:

> From: Qi Liu <[email protected]>
>
> Perf stat displays miss ratio of L1-dcache, L1-icache, dTLB cache,
> iTLB cache and LL-cache. Take L1-dcache for example, its miss ratio
> is caculated as "L1-dcache-load-misses/L1-dcache-loads". So "of all
> L1-dcache hits" is unsuitable to describe it, and "of all L1-dcache
> accesses" seems better. The comments of L1-icache, dTLB cache, iTLB
> cache and LL-cache are fixed in the same way.

Reviewed-by: Andi Kleen <[email protected]>

-Andi

2019-11-19 16:01:58

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] Perf stat: Fix the ratio comments of miss-events

Em Sat, Nov 16, 2019 at 03:48:41PM +0800, lqqq341 escreveu:
> From: Qi Liu <[email protected]>
>
> Perf stat displays miss ratio of L1-dcache, L1-icache, dTLB cache,
> iTLB cache and LL-cache. Take L1-dcache for example, its miss ratio
> is caculated as "L1-dcache-load-misses/L1-dcache-loads". So "of all
> L1-dcache hits" is unsuitable to describe it, and "of all L1-dcache
> accesses" seems better. The comments of L1-icache, dTLB cache, iTLB
> cache and LL-cache are fixed in the same way.
>
> Signed-off-by: Qi Liu <[email protected]>
> ---
> tools/perf/util/stat-shadow.c | 30 ++++++++++++++++++++----------
> 1 file changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
> index 2c41d47..a3bdf2b 100644
> --- a/tools/perf/util/stat-shadow.c
> +++ b/tools/perf/util/stat-shadow.c
> @@ -506,7 +506,8 @@ static void print_l1_dcache_misses(struct perf_stat_config *config,
>
> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
>
> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio);
> + out->print_metric(config, out->ctx, color, "%7.2f%%",
> + "of all L1-dcache accesses", ratio);


Why have you reflowed all those lines? This patch should have been like:

- out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache accesses", ratio);

Notice how it is easier to compare the changes, and also to keep the
flowing like it was before your change,

Thanks,

- Arnaldo

> }
>
> static void print_l1_icache_misses(struct perf_stat_config *config,
> @@ -527,7 +528,8 @@ static void print_l1_icache_misses(struct perf_stat_config *config,
> ratio = avg / total * 100.0;
>
> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-icache hits", ratio);
> + out->print_metric(config, out->ctx, color, "%7.2f%%",
> + "of all L1-icache accesses", ratio);
> }
>
> static void print_dtlb_cache_misses(struct perf_stat_config *config,
> @@ -547,7 +549,8 @@ static void print_dtlb_cache_misses(struct perf_stat_config *config,
> ratio = avg / total * 100.0;
>
> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all dTLB cache hits", ratio);
> + out->print_metric(config, out->ctx, color, "%7.2f%%",
> + "of all dTLB cache accesses", ratio);
> }
>
> static void print_itlb_cache_misses(struct perf_stat_config *config,
> @@ -567,7 +570,8 @@ static void print_itlb_cache_misses(struct perf_stat_config *config,
> ratio = avg / total * 100.0;
>
> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all iTLB cache hits", ratio);
> + out->print_metric(config, out->ctx, color, "%7.2f%%",
> + "of all iTLB cache accesses", ratio);
> }
>
> static void print_ll_cache_misses(struct perf_stat_config *config,
> @@ -587,7 +591,8 @@ static void print_ll_cache_misses(struct perf_stat_config *config,
> ratio = avg / total * 100.0;
>
> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all LL-cache hits", ratio);
> + out->print_metric(config, out->ctx, color, "%7.2f%%",
> + "of all LL-cache accesses", ratio);
> }
>
> /*
> @@ -872,7 +877,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
> if (runtime_stat_n(st, STAT_L1_DCACHE, ctx, cpu) != 0)
> print_l1_dcache_misses(config, cpu, evsel, avg, out, st);
> else
> - print_metric(config, ctxp, NULL, NULL, "of all L1-dcache hits", 0);
> + print_metric(config, ctxp, NULL, NULL,
> + "of all L1-dcache accesses", 0);
> } else if (
> evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
> evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_L1I |
> @@ -882,7 +888,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
> if (runtime_stat_n(st, STAT_L1_ICACHE, ctx, cpu) != 0)
> print_l1_icache_misses(config, cpu, evsel, avg, out, st);
> else
> - print_metric(config, ctxp, NULL, NULL, "of all L1-icache hits", 0);
> + print_metric(config, ctxp, NULL, NULL,
> + "of all L1-icache accesses", 0);
> } else if (
> evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
> evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_DTLB |
> @@ -892,7 +899,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
> if (runtime_stat_n(st, STAT_DTLB_CACHE, ctx, cpu) != 0)
> print_dtlb_cache_misses(config, cpu, evsel, avg, out, st);
> else
> - print_metric(config, ctxp, NULL, NULL, "of all dTLB cache hits", 0);
> + print_metric(config, ctxp, NULL, NULL,
> + "of all dTLB cache accesses", 0);
> } else if (
> evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
> evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_ITLB |
> @@ -902,7 +910,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
> if (runtime_stat_n(st, STAT_ITLB_CACHE, ctx, cpu) != 0)
> print_itlb_cache_misses(config, cpu, evsel, avg, out, st);
> else
> - print_metric(config, ctxp, NULL, NULL, "of all iTLB cache hits", 0);
> + print_metric(config, ctxp, NULL, NULL,
> + "of all iTLB cache accesses", 0);
> } else if (
> evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
> evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_LL |
> @@ -912,7 +921,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
> if (runtime_stat_n(st, STAT_LL_CACHE, ctx, cpu) != 0)
> print_ll_cache_misses(config, cpu, evsel, avg, out, st);
> else
> - print_metric(config, ctxp, NULL, NULL, "of all LL-cache hits", 0);
> + print_metric(config, ctxp, NULL, NULL,
> + "of all LL-cache accesses", 0);
> } else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES)) {
> total = runtime_stat_avg(st, STAT_CACHEREFS, ctx, cpu);
>
> --
> 2.8.1

--

- Arnaldo

2019-12-12 06:39:21

by liuqi (BA)

[permalink] [raw]
Subject: Re: [PATCH] Perf stat: Fix the ratio comments of miss-events

Hi, Arnaldo:
Thanks for your reply and sorry for replying this mail so late.

I reflowed all the lines to keep the number of characters in each line
less than 80. But I realized that the original code has exceeded 80. So
if this code format isn't necessary, and to make it easier to compare
the changes, I'll send a new patch as follow:

- out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio);
+ out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache accesses", ratio);

Thanks
Qi Liu

On 2019/11/19 23:59, Arnaldo Carvalho de Melo wrote:
> Em Sat, Nov 16, 2019 at 03:48:41PM +0800, lqqq341 escreveu:
>> From: Qi Liu <[email protected]>
>>
>> Perf stat displays miss ratio of L1-dcache, L1-icache, dTLB cache,
>> iTLB cache and LL-cache. Take L1-dcache for example, its miss ratio
>> is caculated as "L1-dcache-load-misses/L1-dcache-loads". So "of all
>> L1-dcache hits" is unsuitable to describe it, and "of all L1-dcache
>> accesses" seems better. The comments of L1-icache, dTLB cache, iTLB
>> cache and LL-cache are fixed in the same way.
>>
>> Signed-off-by: Qi Liu <[email protected]>
>> ---
>> tools/perf/util/stat-shadow.c | 30 ++++++++++++++++++++----------
>> 1 file changed, 20 insertions(+), 10 deletions(-)
>>
>> diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
>> index 2c41d47..a3bdf2b 100644
>> --- a/tools/perf/util/stat-shadow.c
>> +++ b/tools/perf/util/stat-shadow.c
>> @@ -506,7 +506,8 @@ static void print_l1_dcache_misses(struct perf_stat_config *config,
>>
>> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
>>
>> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio);
>> + out->print_metric(config, out->ctx, color, "%7.2f%%",
>> + "of all L1-dcache accesses", ratio);
>
>
> Why have you reflowed all those lines? This patch should have been like:
>
> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache hits", ratio);
> + out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-dcache accesses", ratio);
>
> Notice how it is easier to compare the changes, and also to keep the
> flowing like it was before your change,
>
> Thanks,
>
> - Arnaldo
>
>> }
>>
>> static void print_l1_icache_misses(struct perf_stat_config *config,
>> @@ -527,7 +528,8 @@ static void print_l1_icache_misses(struct perf_stat_config *config,
>> ratio = avg / total * 100.0;
>>
>> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
>> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all L1-icache hits", ratio);
>> + out->print_metric(config, out->ctx, color, "%7.2f%%",
>> + "of all L1-icache accesses", ratio);
>> }
>>
>> static void print_dtlb_cache_misses(struct perf_stat_config *config,
>> @@ -547,7 +549,8 @@ static void print_dtlb_cache_misses(struct perf_stat_config *config,
>> ratio = avg / total * 100.0;
>>
>> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
>> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all dTLB cache hits", ratio);
>> + out->print_metric(config, out->ctx, color, "%7.2f%%",
>> + "of all dTLB cache accesses", ratio);
>> }
>>
>> static void print_itlb_cache_misses(struct perf_stat_config *config,
>> @@ -567,7 +570,8 @@ static void print_itlb_cache_misses(struct perf_stat_config *config,
>> ratio = avg / total * 100.0;
>>
>> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
>> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all iTLB cache hits", ratio);
>> + out->print_metric(config, out->ctx, color, "%7.2f%%",
>> + "of all iTLB cache accesses", ratio);
>> }
>>
>> static void print_ll_cache_misses(struct perf_stat_config *config,
>> @@ -587,7 +591,8 @@ static void print_ll_cache_misses(struct perf_stat_config *config,
>> ratio = avg / total * 100.0;
>>
>> color = get_ratio_color(GRC_CACHE_MISSES, ratio);
>> - out->print_metric(config, out->ctx, color, "%7.2f%%", "of all LL-cache hits", ratio);
>> + out->print_metric(config, out->ctx, color, "%7.2f%%",
>> + "of all LL-cache accesses", ratio);
>> }
>>
>> /*
>> @@ -872,7 +877,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
>> if (runtime_stat_n(st, STAT_L1_DCACHE, ctx, cpu) != 0)
>> print_l1_dcache_misses(config, cpu, evsel, avg, out, st);
>> else
>> - print_metric(config, ctxp, NULL, NULL, "of all L1-dcache hits", 0);
>> + print_metric(config, ctxp, NULL, NULL,
>> + "of all L1-dcache accesses", 0);
>> } else if (
>> evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
>> evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_L1I |
>> @@ -882,7 +888,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
>> if (runtime_stat_n(st, STAT_L1_ICACHE, ctx, cpu) != 0)
>> print_l1_icache_misses(config, cpu, evsel, avg, out, st);
>> else
>> - print_metric(config, ctxp, NULL, NULL, "of all L1-icache hits", 0);
>> + print_metric(config, ctxp, NULL, NULL,
>> + "of all L1-icache accesses", 0);
>> } else if (
>> evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
>> evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_DTLB |
>> @@ -892,7 +899,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
>> if (runtime_stat_n(st, STAT_DTLB_CACHE, ctx, cpu) != 0)
>> print_dtlb_cache_misses(config, cpu, evsel, avg, out, st);
>> else
>> - print_metric(config, ctxp, NULL, NULL, "of all dTLB cache hits", 0);
>> + print_metric(config, ctxp, NULL, NULL,
>> + "of all dTLB cache accesses", 0);
>> } else if (
>> evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
>> evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_ITLB |
>> @@ -902,7 +910,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
>> if (runtime_stat_n(st, STAT_ITLB_CACHE, ctx, cpu) != 0)
>> print_itlb_cache_misses(config, cpu, evsel, avg, out, st);
>> else
>> - print_metric(config, ctxp, NULL, NULL, "of all iTLB cache hits", 0);
>> + print_metric(config, ctxp, NULL, NULL,
>> + "of all iTLB cache accesses", 0);
>> } else if (
>> evsel->core.attr.type == PERF_TYPE_HW_CACHE &&
>> evsel->core.attr.config == ( PERF_COUNT_HW_CACHE_LL |
>> @@ -912,7 +921,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
>> if (runtime_stat_n(st, STAT_LL_CACHE, ctx, cpu) != 0)
>> print_ll_cache_misses(config, cpu, evsel, avg, out, st);
>> else
>> - print_metric(config, ctxp, NULL, NULL, "of all LL-cache hits", 0);
>> + print_metric(config, ctxp, NULL, NULL,
>> + "of all LL-cache accesses", 0);
>> } else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES)) {
>> total = runtime_stat_avg(st, STAT_CACHEREFS, ctx, cpu);
>>
>> --
>> 2.8.1
>