* [PATCH 1/3] perf mem: Describe overhead calculation in brief
@ 2025-05-23 22:21 Namhyung Kim
2025-05-23 22:21 ` [PATCH 2/3] perf mem: Display sort order only if it's available Namhyung Kim
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Namhyung Kim @ 2025-05-23 22:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Ravi Bangoria, Leo Yan, Stephane Eranian
From: Ravi Bangoria <ravi.bangoria@amd.com>
Unlike perf-report which uses sample period for overhead calculation,
perf-mem overhead is calculated using sample weight. Describe perf-mem
overhead calculation method in it's man page.
Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/Documentation/perf-mem.txt | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
index a9e3c71a220557d4..965e73d377724607 100644
--- a/tools/perf/Documentation/perf-mem.txt
+++ b/tools/perf/Documentation/perf-mem.txt
@@ -137,6 +137,25 @@ REPORT OPTIONS
In addition, for report all perf report options are valid, and for record
all perf record options.
+OVERHEAD CALCULATION
+--------------------
+Unlike linkperf:perf-report[1], which calculates overhead from the actual
+sample period, perf-mem overhead is calculated using sample weight. E.g.
+there are two samples in perf.data file, both with the same sample period,
+but one sample with weight 180 and the other with weight 20:
+
+ $ perf script -F period,data_src,weight,ip,sym
+ 100000 629080842 |OP LOAD|LVL L3 hit|... 20 7e69b93ca524 strcmp
+ 100000 1a29081042 |OP LOAD|LVL RAM hit|... 180 ffffffff82429168 memcpy
+
+ $ perf report -F overhead,symbol
+ 50% [.] strcmp
+ 50% [k] memcpy
+
+ $ perf mem report -F overhead,symbol
+ 90% [k] memcpy
+ 10% [.] strcmp
+
SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-arm-spe[1]
--
2.49.0.1151.ga128411c76-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] perf mem: Display sort order only if it's available
2025-05-23 22:21 [PATCH 1/3] perf mem: Describe overhead calculation in brief Namhyung Kim
@ 2025-05-23 22:21 ` Namhyung Kim
2025-05-23 22:21 ` [PATCH 3/3] perf mem: Show absolute percent in mem_stat output Namhyung Kim
2025-05-27 10:12 ` [PATCH 1/3] perf mem: Describe overhead calculation in brief Leo Yan
2 siblings, 0 replies; 5+ messages in thread
From: Namhyung Kim @ 2025-05-23 22:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Ravi Bangoria, Leo Yan, Stephane Eranian
IOW it's not used when -F option is used alone. Let's make it
conditional to skip printing incorrect information.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-report.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index f0299c7ee0254a37..e662e1c3a7c6b6ec 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -529,7 +529,10 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report
if (rep->mem_mode) {
ret += fprintf(fp, "\n# Total weight : %" PRIu64, nr_events);
- ret += fprintf(fp, "\n# Sort order : %s", sort_order ? : default_mem_sort_order);
+ if (sort_order || !field_order) {
+ ret += fprintf(fp, "\n# Sort order : %s",
+ sort_order ? : default_mem_sort_order);
+ }
} else
ret += fprintf(fp, "\n# Event count (approx.): %" PRIu64, nr_events);
--
2.49.0.1151.ga128411c76-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] perf mem: Show absolute percent in mem_stat output
2025-05-23 22:21 [PATCH 1/3] perf mem: Describe overhead calculation in brief Namhyung Kim
2025-05-23 22:21 ` [PATCH 2/3] perf mem: Display sort order only if it's available Namhyung Kim
@ 2025-05-23 22:21 ` Namhyung Kim
2025-05-27 10:12 ` [PATCH 1/3] perf mem: Describe overhead calculation in brief Leo Yan
2 siblings, 0 replies; 5+ messages in thread
From: Namhyung Kim @ 2025-05-23 22:21 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Ravi Bangoria, Leo Yan, Stephane Eranian
Currently the output sums up to 100% for each entry. But it can be
confusing when it's displayed with 'overhead'.
Before:
$ perf mem report -F overhead,sample,cache,comm
...
# -------------- Cache --------------
# Overhead Samples L1 L2 L3 L1-buf Other Command
# ........ ............ ................................... ...............
#
25.38% 517 34.6% 0.0% 15.8% 23.3% 26.2% swapper
9.03% 239 35.4% 0.8% 9.1% 22.1% 32.6% chrome
8.61% 233 45.3% 1.2% 8.9% 22.7% 21.9% Chrome_ChildIOT
7.81% 189 33.6% 0.4% 5.5% 35.9% 24.6% Isolated Web Co
3.73% 103 40.4% 0.3% 2.7% 39.4% 17.2% gnome-shell
Let's convert it to use absolute percent value so that it can add up to
the overhead for that entry.
After:
# -------------- Cache --------------
# Overhead Samples L1 L2 L3 L1-buf Other Command
# ........ ............ ................................... ...............
#
25.38% 517 8.8% 0.0% 4.0% 5.9% 6.7% swapper
9.03% 239 3.2% 0.1% 0.8% 2.0% 2.9% chrome
8.61% 233 3.9% 0.1% 0.8% 2.0% 1.9% Chrome_ChildIOT
7.81% 189 2.6% 0.0% 0.4% 2.8% 1.9% Isolated Web Co
3.73% 103 1.5% 0.0% 0.1% 1.5% 0.6% gnome-shell
This aligns well with the existing 'mem' sort key.
$ perf mem report -s comm,mem -H
...
#
# Overhead Samples Command / Memory access
# ......................... ..........................................
#
25.38% 517 swapper
8.78% 150 L1 hit
6.66% 72 RAM hit
5.92% 137 LFB/MAB hit
4.02% 157 L3 hit
0.00% 1 L3 miss
9.03% 239 chrome
3.19% 117 L1 hit
2.94% 35 RAM hit
1.99% 48 LFB/MAB hit
0.82% 32 L3 hit
0.08% 5 L2 hit
0.00% 2 L3 miss
We can add an option or a config to change the setting later.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/ui/hist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index ed5c40ebd906f076..b085eb0de84997f4 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -172,7 +172,7 @@ int hpp__fmt_mem_stat(struct perf_hpp_fmt *fmt __maybe_unused, struct perf_hpp *
assert(mem_stat_idx != -1);
for (int i = 0; i < MEM_STAT_LEN; i++)
- total += he->mem_stat[mem_stat_idx].entries[i];
+ total += hists->mem_stat_total[mem_stat_idx].entries[i];
assert(total != 0);
for (int i = 0; i < MEM_STAT_LEN; i++) {
--
2.49.0.1151.ga128411c76-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] perf mem: Describe overhead calculation in brief
2025-05-23 22:21 [PATCH 1/3] perf mem: Describe overhead calculation in brief Namhyung Kim
2025-05-23 22:21 ` [PATCH 2/3] perf mem: Display sort order only if it's available Namhyung Kim
2025-05-23 22:21 ` [PATCH 3/3] perf mem: Show absolute percent in mem_stat output Namhyung Kim
@ 2025-05-27 10:12 ` Leo Yan
2025-05-28 17:43 ` Arnaldo Carvalho de Melo
2 siblings, 1 reply; 5+ messages in thread
From: Leo Yan @ 2025-05-27 10:12 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang, Jiri Olsa,
Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Ravi Bangoria, Stephane Eranian
On Fri, May 23, 2025 at 03:21:55PM -0700, Namhyung Kim wrote:
> From: Ravi Bangoria <ravi.bangoria@amd.com>
>
> Unlike perf-report which uses sample period for overhead calculation,
> perf-mem overhead is calculated using sample weight. Describe perf-mem
> overhead calculation method in it's man page.
>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
For whole series:
Reviewed-by: Leo Yan <leo.yan@arm.com>
> ---
> tools/perf/Documentation/perf-mem.txt | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-mem.txt b/tools/perf/Documentation/perf-mem.txt
> index a9e3c71a220557d4..965e73d377724607 100644
> --- a/tools/perf/Documentation/perf-mem.txt
> +++ b/tools/perf/Documentation/perf-mem.txt
> @@ -137,6 +137,25 @@ REPORT OPTIONS
> In addition, for report all perf report options are valid, and for record
> all perf record options.
>
> +OVERHEAD CALCULATION
> +--------------------
> +Unlike linkperf:perf-report[1], which calculates overhead from the actual
> +sample period, perf-mem overhead is calculated using sample weight. E.g.
> +there are two samples in perf.data file, both with the same sample period,
> +but one sample with weight 180 and the other with weight 20:
> +
> + $ perf script -F period,data_src,weight,ip,sym
> + 100000 629080842 |OP LOAD|LVL L3 hit|... 20 7e69b93ca524 strcmp
> + 100000 1a29081042 |OP LOAD|LVL RAM hit|... 180 ffffffff82429168 memcpy
> +
> + $ perf report -F overhead,symbol
> + 50% [.] strcmp
> + 50% [k] memcpy
> +
> + $ perf mem report -F overhead,symbol
> + 90% [k] memcpy
> + 10% [.] strcmp
> +
> SEE ALSO
> --------
> linkperf:perf-record[1], linkperf:perf-report[1], linkperf:perf-arm-spe[1]
> --
> 2.49.0.1151.ga128411c76-goog
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] perf mem: Describe overhead calculation in brief
2025-05-27 10:12 ` [PATCH 1/3] perf mem: Describe overhead calculation in brief Leo Yan
@ 2025-05-28 17:43 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-05-28 17:43 UTC (permalink / raw)
To: Leo Yan
Cc: Namhyung Kim, Ian Rogers, Kan Liang, Jiri Olsa, Adrian Hunter,
Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users,
Ravi Bangoria, Stephane Eranian
On Tue, May 27, 2025 at 11:12:46AM +0100, Leo Yan wrote:
> On Fri, May 23, 2025 at 03:21:55PM -0700, Namhyung Kim wrote:
> > From: Ravi Bangoria <ravi.bangoria@amd.com>
> >
> > Unlike perf-report which uses sample period for overhead calculation,
> > perf-mem overhead is calculated using sample weight. Describe perf-mem
> > overhead calculation method in it's man page.
> >
> > Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>
> For whole series:
>
> Reviewed-by: Leo Yan <leo.yan@arm.com>
Thanks, applied to perf-tools-next,
- Arnaldo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-28 17:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23 22:21 [PATCH 1/3] perf mem: Describe overhead calculation in brief Namhyung Kim
2025-05-23 22:21 ` [PATCH 2/3] perf mem: Display sort order only if it's available Namhyung Kim
2025-05-23 22:21 ` [PATCH 3/3] perf mem: Show absolute percent in mem_stat output Namhyung Kim
2025-05-27 10:12 ` [PATCH 1/3] perf mem: Describe overhead calculation in brief Leo Yan
2025-05-28 17:43 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).