Commit 24fead56 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo
Browse files

perf intel-tpebs: Move the cpumap_buf variable out of evsel__tpebs_open()



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: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarWeilin Wang <weilin.wang@intel.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Andreas Färber <afaerber@suse.de>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Link: https://lore.kernel.org/r/20250414174134.3095492-6-irogers@google.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b009b51e
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -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;