]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf mem: Add 'snoop' output field
authorNamhyung Kim <namhyung@kernel.org>
Wed, 30 Apr 2025 20:55:47 +0000 (13:55 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 2 May 2025 18:36:14 +0000 (15:36 -0300)
This is a breakdown of perf_mem_data_src.mem_snoop values.  For now, it
doesn't use mem_snoopx values like FWD and PEER.

  $ perf mem report -F overhead,snoop,comm --stdio
  ...
  #           ---------- Snoop -----------
  # Overhead      Hit   HitM   Miss  Other  Command
  # ........  ............................  ...............
  #
      34.24%     0.6%   0.0%   0.0%  99.4%  gnome-shell
      12.02%     1.0%   0.0%   0.0%  99.0%  chrome
       9.32%     1.0%   0.0%   0.3%  98.7%  Isolated Web Co
       6.85%     1.0%   0.3%   0.0%  98.6%  swapper
       6.30%     0.8%   0.8%   0.0%  98.5%  Xorg
       3.02%     2.4%   0.0%   0.0%  97.6%  VizCompositorTh
       2.35%     0.0%   0.0%   0.0% 100.0%  firefox-esr
       2.04%     0.0%   0.0%   0.0% 100.0%  JS Helper
       1.51%     3.2%   0.0%   0.0%  96.8%  threaded-ml
       1.44%     0.0%   0.0%   0.0% 100.0%  AudioIP~allback
       ...

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
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>
Link: https://lore.kernel.org/r/20250430205548.789750-11-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/browsers/hists.c
tools/perf/ui/hist.c
tools/perf/util/hist.h
tools/perf/util/mem-events.c
tools/perf/util/mem-events.h
tools/perf/util/sort.c

index 675dd64067747126f9de6a4790d2b5bb8b7cef96..5b080f506244024608cd248bbba3dcdef73ddf5e 100644 (file)
@@ -1287,6 +1287,7 @@ __HPP_COLOR_ACC_PERCENT_FN(latency_acc, latency, PERF_HPP_FMT_TYPE__LATENCY)
 __HPP_COLOR_MEM_STAT_FN(op, OP)
 __HPP_COLOR_MEM_STAT_FN(cache, CACHE)
 __HPP_COLOR_MEM_STAT_FN(memory, MEMORY)
+__HPP_COLOR_MEM_STAT_FN(snoop, SNOOP)
 
 #undef __HPP_COLOR_PERCENT_FN
 #undef __HPP_COLOR_ACC_PERCENT_FN
@@ -1316,6 +1317,8 @@ void hist_browser__init_hpp(void)
                                hist_browser__hpp_color_mem_stat_cache;
        perf_hpp__format[PERF_HPP__MEM_STAT_MEMORY].color =
                                hist_browser__hpp_color_mem_stat_memory;
+       perf_hpp__format[PERF_HPP__MEM_STAT_SNOOP].color =
+                               hist_browser__hpp_color_mem_stat_snoop;
 
        res_sample_init();
 }
index 7fc09c738ed02acb54c17677aa803a78642a0116..94024dfa8dccf9ba5e51c0dcfb6ea126348e4d6b 100644 (file)
@@ -352,6 +352,8 @@ static enum mem_stat_type hpp__mem_stat_type(struct perf_hpp_fmt *fmt)
                return PERF_MEM_STAT_CACHE;
        case PERF_HPP__MEM_STAT_MEMORY:
                return PERF_MEM_STAT_MEMORY;
+       case PERF_HPP__MEM_STAT_SNOOP:
+               return PERF_MEM_STAT_SNOOP;
        default:
                break;
        }
@@ -650,6 +652,7 @@ HPP_AVERAGE_FNS(weight3, weight3)
 HPP_MEM_STAT_FNS(op, OP)
 HPP_MEM_STAT_FNS(cache, CACHE)
 HPP_MEM_STAT_FNS(memory, MEMORY)
+HPP_MEM_STAT_FNS(snoop, SNOOP)
 
 static int64_t hpp__nop_cmp(struct perf_hpp_fmt *fmt __maybe_unused,
                            struct hist_entry *a __maybe_unused,
@@ -756,6 +759,7 @@ struct perf_hpp_fmt perf_hpp__format[] = {
        HPP__MEM_STAT_PRINT_FNS("Mem Op", op, OP),
        HPP__MEM_STAT_PRINT_FNS("Cache", cache, CACHE),
        HPP__MEM_STAT_PRINT_FNS("Memory", memory, MEMORY),
+       HPP__MEM_STAT_PRINT_FNS("Snoop", snoop, SNOOP),
 };
 
 struct perf_hpp_list perf_hpp_list = {
@@ -1113,6 +1117,7 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
        case PERF_HPP__MEM_STAT_OP:
        case PERF_HPP__MEM_STAT_CACHE:
        case PERF_HPP__MEM_STAT_MEMORY:
+       case PERF_HPP__MEM_STAT_SNOOP:
                fmt->len = MEM_STAT_LEN * MEM_STAT_PRINT_LEN;
                break;
 
index 9de50d929ad1268c0893a2ce070919dd4afc8a86..c2d286c4ba395674927458bb738fcec20ac057c2 100644 (file)
@@ -591,6 +591,7 @@ enum {
        PERF_HPP__MEM_STAT_OP,
        PERF_HPP__MEM_STAT_CACHE,
        PERF_HPP__MEM_STAT_MEMORY,
+       PERF_HPP__MEM_STAT_SNOOP,
 
        PERF_HPP__MAX_INDEX
 };
index 6822815278a4b2135de4c2b3db352f2152388c00..ddcfc6500d77a9e60a62c2bed0b2293520644390 100644 (file)
@@ -857,6 +857,17 @@ int mem_stat_index(const enum mem_stat_type mst, const u64 val)
                default:
                        return MEM_STAT_MEMORY_OTHER;
                }
+       case PERF_MEM_STAT_SNOOP:
+               switch (src.mem_snoop) {
+               case PERF_MEM_SNOOP_HIT:
+                       return MEM_STAT_SNOOP_HIT;
+               case PERF_MEM_SNOOP_HITM:
+                       return MEM_STAT_SNOOP_HITM;
+               case PERF_MEM_SNOOP_MISS:
+                       return MEM_STAT_SNOOP_MISS;
+               default:
+                       return MEM_STAT_SNOOP_OTHER;
+               }
        default:
                break;
        }
@@ -919,6 +930,18 @@ const char *mem_stat_name(const enum mem_stat_type mst, const int idx)
                default:
                        return "Other";
                }
+       case PERF_MEM_STAT_SNOOP:
+               switch (idx) {
+               case MEM_STAT_SNOOP_HIT:
+                       return "Hit";
+               case MEM_STAT_SNOOP_HITM:
+                       return "HitM";
+               case MEM_STAT_SNOOP_MISS:
+                       return "Miss";
+               case MEM_STAT_SNOOP_OTHER:
+               default:
+                       return "Other";
+               }
        default:
                break;
        }
index 002e2772400e3ddaf3dfdcd5ecaf1a8421dae2a7..4d8f18583af425501e202f2a9b0d8f3718553522 100644 (file)
@@ -93,6 +93,7 @@ enum mem_stat_type {
        PERF_MEM_STAT_OP,
        PERF_MEM_STAT_CACHE,
        PERF_MEM_STAT_MEMORY,
+       PERF_MEM_STAT_SNOOP,
 };
 
 #define MEM_STAT_PRINT_LEN  7  /* 1 space + 5 digits + 1 percent sign */
@@ -126,6 +127,13 @@ enum mem_stat_memory {
        MEM_STAT_MEMORY_OTHER,
 };
 
+enum mem_stat_snoop {
+       MEM_STAT_SNOOP_HIT,
+       MEM_STAT_SNOOP_HITM,
+       MEM_STAT_SNOOP_MISS,
+       MEM_STAT_SNOOP_OTHER,
+};
+
 int mem_stat_index(const enum mem_stat_type mst, const u64 data_src);
 const char *mem_stat_name(const enum mem_stat_type mst, const int idx);
 
index 2ad88f7de95a224759cfbe68adb7e4f0972d579f..51a210d874327d3a07e6a4c2c54c9d4b04dcd3ad 100644 (file)
@@ -2626,6 +2626,7 @@ static struct hpp_dimension hpp_sort_dimensions[] = {
        DIM_MEM(PERF_HPP__MEM_STAT_OP, "op"),
        DIM_MEM(PERF_HPP__MEM_STAT_CACHE, "cache"),
        DIM_MEM(PERF_HPP__MEM_STAT_MEMORY, "memory"),
+       DIM_MEM(PERF_HPP__MEM_STAT_SNOOP, "snoop"),
 };
 
 #undef DIM_MEM