Commit 4e66527f authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo
Browse files

perf thread: Add optional e_flags output argument to thread__e_machine



The e_flags are needed to accurately compute complete perf register
information for CSKY.

Add the ability to read and have this value associated with a thread.

This change doesn't wire up the use of the e_flags except in disasm
where use already exists but just wasn't set up yet.

Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Chun-Tse Shao <ctshao@google.com>
Cc: Guo Ren <guoren@kernel.org>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sergei Trofimovich <slyich@gmail.com>
Cc: Shimin Guo <shimin.guo@skydio.com>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Swapnil Sapkal <swapnil.sapkal@amd.com>
Cc: Tianyou Li <tianyou.li@intel.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 7d0ebeb6
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -2504,11 +2504,17 @@ static void process_event(struct perf_script *script,
				    symbol_conf.bt_stop_list, fp);
	}

	if (PRINT_FIELD(IREGS))
		perf_sample__fprintf_iregs(sample, attr, thread__e_machine(thread, machine), fp);
	if (PRINT_FIELD(IREGS)) {
		perf_sample__fprintf_iregs(sample, attr,
					   thread__e_machine(thread, machine, /*e_flags=*/NULL),
					   fp);
	}

	if (PRINT_FIELD(UREGS))
		perf_sample__fprintf_uregs(sample, attr, thread__e_machine(thread, machine), fp);
	if (PRINT_FIELD(UREGS)) {
		perf_sample__fprintf_uregs(sample, attr,
					   thread__e_machine(thread, machine, /*e_flags=*/NULL),
					   fp);
	}

	if (PRINT_FIELD(BRSTACK))
		perf_sample__fprintf_brstack(sample, thread, evsel, fp);
+7 −5
Original line number Diff line number Diff line
@@ -2789,7 +2789,7 @@ static int trace__sys_enter(struct trace *trace, struct evsel *evsel,
	struct thread_trace *ttrace;

	thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
	e_machine = thread__e_machine(thread, trace->host);
	e_machine = thread__e_machine(thread, trace->host, /*e_flags=*/NULL);
	sc = trace__syscall_info(trace, evsel, e_machine, id);
	if (sc == NULL)
		goto out_put;
@@ -2868,7 +2868,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,


	thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
	e_machine = thread__e_machine(thread, trace->host);
	e_machine = thread__e_machine(thread, trace->host, /*e_flags=*/NULL);
	sc = trace__syscall_info(trace, evsel, e_machine, id);
	if (sc == NULL)
		goto out_put;
@@ -2934,7 +2934,7 @@ static int trace__sys_exit(struct trace *trace, struct evsel *evsel,
	struct thread_trace *ttrace;

	thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
	e_machine = thread__e_machine(thread, trace->host);
	e_machine = thread__e_machine(thread, trace->host, /*e_flags=*/NULL);
	sc = trace__syscall_info(trace, evsel, e_machine, id);
	if (sc == NULL)
		goto out_put;
@@ -3285,7 +3285,9 @@ static int trace__event_handler(struct trace *trace, struct evsel *evsel,

	if (evsel == trace->syscalls.events.bpf_output) {
		int id = perf_evsel__sc_tp_uint(evsel, id, sample);
		int e_machine = thread ? thread__e_machine(thread, trace->host) : EM_HOST;
		int e_machine = thread
			? thread__e_machine(thread, trace->host, /*e_flags=*/NULL)
			: EM_HOST;
		struct syscall *sc = trace__syscall_info(trace, evsel, e_machine, id);

		if (sc) {
@@ -4916,7 +4918,7 @@ static size_t trace__fprintf_thread(FILE *fp, struct thread *thread, struct trac
{
	size_t printed = 0;
	struct thread_trace *ttrace = thread__priv(thread);
	int e_machine = thread__e_machine(thread, trace->host);
	int e_machine = thread__e_machine(thread, trace->host, /*e_flags=*/NULL);
	double ratio;

	if (ttrace == NULL)
+3 −2
Original line number Diff line number Diff line
@@ -984,6 +984,7 @@ int thread__get_arch(struct thread *thread, const struct arch **parch)
{
	const struct arch *arch;
	struct machine *machine;
	uint32_t e_flags;
	uint16_t e_machine;

	if (!thread) {
@@ -992,8 +993,8 @@ int thread__get_arch(struct thread *thread, const struct arch **parch)
	}

	machine = maps__machine(thread__maps(thread));
	e_machine = thread__e_machine(thread, machine);
	arch = arch__find(e_machine, machine->env ? machine->env->cpuid : NULL);
	e_machine = thread__e_machine(thread, machine, &e_flags);
	arch = arch__find(e_machine, e_flags, machine->env ? machine->env->cpuid : NULL);
	if (arch == NULL) {
		pr_err("%s: unsupported arch %d\n", __func__, e_machine);
		return errno;
+2 −3
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ static int arch__cmp(const void *a, const void *b)
	return e_machine_and_eflags__cmp(&(*aa)->id, &(*ab)->id);
}

const struct arch *arch__find(uint16_t e_machine, const char *cpuid)
const struct arch *arch__find(uint16_t e_machine, uint32_t e_flags, const char *cpuid)
{
	static const struct arch *(*const arch_new_fn[])(const struct e_machine_and_e_flags *id,
							 const char *cpuid) = {
@@ -157,8 +157,7 @@ const struct arch *arch__find(uint16_t e_machine, const char *cpuid)
	static size_t num_archs;
	struct e_machine_and_e_flags key = {
		.e_machine = e_machine,
		// TODO: e_flags should really come from the same source as e_machine.
		.e_flags = EF_HOST,
		.e_flags = e_flags,
	};
	const struct arch *result = NULL, **tmp;

+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ struct annotate_args {
	char			  *fileloc;
};

const struct arch *arch__find(uint16_t e_machine, const char *cpuid);
const struct arch *arch__find(uint16_t e_machine, uint32_t e_flags, const char *cpuid);
bool arch__is_x86(const struct arch *arch);
bool arch__is_powerpc(const struct arch *arch);

Loading