is_pos only useful for tracking events (fork, mmap, exit, ...). Perf collects those events through evsel with 'tracking' set. Therefore, there's no need to validate every is_pos against evlist->is_pos.
With this commit, kernel can safely put something at the end of a record. For example, PERF_SAMPLE_TAILSIZE [1]. However, since we have dropped TAILSIZE, this commit is not mandatory, just making code robust if someone implements similar things in their private kernel. [1] http://lkml.kernel.org/g/[email protected] Signed-off-by: Wang Nan <[email protected]> Signed-off-by: He Kuang <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Zefan Li <[email protected]> Cc: [email protected] --- tools/perf/util/evlist.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 86a0383..227950b 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1277,8 +1277,15 @@ bool perf_evlist__valid_sample_type(struct perf_evlist *evlist) return false; evlist__for_each(evlist, pos) { - if (pos->id_pos != evlist->id_pos || - pos->is_pos != evlist->is_pos) + if (pos->id_pos != evlist->id_pos) + return false; + /* + * Only tracking events needs is_pos. Those events are + * collected if evsel->tracking is selected. + * For other evsel, is_pos is useless, so skip + * validating them. + */ + if (pos->tracking && pos->is_pos != evlist->is_pos) return false; } -- 1.8.3.4

