Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 473398a2 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf tools: Add cpumode to struct perf_sample

To avoid parsing event->header.misc in many locations.

This will also allow setting perf.sample.{ip,cpumode} in a single place,
from tracepoint fields, as needed by 'perf kvm' with PPC guests, where
the guest hardware counters is not available at the host.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-qp3yradhyt6q3wl895b1aat0@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent eb9f0323
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -416,9 +416,6 @@ static int perf_event__inject_buildid(struct perf_tool *tool,
{
	struct addr_location al;
	struct thread *thread;
	u8 cpumode;

	cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;

	thread = machine__findnew_thread(machine, sample->pid, sample->tid);
	if (thread == NULL) {
@@ -427,7 +424,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,
		goto repipe;
	}

	thread__find_addr_map(thread, cpumode, MAP__FUNCTION, sample->ip, &al);
	thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, sample->ip, &al);

	if (al.map != NULL) {
		if (!al.map->dso->hit) {
+3 −4
Original line number Diff line number Diff line
@@ -498,14 +498,13 @@ static void print_sample_brstack(union perf_event *event __maybe_unused,
	}
}

static void print_sample_brstacksym(union perf_event *event,
static void print_sample_brstacksym(union perf_event *event __maybe_unused,
			  struct perf_sample *sample,
			  struct thread *thread __maybe_unused,
			  struct perf_event_attr *attr __maybe_unused)
{
	struct branch_stack *br = sample->branch_stack;
	struct addr_location alf, alt;
	u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
	u64 i, from, to;

	if (!(br && br->nr))
@@ -518,11 +517,11 @@ static void print_sample_brstacksym(union perf_event *event,
		from = br->entries[i].from;
		to   = br->entries[i].to;

		thread__find_addr_map(thread, cpumode, MAP__FUNCTION, from, &alf);
		thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, from, &alf);
		if (alf.map)
			alf.sym = map__find_symbol(alf.map, alf.addr, NULL);

		thread__find_addr_map(thread, cpumode, MAP__FUNCTION, to, &alt);
		thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, to, &alt);
		if (alt.map)
			alt.sym = map__find_symbol(alt.map, alt.addr, NULL);

+1 −4
Original line number Diff line number Diff line
@@ -809,7 +809,6 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
	struct perf_session *session = top->session;
	union perf_event *event;
	struct machine *machine;
	u8 origin;
	int ret;

	while ((event = perf_evlist__mmap_read(top->evlist, idx)) != NULL) {
@@ -822,12 +821,10 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
		evsel = perf_evlist__id2evsel(session->evlist, sample.id);
		assert(evsel != NULL);

		origin = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;

		if (event->header.type == PERF_RECORD_SAMPLE)
			++top->samples;

		switch (origin) {
		switch (sample.cpumode) {
		case PERF_RECORD_MISC_USER:
			++top->us_samples;
			if (top->hide_user_symbols)
+4 −5
Original line number Diff line number Diff line
@@ -2256,11 +2256,10 @@ static void print_location(FILE *f, struct perf_sample *sample,

static int trace__pgfault(struct trace *trace,
			  struct perf_evsel *evsel,
			  union perf_event *event,
			  union perf_event *event __maybe_unused,
			  struct perf_sample *sample)
{
	struct thread *thread;
	u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
	struct addr_location al;
	char map_type = 'd';
	struct thread_trace *ttrace;
@@ -2279,7 +2278,7 @@ static int trace__pgfault(struct trace *trace,
	if (trace->summary_only)
		goto out;

	thread__find_addr_location(thread, cpumode, MAP__FUNCTION,
	thread__find_addr_location(thread, sample->cpumode, MAP__FUNCTION,
			      sample->ip, &al);

	trace__fprintf_entry_head(trace, thread, 0, sample->time, trace->output);
@@ -2292,11 +2291,11 @@ static int trace__pgfault(struct trace *trace,

	fprintf(trace->output, "] => ");

	thread__find_addr_location(thread, cpumode, MAP__VARIABLE,
	thread__find_addr_location(thread, sample->cpumode, MAP__VARIABLE,
				   sample->addr, &al);

	if (!al.map) {
		thread__find_addr_location(thread, cpumode,
		thread__find_addr_location(thread, sample->cpumode,
					   MAP__FUNCTION, sample->addr, &al);

		if (al.map)
+1 −4
Original line number Diff line number Diff line
@@ -293,7 +293,6 @@ static int process_sample_event(struct machine *machine,
{
	struct perf_sample sample;
	struct thread *thread;
	u8 cpumode;
	int ret;

	if (perf_evlist__parse_sample(evlist, event, &sample)) {
@@ -307,9 +306,7 @@ static int process_sample_event(struct machine *machine,
		return -1;
	}

	cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;

	ret = read_object_code(sample.ip, READLEN, cpumode, thread, state);
	ret = read_object_code(sample.ip, READLEN, sample.cpumode, thread, state);
	thread__put(thread);
	return ret;
}
Loading