perf: Add support for event removal on exec

Adds bit perf_event_attr::remove_on_exec, to support removing an event
from a task on exec.

This option supports the case where an event is supposed to be
process-wide only, and should not propagate beyond exec, to limit
monitoring to the original process image only.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210408103605.1676875-5-elver@google.com
This commit is contained in:
Marco Elver
2021-04-08 12:35:59 +02:00
committed by Peter Zijlstra
parent 2b26f0aa00
commit 2e498d0a74
2 changed files with 64 additions and 9 deletions

View File

@@ -390,7 +390,8 @@ struct perf_event_attr {
text_poke : 1, /* include text poke events */
build_id : 1, /* use build id in mmap2 events */
inherit_thread : 1, /* children only inherit if cloned with CLONE_THREAD */
__reserved_1 : 28;
remove_on_exec : 1, /* event is removed from task on exec */
__reserved_1 : 27;
union {
__u32 wakeup_events; /* wakeup every n events */