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

perf jit: Let jit_process() return errors

In preparation for moving clockid validation into jit_process().

Previously a return value of zero meant the processing had been done and
non-zero meant either the processing was not done (i.e. not the jitdump
file mmap event) or an error occurred.

Change it so that zero means the processing was not done, one means the
processing was done and successful, and negative values are an error.

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-5-git-send-email-adrian.hunter@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Adrian Hunter and committed by
Ingo Molnar
570735b3 5fb0ac16

+16 -6
+12 -4
tools/perf/builtin-inject.c
··· 253 253 { 254 254 struct perf_inject *inject = container_of(tool, struct perf_inject, tool); 255 255 u64 n = 0; 256 + int ret; 256 257 257 258 /* 258 259 * if jit marker, then inject jit mmaps and generate ELF images 259 260 */ 260 - if (!jit_process(inject->session, &inject->output, machine, 261 - event->mmap.filename, sample->pid, &n)) { 261 + ret = jit_process(inject->session, &inject->output, machine, 262 + event->mmap.filename, sample->pid, &n); 263 + if (ret < 0) 264 + return ret; 265 + if (ret) { 262 266 inject->bytes_written += n; 263 267 return 0; 264 268 } ··· 291 287 { 292 288 struct perf_inject *inject = container_of(tool, struct perf_inject, tool); 293 289 u64 n = 0; 290 + int ret; 294 291 295 292 /* 296 293 * if jit marker, then inject jit mmaps and generate ELF images 297 294 */ 298 - if (!jit_process(inject->session, &inject->output, machine, 299 - event->mmap2.filename, sample->pid, &n)) { 295 + ret = jit_process(inject->session, &inject->output, machine, 296 + event->mmap2.filename, sample->pid, &n); 297 + if (ret < 0) 298 + return ret; 299 + if (ret) { 300 300 inject->bytes_written += n; 301 301 return 0; 302 302 }
+4 -2
tools/perf/util/jitdump.c
··· 647 647 * first, detect marker mmap (i.e., the jitdump mmap) 648 648 */ 649 649 if (jit_detect(filename, pid)) 650 - return -1; 650 + return 0; 651 651 652 652 memset(&jd, 0, sizeof(jd)); 653 653 ··· 665 665 *nbytes = 0; 666 666 667 667 ret = jit_inject(&jd, filename); 668 - if (!ret) 668 + if (!ret) { 669 669 *nbytes = jd.bytes_written; 670 + ret = 1; 671 + } 670 672 671 673 return ret; 672 674 }