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

perf record: Set PERF_FORMAT_LOST by default

As we want to see the number of lost samples in the perf report, set the
LOST format when it configs evsel. On old kernels, it'd fallback to
disable it.

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-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
e17f343c a8d68cc4

+10 -1
+9 -1
tools/perf/util/evsel.c
··· 1161 1161 attr->sample_id_all = perf_missing_features.sample_id_all ? 0 : 1; 1162 1162 attr->inherit = !opts->no_inherit; 1163 1163 attr->write_backward = opts->overwrite ? 1 : 0; 1164 + attr->read_format = PERF_FORMAT_LOST; 1164 1165 1165 1166 evsel__set_sample_bit(evsel, IP); 1166 1167 evsel__set_sample_bit(evsel, TID); ··· 1857 1856 1858 1857 static void evsel__disable_missing_features(struct evsel *evsel) 1859 1858 { 1859 + if (perf_missing_features.read_lost) 1860 + evsel->core.attr.read_format &= ~PERF_FORMAT_LOST; 1860 1861 if (perf_missing_features.weight_struct) { 1861 1862 evsel__set_sample_bit(evsel, WEIGHT); 1862 1863 evsel__reset_sample_bit(evsel, WEIGHT_STRUCT); ··· 1910 1907 * Must probe features in the order they were added to the 1911 1908 * perf_event_attr interface. 1912 1909 */ 1913 - if (!perf_missing_features.weight_struct && 1910 + if (!perf_missing_features.read_lost && 1911 + (evsel->core.attr.read_format & PERF_FORMAT_LOST)) { 1912 + perf_missing_features.read_lost = true; 1913 + pr_debug2("switching off PERF_FORMAT_LOST support\n"); 1914 + return true; 1915 + } else if (!perf_missing_features.weight_struct && 1914 1916 (evsel->core.attr.sample_type & PERF_SAMPLE_WEIGHT_STRUCT)) { 1915 1917 perf_missing_features.weight_struct = true; 1916 1918 pr_debug2("switching off weight struct support\n");
+1
tools/perf/util/evsel.h
··· 188 188 bool data_page_size; 189 189 bool code_page_size; 190 190 bool weight_struct; 191 + bool read_lost; 191 192 }; 192 193 193 194 extern struct perf_missing_features perf_missing_features;