]> git.baikalelectronics.ru Git - kernel.git/commit
perf tools: Use scandir() to iterate threads when synthesizing PERF_RECORD_ events
authorNamhyung Kim <namhyung@kernel.org>
Tue, 2 Feb 2021 09:01:18 +0000 (18:01 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 3 Feb 2021 16:10:44 +0000 (13:10 -0300)
commitcb5d4bc4a7a3e41f44053b6c9b26fb3b05af3890
tree85712cf17395bbddd9af2c9c2586e2a0a9b9de52
parentfe9abdae423c2aa29b0d9c947c5e8c281ad8eb0a
perf tools: Use scandir() to iterate threads when synthesizing PERF_RECORD_ events

Like in __event__synthesize_thread(), I think it's better to use
scandir() instead of the readdir() loop.  In case some malicious task
continues to create new threads, the readdir() loop will run over and
over to collect tids.  The scandir() also has the problem but the window
is much smaller since it doesn't do much work during the iteration.

Also add filter_task() function as we only care the tasks.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20210202090118.2008551-4-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/synthetic-events.c