Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf report: Show per-event LOST SAMPLES stat

Display lost samples with --stat (if not zero):

$ perf report --stat
Aggregated stats:
TOTAL events: 64
COMM events: 2 ( 3.1%)
EXIT events: 1 ( 1.6%)
SAMPLE events: 26 (40.6%)
MMAP2 events: 4 ( 6.2%)
LOST_SAMPLES events: 1 ( 1.6%)
ATTR events: 2 ( 3.1%)
FINISHED_ROUND events: 1 ( 1.6%)
ID_INDEX events: 1 ( 1.6%)
THREAD_MAP events: 1 ( 1.6%)
CPU_MAP events: 1 ( 1.6%)
EVENT_UPDATE events: 2 ( 3.1%)
TIME_CONV events: 1 ( 1.6%)
FEATURE events: 20 (31.2%)
FINISHED_INIT events: 1 ( 1.6%)
cycles:uH stats:
SAMPLE events: 14
LOST_SAMPLES events: 1
instructions:uH stats:
SAMPLE events: 12

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220901195739.668604-6-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
d7ba22d4 75b37db0

+24 -3
+17
tools/perf/builtin-report.c
··· 752 752 return 0; 753 753 } 754 754 755 + static int count_lost_samples_event(struct perf_tool *tool, 756 + union perf_event *event, 757 + struct perf_sample *sample, 758 + struct machine *machine __maybe_unused) 759 + { 760 + struct report *rep = container_of(tool, struct report, tool); 761 + struct evsel *evsel; 762 + 763 + evsel = evlist__id2evsel(rep->session->evlist, sample->id); 764 + if (evsel) { 765 + hists__inc_nr_lost_samples(evsel__hists(evsel), 766 + event->lost_samples.lost); 767 + } 768 + return 0; 769 + } 770 + 755 771 static int process_attr(struct perf_tool *tool __maybe_unused, 756 772 union perf_event *event, 757 773 struct evlist **pevlist); ··· 777 761 memset(&rep->tool, 0, sizeof(rep->tool)); 778 762 rep->tool.attr = process_attr; 779 763 rep->tool.sample = count_sample_event; 764 + rep->tool.lost_samples = count_lost_samples_event; 780 765 rep->tool.no_warn = true; 781 766 } 782 767
+7 -3
tools/perf/util/hist.c
··· 2683 2683 evlist__for_each_entry(evlist, pos) { 2684 2684 struct hists *hists = evsel__hists(pos); 2685 2685 2686 - if (skip_empty && !hists->stats.nr_samples) 2686 + if (skip_empty && !hists->stats.nr_samples && !hists->stats.nr_lost_samples) 2687 2687 continue; 2688 2688 2689 2689 ret += fprintf(fp, "%s stats:\n", evsel__name(pos)); 2690 - ret += fprintf(fp, "%16s events: %10d\n", 2691 - "SAMPLE", hists->stats.nr_samples); 2690 + if (hists->stats.nr_samples) 2691 + ret += fprintf(fp, "%16s events: %10d\n", 2692 + "SAMPLE", hists->stats.nr_samples); 2693 + if (hists->stats.nr_lost_samples) 2694 + ret += fprintf(fp, "%16s events: %10d\n", 2695 + "LOST_SAMPLES", hists->stats.nr_lost_samples); 2692 2696 } 2693 2697 2694 2698 return ret;