diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2016-03-07 14:44:41 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-03-08 04:11:17 -0500 |
commit | 4a018cc47932ef1e68a0600ce3ac100df70fab2a (patch) | |
tree | 008fc6a2459816a7ceca4e8b7b4732be3751a22a | |
parent | 570735b33d122bcb259ef67c6aa63e5609af5752 (diff) |
perf jit: Move clockid validation
Move clockid validation into jit_process() so it can later be made
conditional.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1457005856-6143-6-git-send-email-adrian.hunter@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | tools/perf/builtin-inject.c | 24 | ||||
-rw-r--r-- | tools/perf/util/jitdump.c | 23 |
2 files changed, 23 insertions, 24 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 2512d71ca386..b2885776b602 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c | |||
@@ -729,23 +729,6 @@ static int __cmd_inject(struct perf_inject *inject) | |||
729 | return ret; | 729 | return ret; |
730 | } | 730 | } |
731 | 731 | ||
732 | #ifdef HAVE_LIBELF_SUPPORT | ||
733 | static int | ||
734 | jit_validate_events(struct perf_session *session) | ||
735 | { | ||
736 | struct perf_evsel *evsel; | ||
737 | |||
738 | /* | ||
739 | * check that all events use CLOCK_MONOTONIC | ||
740 | */ | ||
741 | evlist__for_each(session->evlist, evsel) { | ||
742 | if (evsel->attr.use_clockid == 0 || evsel->attr.clockid != CLOCK_MONOTONIC) | ||
743 | return -1; | ||
744 | } | ||
745 | return 0; | ||
746 | } | ||
747 | #endif | ||
748 | |||
749 | int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) | 732 | int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) |
750 | { | 733 | { |
751 | struct perf_inject inject = { | 734 | struct perf_inject inject = { |
@@ -852,13 +835,6 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) | |||
852 | } | 835 | } |
853 | #ifdef HAVE_LIBELF_SUPPORT | 836 | #ifdef HAVE_LIBELF_SUPPORT |
854 | if (inject.jit_mode) { | 837 | if (inject.jit_mode) { |
855 | /* | ||
856 | * validate event is using the correct clockid | ||
857 | */ | ||
858 | if (jit_validate_events(inject.session)) { | ||
859 | fprintf(stderr, "error, jitted code must be sampled with perf record -k 1\n"); | ||
860 | return -1; | ||
861 | } | ||
862 | inject.tool.mmap2 = perf_event__jit_repipe_mmap2; | 838 | inject.tool.mmap2 = perf_event__jit_repipe_mmap2; |
863 | inject.tool.mmap = perf_event__jit_repipe_mmap; | 839 | inject.tool.mmap = perf_event__jit_repipe_mmap; |
864 | inject.tool.ordered_events = true; | 840 | inject.tool.ordered_events = true; |
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index bd9e44f9fff2..cd272cc21e05 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c | |||
@@ -99,6 +99,21 @@ jit_close(struct jit_buf_desc *jd) | |||
99 | } | 99 | } |
100 | 100 | ||
101 | static int | 101 | static int |
102 | jit_validate_events(struct perf_session *session) | ||
103 | { | ||
104 | struct perf_evsel *evsel; | ||
105 | |||
106 | /* | ||
107 | * check that all events use CLOCK_MONOTONIC | ||
108 | */ | ||
109 | evlist__for_each(session->evlist, evsel) { | ||
110 | if (evsel->attr.use_clockid == 0 || evsel->attr.clockid != CLOCK_MONOTONIC) | ||
111 | return -1; | ||
112 | } | ||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | static int | ||
102 | jit_open(struct jit_buf_desc *jd, const char *name) | 117 | jit_open(struct jit_buf_desc *jd, const char *name) |
103 | { | 118 | { |
104 | struct jitheader header; | 119 | struct jitheader header; |
@@ -157,6 +172,14 @@ jit_open(struct jit_buf_desc *jd, const char *name) | |||
157 | goto error; | 172 | goto error; |
158 | } | 173 | } |
159 | 174 | ||
175 | /* | ||
176 | * validate event is using the correct clockid | ||
177 | */ | ||
178 | if (jit_validate_events(jd->session)) { | ||
179 | pr_err("error, jitted code must be sampled with perf record -k 1\n"); | ||
180 | goto error; | ||
181 | } | ||
182 | |||
160 | bs = header.total_size - sizeof(header); | 183 | bs = header.total_size - sizeof(header); |
161 | 184 | ||
162 | if (bs > bsz) { | 185 | if (bs > bsz) { |