perf hist: Add weight fields to hist entry stats
authorNamhyung Kim <namhyung@kernel.org>
Thu, 11 Apr 2024 18:17:17 +0000 (11:17 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 17 Apr 2024 15:21:39 +0000 (12:21 -0300)
Like period and sample numbers, it'd be better to track weight values
and display them in the output rather than having them as sort keys.

This patch just adds a few more fields to save the weights in a hist
entry.  It'll be displayed as new output fields in the later patch.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.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: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240411181718.2367948-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/hist.c
tools/perf/util/hist.h

index fa359180ebf8fc45e1248e4241543817e0660260..9d43f8ae412d850d9cac09ba6bd574177542751e 100644 (file)
@@ -308,6 +308,9 @@ static void he_stat__add_stat(struct he_stat *dest, struct he_stat *src)
        dest->period_us         += src->period_us;
        dest->period_guest_sys  += src->period_guest_sys;
        dest->period_guest_us   += src->period_guest_us;
+       dest->weight1           += src->weight1;
+       dest->weight2           += src->weight2;
+       dest->weight3           += src->weight3;
        dest->nr_events         += src->nr_events;
 }
 
@@ -315,7 +318,9 @@ static void he_stat__decay(struct he_stat *he_stat)
 {
        he_stat->period = (he_stat->period * 7) / 8;
        he_stat->nr_events = (he_stat->nr_events * 7) / 8;
-       /* XXX need decay for weight too? */
+       he_stat->weight1 = (he_stat->weight1 * 7) / 8;
+       he_stat->weight2 = (he_stat->weight2 * 7) / 8;
+       he_stat->weight3 = (he_stat->weight3 * 7) / 8;
 }
 
 static void hists__delete_entry(struct hists *hists, struct hist_entry *he);
@@ -614,7 +619,7 @@ static struct hist_entry *hists__findnew_entry(struct hists *hists,
                cmp = hist_entry__cmp(he, entry);
                if (!cmp) {
                        if (sample_self) {
-                               he_stat__add_period(&he->stat, period);
+                               he_stat__add_stat(&he->stat, &entry->stat);
                                hist_entry__add_callchain_period(he, period);
                        }
                        if (symbol_conf.cumulate_callchain)
@@ -731,6 +736,9 @@ __hists__add_entry(struct hists *hists,
                .stat = {
                        .nr_events = 1,
                        .period = sample->period,
+                       .weight1 = sample->weight,
+                       .weight2 = sample->ins_lat,
+                       .weight3 = sample->p_stage_cyc,
                },
                .parent = sym_parent,
                .filtered = symbol__parent_filter(sym_parent) | al->filtered,
index 8f072f3749eb927ec687c62a8f284a2de9e1513b..f34f101c36c27ea03aab58e8f09ed494d802c885 100644 (file)
@@ -163,6 +163,9 @@ struct he_stat {
        u64                     period_us;
        u64                     period_guest_sys;
        u64                     period_guest_us;
+       u64                     weight1;
+       u64                     weight2;
+       u64                     weight3;
        u32                     nr_events;
 };