Commit 42e1fd80 authored by Alexey Budankov's avatar Alexey Budankov Committed by Arnaldo Carvalho de Melo
Browse files

perf record: Implement COMPRESSED event record and its attributes



Implemented PERF_RECORD_COMPRESSED event, related data types, header
feature and functions to write, read and print feature attributes from
the trace header section.

comp_mmap_len preserves the size of mmaped kernel buffer that was used
during collection. comp_mmap_len size is used on loading stage as the
size of decomp buffer for decompression of COMPRESSED events content.

Committer notes:

Fixed up conflict with BPF_PROG_INFO and BTF_BTF header features.

Signed-off-by: default avatarAlexey Budankov <alexey.budankov@linux.intel.com>
Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/ebbaf031-8dda-3864-ebc6-7922d43ee515@linux.intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d3c8c08e
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -272,6 +272,19 @@ struct {

Two uint64_t for the time of first sample and the time of last sample.

        HEADER_COMPRESSED = 27,

struct {
	u32	version;
	u32	type;
	u32	level;
	u32	ratio;
	u32	mmap_len;
};

Indicates that trace contains records of PERF_RECORD_COMPRESSED type
that have perf_events records in compressed form.

	other bits are reserved and should ignored for now
	HEADER_FEAT_BITS	= 256,

@@ -437,6 +450,17 @@ struct auxtrace_error_event {
Describes a header feature. These are records used in pipe-mode that
contain information that otherwise would be in perf.data file's header.

	PERF_RECORD_COMPRESSED 			= 81,

struct compressed_event {
	struct perf_event_header	header;
	char				data[];
};

The header is followed by compressed data frame that can be decompressed
into array of perf trace records. The size of the entire compressed event
record including the header is limited by the max value of header.size.

Event types

Define the event attributes with their IDs.
+8 −0
Original line number Diff line number Diff line
@@ -372,6 +372,11 @@ static int record__mmap_flush_parse(const struct option *opt,
	return 0;
}

static int record__comp_enabled(struct record *rec)
{
	return rec->opts.comp_level > 0;
}

static int process_synthesized_event(struct perf_tool *tool,
				     union perf_event *event,
				     struct perf_sample *sample __maybe_unused,
@@ -888,6 +893,8 @@ static void record__init_features(struct record *rec)
		perf_header__clear_feat(&session->header, HEADER_CLOCKID);

	perf_header__clear_feat(&session->header, HEADER_DIR_FORMAT);
	if (!record__comp_enabled(rec))
		perf_header__clear_feat(&session->header, HEADER_COMPRESSED);

	perf_header__clear_feat(&session->header, HEADER_STAT);
}
@@ -1245,6 +1252,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
		err = -1;
		goto out_child;
	}
	session->header.env.comp_mmap_len = session->evlist->mmap_len;

	err = bpf__apply_obj_config();
	if (err) {
+1 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ struct record_opts {
	int	     nr_cblocks;
	int	     affinity;
	int	     mmap_flush;
	unsigned int comp_level;
};

enum perf_affinity {
+10 −0
Original line number Diff line number Diff line
@@ -63,6 +63,10 @@ struct perf_env {
	struct cpu_cache_level	*caches;
	int			 caches_cnt;
	u32			comp_ratio;
	u32			comp_ver;
	u32			comp_type;
	u32			comp_level;
	u32			comp_mmap_len;
	struct numa_node	*numa_nodes;
	struct memory_node	*memory_nodes;
	unsigned long long	 memory_bsize;
@@ -81,6 +85,12 @@ struct perf_env {
	} bpf_progs;
};

enum perf_compress_type {
	PERF_COMP_NONE = 0,
	PERF_COMP_ZSTD,
	PERF_COMP_MAX
};

struct bpf_prog_info_node;
struct btf_node;

+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ static const char *perf_event__names[] = {
	[PERF_RECORD_EVENT_UPDATE]		= "EVENT_UPDATE",
	[PERF_RECORD_TIME_CONV]			= "TIME_CONV",
	[PERF_RECORD_HEADER_FEATURE]		= "FEATURE",
	[PERF_RECORD_COMPRESSED]		= "COMPRESSED",
};

static const char *perf_ns__names[] = {
Loading