perf tools: Add debug messages and comments for testing
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 12 Sep 2022 08:34:11 +0000 (11:34 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 4 Oct 2022 11:55:23 +0000 (08:55 -0300)
Add debug messages to enable scripts to track aspects of 'perf record'
behaviour. The messages will be consumed after 'perf record' has run,
with the exception of "perf record has started" which is consequently
flushed.

Put comments so developers know which messages are also being used by test
scripts.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20220912083412.7058-11-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/perf/evlist.c
tools/perf/builtin-record.c
tools/perf/util/evsel.c

index 8ec5b9f344e02cbb1985f36c66234359e2a00eea..0e7347d1583dcbb69ab5fe8a8298fea7d5f1595f 100644 (file)
@@ -487,6 +487,7 @@ mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
                        if (ops->idx)
                                ops->idx(evlist, evsel, mp, idx);
 
+                       /* Debug message used by test scripts */
                        pr_debug("idx %d: mmapping fd %d\n", idx, *output);
                        if (ops->mmap(map, mp, *output, evlist_cpu) < 0)
                                return -1;
@@ -496,6 +497,7 @@ mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
                        if (!idx)
                                perf_evlist__set_mmap_first(evlist, map, overwrite);
                } else {
+                       /* Debug message used by test scripts */
                        pr_debug("idx %d: set output fd %d -> %d\n", idx, fd, *output);
                        if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
                                return -1;
index f4f1619199e5ceed79334ed1d28bee66fb0b0ba2..52d254b1530c98be0855e1b1d4adb81748641b95 100644 (file)
@@ -2434,10 +2434,14 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 
        record__uniquify_name(rec);
 
+       /* Debug message used by test scripts */
+       pr_debug3("perf record opening and mmapping events\n");
        if (record__open(rec) != 0) {
                err = -1;
                goto out_free_threads;
        }
+       /* Debug message used by test scripts */
+       pr_debug3("perf record done opening and mmapping events\n");
        session->header.env.comp_mmap_len = session->evlist->core.mmap_len;
 
        if (rec->opts.kcore) {
@@ -2580,6 +2584,10 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
        if (err)
                goto out_child;
 
+       /* Debug message used by test scripts */
+       pr_debug3("perf record has started\n");
+       fflush(stderr);
+
        trigger_ready(&auxtrace_snapshot_trigger);
        trigger_ready(&switch_output_trigger);
        perf_hooks__invoke_record_start();
index 5776bfa70f11e8da98b6f41736464b24851ec533..a27092339b81a439c409a101b1d67eee077553ae 100644 (file)
@@ -2089,6 +2089,7 @@ retry_open:
 
                        test_attr__ready();
 
+                       /* Debug message used by test scripts */
                        pr_debug2_peo("sys_perf_event_open: pid %d  cpu %d  group_fd %d  flags %#lx",
                                pid, perf_cpu_map__cpu(cpus, idx).cpu, group_fd, evsel->open_flags);
 
@@ -2114,6 +2115,7 @@ retry_open:
                                                fd, group_fd, evsel->open_flags);
                        }
 
+                       /* Debug message used by test scripts */
                        pr_debug2_peo(" = %d\n", fd);
 
                        if (evsel->bpf_fd >= 0) {