From 22fdd6763bbf74fa64031ecc5575647f4e5a2713 Mon Sep 17 00:00:00 2001 From: Will Drewry Date: Tue, 24 May 2011 10:46:00 -0500 Subject: [PATCH 2/2] tools/perf: Add -S/--secure to builtin-record.c Example addition of require_secure and err_on_discard support being added to a perf command. Signed-off-by: Will Drewry --- tools/perf/builtin-record.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 9f70f39..f8aca7b 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -49,6 +49,7 @@ static int pipe_output = 0; static const char *output_name = NULL; static int group = 0; static int realtime_prio = 0; +static bool require_secure = false; static bool nodelay = false; static bool raw_samples = false; static bool sample_id_all_avail = true; @@ -223,9 +224,9 @@ static void config_attr(struct perf_evsel *evsel, struct perf_evlist *evlist) attr->mmap = track; attr->comm = track; - if (!system_wide) { + if (!system_wide && require_secure) { attr->require_secure = 1; - attr->fail_on_discard = 1; + attr->err_on_discard = 1; } if (target_pid == -1 && target_tid == -1 && !system_wide) { @@ -754,6 +755,8 @@ const struct option record_options[] = { "record events on existing thread id"), OPT_INTEGER('r', "realtime", &realtime_prio, "collect data with this RT SCHED_FIFO priority"), + OPT_BOOLEAN('S', "secure", &require_secure, + "configure all filters for secure use"), OPT_BOOLEAN('D', "no-delay", &nodelay, "collect data without buffering"), OPT_BOOLEAN('R', "raw-samples", &raw_samples, @@ -820,6 +823,12 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) write_mode = WRITE_FORCE; } + if (system_wide && require_secure) { + fprintf(stderr, "Can't install system-wide secure events." + " You need to choose between -S and -a"); + usage_with_options(record_usage, record_options); + } + if (nr_cgroups && !system_wide) { fprintf(stderr, "cgroup monitoring only available in" " system-wide mode\n"); -- 1.7.0.4