perf jit: Move clockid validation
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 7 Mar 2016 19:44:41 +0000 (16:44 -0300)
committerIngo Molnar <mingo@kernel.org>
Tue, 8 Mar 2016 09:11:17 +0000 (10:11 +0100)
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>
tools/perf/builtin-inject.c
tools/perf/util/jitdump.c

index 2512d71ca386954101f2f7ba37ca1daf10efe356..b2885776b60207f73b39f2fcbb176a26c36ff8f4 100644 (file)
@@ -729,23 +729,6 @@ static int __cmd_inject(struct perf_inject *inject)
        return ret;
 }
 
-#ifdef HAVE_LIBELF_SUPPORT
-static int
-jit_validate_events(struct perf_session *session)
-{
-       struct perf_evsel *evsel;
-
-       /*
-        * check that all events use CLOCK_MONOTONIC
-        */
-       evlist__for_each(session->evlist, evsel) {
-               if (evsel->attr.use_clockid == 0 || evsel->attr.clockid != CLOCK_MONOTONIC)
-                       return -1;
-       }
-       return 0;
-}
-#endif
-
 int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
 {
        struct perf_inject inject = {
@@ -852,13 +835,6 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
        }
 #ifdef HAVE_LIBELF_SUPPORT
        if (inject.jit_mode) {
-               /*
-                * validate event is using the correct clockid
-                */
-               if (jit_validate_events(inject.session)) {
-                       fprintf(stderr, "error, jitted code must be sampled with perf record -k 1\n");
-                       return -1;
-               }
                inject.tool.mmap2          = perf_event__jit_repipe_mmap2;
                inject.tool.mmap           = perf_event__jit_repipe_mmap;
                inject.tool.ordered_events = true;
index bd9e44f9fff2446d488f5950075904915db6c7a5..cd272cc21e05b1325c68f4ff4aae442c45a0364a 100644 (file)
@@ -98,6 +98,21 @@ jit_close(struct jit_buf_desc *jd)
        jd->in = NULL;
 }
 
+static int
+jit_validate_events(struct perf_session *session)
+{
+       struct perf_evsel *evsel;
+
+       /*
+        * check that all events use CLOCK_MONOTONIC
+        */
+       evlist__for_each(session->evlist, evsel) {
+               if (evsel->attr.use_clockid == 0 || evsel->attr.clockid != CLOCK_MONOTONIC)
+                       return -1;
+       }
+       return 0;
+}
+
 static int
 jit_open(struct jit_buf_desc *jd, const char *name)
 {
@@ -157,6 +172,14 @@ jit_open(struct jit_buf_desc *jd, const char *name)
                goto error;
        }
 
+       /*
+        * validate event is using the correct clockid
+        */
+       if (jit_validate_events(jd->session)) {
+               pr_err("error, jitted code must be sampled with perf record -k 1\n");
+               goto error;
+       }
+
        bs = header.total_size - sizeof(header);
 
        if (bs > bsz) {
This page took 0.026255 seconds and 5 git commands to generate.