From 24fead56ebd01f0490c4fb5c3bf18de998eb1add Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Mon, 14 Apr 2025 10:41:23 -0700 Subject: [PATCH] perf intel-tpebs: Move the cpumap_buf variable out of evsel__tpebs_open() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The buffer holds the cpumap to pass to the 'perf record' command, so move it down to the 'perf record' function. Make this function an evsel function given the need for the evsel for the cpumap. Reviewed-by: Kan Liang Signed-off-by: Ian Rogers Tested-by: Weilin Wang Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Alexandre Torgue Cc: Andreas Färber Cc: Caleb Biggers Cc: Ingo Molnar Cc: Jiri Olsa Cc: Manivannan Sadhasivam Cc: Mark Rutland Cc: Maxime Coquelin Cc: Perry Taylor Cc: Peter Zijlstra Cc: Thomas Falcon Link: https://lore.kernel.org/r/20250414174134.3095492-6-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/intel-tpebs.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/intel-tpebs.c b/tools/perf/util/intel-tpebs.c index 2186818b2c9b..2b04deaf66ff 100644 --- a/tools/perf/util/intel-tpebs.c +++ b/tools/perf/util/intel-tpebs.c @@ -83,12 +83,15 @@ static int get_perf_record_args(const char **record_argv, char buf[], return 0; } -static int start_perf_record(int control_fd[], int ack_fd[], - const char *cpumap_buf) +static int evsel__tpebs_start_perf_record(struct evsel *evsel, int control_fd[], int ack_fd[]) { const char **record_argv; int ret; char buf[32]; + char cpumap_buf[50]; + + cpu_map__snprint(evsel->evlist->core.user_requested_cpus, cpumap_buf, + sizeof(cpumap_buf)); scnprintf(buf, sizeof(buf), "--control=fd:%d,%d", control_fd[0], ack_fd[1]); @@ -287,8 +290,6 @@ int evsel__tpebs_open(struct evsel *evsel) return ret; if (tpebs_event_size > 0) { - struct evlist *evsel_list = evsel->evlist; - char cpumap_buf[50]; struct pollfd pollfd = { .events = POLLIN, }; int control_fd[2], ack_fd[2], len; char ack_buf[8]; @@ -305,10 +306,7 @@ int evsel__tpebs_open(struct evsel *evsel) goto out; } - cpu_map__snprint(evsel_list->core.user_requested_cpus, cpumap_buf, - sizeof(cpumap_buf)); - - ret = start_perf_record(control_fd, ack_fd, cpumap_buf); + ret = evsel__tpebs_start_perf_record(evsel, control_fd, ack_fd); if (ret) goto out; -- 2.25.1