Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Adrian Hunter and committed by
Ingo Molnar
4a018cc4 570735b3

+23 -24
-24
tools/perf/builtin-inject.c
··· 729 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 732 int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused) 750 733 { 751 734 struct perf_inject inject = { ··· 835 852 } 836 853 #ifdef HAVE_LIBELF_SUPPORT 837 854 if (inject.jit_mode) { 838 - /* 839 - * validate event is using the correct clockid 840 - */ 841 - if (jit_validate_events(inject.session)) { 842 - fprintf(stderr, "error, jitted code must be sampled with perf record -k 1\n"); 843 - return -1; 844 - } 845 855 inject.tool.mmap2 = perf_event__jit_repipe_mmap2; 846 856 inject.tool.mmap = perf_event__jit_repipe_mmap; 847 857 inject.tool.ordered_events = true;
+23
tools/perf/util/jitdump.c
··· 99 99 } 100 100 101 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 117 jit_open(struct jit_buf_desc *jd, const char *name) 103 118 { 104 119 struct jitheader header; ··· 169 154 if (header.flags & JITDUMP_FLAGS_RESERVED) { 170 155 pr_err("jitdump file contains invalid or unsupported flags 0x%llx\n", 171 156 (unsigned long long)header.flags & JITDUMP_FLAGS_RESERVED); 157 + goto error; 158 + } 159 + 160 + /* 161 + * validate event is using the correct clockid 162 + */ 163 + if (jit_validate_events(jd->session)) { 164 + pr_err("error, jitted code must be sampled with perf record -k 1\n"); 172 165 goto error; 173 166 } 174 167