summaryrefslogtreecommitdiff
path: root/tools/perf/builtin-sched.c
diff options
context:
space:
mode:
authorYann Droneaud <ydroneaud@opteya.com>2014-06-30 20:28:47 (GMT)
committerJiri Olsa <jolsa@kernel.org>2014-07-18 07:09:34 (GMT)
commit57480d2cd93579d665e57e144e1e63f7f02ef058 (patch)
treea1c628c2bd65a943461479ad52cd4bec179e51d7 /tools/perf/builtin-sched.c
parentec6dbcb7ade2a616675cbe3185cf299ee1615c9f (diff)
downloadlinux-57480d2cd93579d665e57e144e1e63f7f02ef058.tar.xz
perf tools: Enable close-on-exec flag on perf file descriptor
In commit a21b0b354d4a ('perf: Introduce a flag to enable close-on-exec in perf_event_open()'), flag PERF_FLAG_FD_CLOEXEC was added to perf_event_open(2) syscall to allows userspace to atomically enable close-on-exec behavor when creating the file descriptor. This patch makes perf tools use the new flag if supported by the kernel, so that the event file descriptors got automatically closed if perf tool exec a sub-command. Signed-off-by: Yann Droneaud <ydroneaud@opteya.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/n/1404160127-7475-1-git-send-email-ydroneaud@opteya.com Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r--tools/perf/builtin-sched.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index b7f555a..f83c08c 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -10,6 +10,7 @@
#include "util/header.h"
#include "util/session.h"
#include "util/tool.h"
+#include "util/cloexec.h"
#include "util/parse-options.h"
#include "util/trace-event.h"
@@ -434,7 +435,8 @@ static int self_open_counters(void)
attr.type = PERF_TYPE_SOFTWARE;
attr.config = PERF_COUNT_SW_TASK_CLOCK;
- fd = sys_perf_event_open(&attr, 0, -1, -1, 0);
+ fd = sys_perf_event_open(&attr, 0, -1, -1,
+ perf_event_open_cloexec_flag());
if (fd < 0)
pr_err("Error: sys_perf_event_open() syscall returned "