Commit c1de7f3d authored by Kan Liang's avatar Kan Liang Committed by Arnaldo Carvalho de Melo
Browse files

perf record: Add support for PERF_SAMPLE_CODE_PAGE_SIZE



Adds the infrastructure to sample the code address page size.

Introduce a new --code-page-size option for perf record.

Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Originally-by: default avatarStephane Eranian <eranian@google.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20210105195752.43489-4-kan.liang@linux.intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 06280e3b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -296,6 +296,9 @@ OPTIONS
--data-page-size::
	Record the sampled data address data page size.

--code-page-size::
	Record the sampled code address (ip) page size

-T::
--timestamp::
	Record the sample timestamps. Use it with 'perf report -D' to see the
+2 −0
Original line number Diff line number Diff line
@@ -2477,6 +2477,8 @@ static struct option __record_options[] = {
		    "Record the sample physical addresses"),
	OPT_BOOLEAN(0, "data-page-size", &record.opts.sample_data_page_size,
		    "Record the sampled data address data page size"),
	OPT_BOOLEAN(0, "code-page-size", &record.opts.sample_code_page_size,
		    "Record the sampled code address (ip) page size"),
	OPT_BOOLEAN(0, "sample-cpu", &record.opts.sample_cpu, "Record the sample cpu"),
	OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time,
			&record.opts.sample_time_set,
+1 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ struct perf_sample {
	u64 data_src;
	u64 phys_addr;
	u64 data_page_size;
	u64 code_page_size;
	u64 cgroup;
	u32 flags;
	u16 insn_len;
+17 −1
Original line number Diff line number Diff line
@@ -1195,6 +1195,9 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
	if (opts->sample_data_page_size)
		evsel__set_sample_bit(evsel, DATA_PAGE_SIZE);

	if (opts->sample_code_page_size)
		evsel__set_sample_bit(evsel, CODE_PAGE_SIZE);

	if (opts->record_switch_events)
		attr->context_switch = track;

@@ -1880,7 +1883,12 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
	 * Must probe features in the order they were added to the
	 * perf_event_attr interface.
	 */
        if (!perf_missing_features.data_page_size &&
	if (!perf_missing_features.code_page_size &&
	    (evsel->core.attr.sample_type & PERF_SAMPLE_CODE_PAGE_SIZE)) {
		perf_missing_features.code_page_size = true;
		pr_debug2_peo("Kernel has no PERF_SAMPLE_CODE_PAGE_SIZE support, bailing out\n");
		goto out_close;
	} else if (!perf_missing_features.data_page_size &&
	    (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_PAGE_SIZE)) {
		perf_missing_features.data_page_size = true;
		pr_debug2_peo("Kernel has no PERF_SAMPLE_DATA_PAGE_SIZE support, bailing out\n");
@@ -2376,6 +2384,12 @@ int evsel__parse_sample(struct evsel *evsel, union perf_event *event,
		array++;
	}

	data->code_page_size = 0;
	if (type & PERF_SAMPLE_CODE_PAGE_SIZE) {
		data->code_page_size = *array;
		array++;
	}

	if (type & PERF_SAMPLE_AUX) {
		OVERFLOW_CHECK_u64(array);
		sz = *array++;
@@ -2685,6 +2699,8 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
	"We found oprofile daemon running, please stop it and try again.");
		break;
	case EINVAL:
		if (evsel->core.attr.sample_type & PERF_SAMPLE_CODE_PAGE_SIZE && perf_missing_features.code_page_size)
			return scnprintf(msg, size, "Asking for the code page size isn't supported by this kernel.");
		if (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_PAGE_SIZE && perf_missing_features.data_page_size)
			return scnprintf(msg, size, "Asking for the data page size isn't supported by this kernel.");
		if (evsel->core.attr.write_backward && perf_missing_features.write_backward)
+1 −0
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ struct perf_missing_features {
	bool branch_hw_idx;
	bool cgroup;
	bool data_page_size;
	bool code_page_size;
};

extern struct perf_missing_features perf_missing_features;
Loading