perf record: Introduce function to propagate control commands
authorAlexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Mon, 17 Jan 2022 18:34:24 +0000 (21:34 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 10 Feb 2022 19:25:37 +0000 (16:25 -0300)
Introduce evlist__ctlfd_update() function to propagate external control
commands to global evlist object.

Reviewed-by: Riccardo Mancini <rickyman7@gmail.com>
Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Tested-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Riccardo Mancini <rickyman7@gmail.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Namhyung Kim <namhyung@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/7df52c9816b13c74897b9e518128b29a391462fe.1642440724.git.alexey.v.bayduraev@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c
tools/perf/util/evlist.h

index eaad04e1672a47523b13114e828f4961eecec745..8134d45e2164e8e286870edcb7c0b8dc19878425 100644 (file)
@@ -2139,6 +2139,22 @@ int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd)
        return err;
 }
 
+int evlist__ctlfd_update(struct evlist *evlist, struct pollfd *update)
+{
+       int ctlfd_pos = evlist->ctl_fd.pos;
+       struct pollfd *entries = evlist->core.pollfd.entries;
+
+       if (!evlist__ctlfd_initialized(evlist))
+               return 0;
+
+       if (entries[ctlfd_pos].fd != update->fd ||
+           entries[ctlfd_pos].events != update->events)
+               return -1;
+
+       entries[ctlfd_pos].revents = update->revents;
+       return 0;
+}
+
 struct evsel *evlist__find_evsel(struct evlist *evlist, int idx)
 {
        struct evsel *evsel;
index 64cba56fbc74d66eb8300efce54cf88360f73337..a21daaa5fc1b39c1d0a03a32c3fb84a8fd15deba 100644 (file)
@@ -410,6 +410,7 @@ void evlist__close_control(int ctl_fd, int ctl_fd_ack, bool *ctl_fd_close);
 int evlist__initialize_ctlfd(struct evlist *evlist, int ctl_fd, int ctl_fd_ack);
 int evlist__finalize_ctlfd(struct evlist *evlist);
 bool evlist__ctlfd_initialized(struct evlist *evlist);
+int evlist__ctlfd_update(struct evlist *evlist, struct pollfd *update);
 int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd);
 int evlist__ctlfd_ack(struct evlist *evlist);