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

Commit c093f308 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo
Browse files

perf intel-pt: Record address filter in AUXTRACE_INFO event



The address filter is needed to help decode the trace, so store it in
the AUXTRACE_INFO event.

Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: http://lkml.kernel.org/r/1474641528-18776-14-git-send-email-adrian.hunter@intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 40b746a0
Loading
Loading
Loading
Loading
+47 −4
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ struct intel_pt_recording {
	size_t				snapshot_ref_buf_size;
	int				snapshot_ref_cnt;
	struct intel_pt_snapshot_ref	*snapshot_refs;
	size_t				priv_size;
};

static int intel_pt_parse_terms_with_default(struct list_head *formats,
@@ -273,11 +274,37 @@ intel_pt_pmu_default_config(struct perf_pmu *intel_pt_pmu)
	return attr;
}

static const char *intel_pt_find_filter(struct perf_evlist *evlist,
					struct perf_pmu *intel_pt_pmu)
{
	struct perf_evsel *evsel;

	evlist__for_each_entry(evlist, evsel) {
		if (evsel->attr.type == intel_pt_pmu->type)
			return evsel->filter;
	}

	return NULL;
}

static size_t intel_pt_filter_bytes(const char *filter)
{
	size_t len = filter ? strlen(filter) : 0;

	return len ? roundup(len + 1, 8) : 0;
}

static size_t
intel_pt_info_priv_size(struct auxtrace_record *itr __maybe_unused,
			struct perf_evlist *evlist __maybe_unused)
intel_pt_info_priv_size(struct auxtrace_record *itr, struct perf_evlist *evlist)
{
	return INTEL_PT_AUXTRACE_PRIV_SIZE;
	struct intel_pt_recording *ptr =
			container_of(itr, struct intel_pt_recording, itr);
	const char *filter = intel_pt_find_filter(evlist, ptr->intel_pt_pmu);

	ptr->priv_size = (INTEL_PT_AUXTRACE_PRIV_MAX * sizeof(u64)) +
			 intel_pt_filter_bytes(filter);

	return ptr->priv_size;
}

static void intel_pt_tsc_ctc_ratio(u32 *n, u32 *d)
@@ -303,9 +330,12 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
	u64 tsc_bit, mtc_bit, mtc_freq_bits, cyc_bit, noretcomp_bit;
	u32 tsc_ctc_ratio_n, tsc_ctc_ratio_d;
	unsigned long max_non_turbo_ratio;
	size_t filter_str_len;
	const char *filter;
	u64 *info;
	int err;

	if (priv_size != INTEL_PT_AUXTRACE_PRIV_SIZE)
	if (priv_size != ptr->priv_size)
		return -EINVAL;

	intel_pt_parse_terms(&intel_pt_pmu->format, "tsc", &tsc_bit);
@@ -322,6 +352,9 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
				"%lu", &max_non_turbo_ratio) != 1)
		max_non_turbo_ratio = 0;

	filter = intel_pt_find_filter(session->evlist, ptr->intel_pt_pmu);
	filter_str_len = filter ? strlen(filter) : 0;

	if (!session->evlist->nr_mmaps)
		return -EINVAL;

@@ -357,6 +390,16 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
	auxtrace_info->priv[INTEL_PT_TSC_CTC_D] = tsc_ctc_ratio_d;
	auxtrace_info->priv[INTEL_PT_CYC_BIT] = cyc_bit;
	auxtrace_info->priv[INTEL_PT_MAX_NONTURBO_RATIO] = max_non_turbo_ratio;
	auxtrace_info->priv[INTEL_PT_FILTER_STR_LEN] = filter_str_len;

	info = &auxtrace_info->priv[INTEL_PT_FILTER_STR_LEN] + 1;

	if (filter_str_len) {
		size_t len = intel_pt_filter_bytes(filter);

		strncpy((char *)info, filter, len);
		info += len >> 3;
	}

	return 0;
}
+1 −2
Original line number Diff line number Diff line
@@ -35,11 +35,10 @@ enum {
	INTEL_PT_TSC_CTC_D,
	INTEL_PT_CYC_BIT,
	INTEL_PT_MAX_NONTURBO_RATIO,
	INTEL_PT_FILTER_STR_LEN,
	INTEL_PT_AUXTRACE_PRIV_MAX,
};

#define INTEL_PT_AUXTRACE_PRIV_SIZE (INTEL_PT_AUXTRACE_PRIV_MAX * sizeof(u64))

struct auxtrace_record;
struct perf_tool;
union perf_event;