]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
perf evlist: Check that there is a thread_map when preparing a workload
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 10 Oct 2014 17:29:49 +0000 (14:29 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 14 Oct 2014 20:32:53 +0000 (17:32 -0300)
The perf_evlist__prepare_workload expects a thread map to be in place
so that it can store the pid of the workload being started, so check it
and tell the developer about it instead of segfaulting.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-jvlz2f264e7kpmhjmwltikqw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c

index 3cebc9a8d52e232e9dafe13dd2b8cf2b0dcd613d..5fc7bd42c80368b6c1ee49f873635068f97fe4b1 100644 (file)
@@ -1276,8 +1276,14 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *tar
                sigaction(SIGUSR1, &act, NULL);
        }
 
-       if (target__none(target))
+       if (target__none(target)) {
+               if (evlist->threads == NULL) {
+                       fprintf(stderr, "FATAL: evlist->threads need to be set at this point (%s:%d).\n",
+                               __func__, __LINE__);
+                       goto out_close_pipes;
+               }
                evlist->threads->map[0] = evlist->workload.pid;
+       }
 
        close(child_ready_pipe[1]);
        close(go_pipe[0]);