]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf mem: Show absolute percent in mem_stat output
authorNamhyung Kim <namhyung@kernel.org>
Fri, 23 May 2025 22:21:57 +0000 (15:21 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 28 May 2025 17:42:20 +0000 (14:42 -0300)
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.

Reviewed-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20250523222157.1259998-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/hist.c

index ed5c40ebd906f0768a18bc3422ecf437e36bb69e..b085eb0de84997f46fedf3907cdc287b99a37b4c 100644 (file)
@@ -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++) {