perf evlist: Add want_signal parameter to perf_evlist__prepare_workload()
Namhyung Kim [Mon, 11 Mar 2013 07:43:17 +0000 (16:43 +0900)]
In case a caller doesn't want to receive SIGUSR1 when the child failed
to exec().

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1362987798-24969-6-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

tools/perf/builtin-record.c
tools/perf/builtin-trace.c
tools/perf/tests/perf-record.c
tools/perf/util/evlist.c
tools/perf/util/evlist.h

index 2a43c44..80cc3ea 100644 (file)
@@ -475,7 +475,8 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
 
        if (forks) {
                err = perf_evlist__prepare_workload(evsel_list, &opts->target,
-                                                   argv, opts->pipe_output);
+                                                   argv, opts->pipe_output,
+                                                   true);
                if (err < 0) {
                        pr_err("Couldn't run the workload!\n");
                        goto out_delete_session;
index 3d9944c..f0c20ef 100644 (file)
@@ -462,7 +462,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 
        if (forks) {
                err = perf_evlist__prepare_workload(evlist, &trace->opts.target,
-                                                   argv, false);
+                                                   argv, false, false);
                if (err < 0) {
                        printf("Couldn't run the workload!\n");
                        goto out_delete_evlist;
index a1c41b7..ffab5a4 100644 (file)
@@ -93,7 +93,8 @@ int test__PERF_RECORD(void)
         * so that we have time to open the evlist (calling sys_perf_event_open
         * on all the fds) and then mmap them.
         */
-       err = perf_evlist__prepare_workload(evlist, &opts.target, argv, false);
+       err = perf_evlist__prepare_workload(evlist, &opts.target, argv,
+                                           false, false);
        if (err < 0) {
                pr_debug("Couldn't run the workload!\n");
                goto out_delete_maps;
index 9a337f0..5b012b8 100644 (file)
@@ -746,7 +746,8 @@ out_err:
 
 int perf_evlist__prepare_workload(struct perf_evlist *evlist,
                                  struct perf_target *target,
-                                 const char *argv[], bool pipe_output)
+                                 const char *argv[], bool pipe_output,
+                                 bool want_signal)
 {
        int child_ready_pipe[2], go_pipe[2];
        char bf;
@@ -796,7 +797,8 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist,
                execvp(argv[0], (char **)argv);
 
                perror(argv[0]);
-               kill(getppid(), SIGUSR1);
+               if (want_signal)
+                       kill(getppid(), SIGUSR1);
                exit(-1);
        }
 
index 276a5ac..c096da7 100644 (file)
@@ -87,7 +87,8 @@ void perf_evlist__config(struct perf_evlist *evlist,
 
 int perf_evlist__prepare_workload(struct perf_evlist *evlist,
                                  struct perf_target *target,
-                                 const char *argv[], bool pipe_output);
+                                 const char *argv[], bool pipe_output,
+                                 bool want_signal);
 int perf_evlist__start_workload(struct perf_evlist *evlist);
 
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,