tools/perf/util/sample.h

Source file repositories/reference/linux-study-clean/tools/perf/util/sample.h

File Facts

System
Linux kernel
Corpus path
tools/perf/util/sample.h
Extension
.h
Size
8626 bytes
Lines
267
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct regs_dump {
	u64 abi;
	u64 mask;
	u64 *regs;

	/* Cached values/mask filled by first register access. */
	u64 cache_regs[PERF_SAMPLE_REGS_CACHE_SIZE];
	u64 cache_mask;
};

struct stack_dump {
	u16 offset;
	u64 size;
	char *data;
};

struct sample_read_value {
	u64 value;
	u64 id;   /* only if PERF_FORMAT_ID */
	u64 lost; /* only if PERF_FORMAT_LOST */
};

struct sample_read {
	u64 time_enabled;
	u64 time_running;
	union {
		struct {
			u64 nr;
			struct sample_read_value *values;
		} group;
		struct sample_read_value one;
	};
};

static inline size_t sample_read_value_size(u64 read_format)
{
	/* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */
	if (read_format & PERF_FORMAT_LOST)
		return sizeof(struct sample_read_value);
	else
		return offsetof(struct sample_read_value, lost);
}

static inline struct sample_read_value *next_sample_read_value(struct sample_read_value *v, u64 read_format)
{
	return (void *)v + sample_read_value_size(read_format);
}

#define sample_read_group__for_each(v, nr, rf) \
	for (int __i = 0; __i < (int)nr; v = next_sample_read_value(v, rf), __i++)

#define MAX_INSN 16

struct aux_sample {
	u64 size;
	void *data;
};

struct simd_flags {
	u8	arch:  2,	/* architecture (isa) */
		pred:  3,	/* predication */
		resv:  3;	/* reserved */
};

/* simd architecture flags */
enum simd_op_flags {
	SIMD_OP_FLAGS_ARCH_NONE = 0x0,	/* No SIMD operation */
	SIMD_OP_FLAGS_ARCH_SVE,		/* Arm SVE */
	SIMD_OP_FLAGS_ARCH_SME,		/* Arm SME */
	SIMD_OP_FLAGS_ARCH_ASE,		/* Arm Advanced SIMD */
};

/* simd predicate flags */
enum simd_pred_flags {
	SIMD_OP_FLAGS_PRED_NONE = 0x0,	/* Not available */
	SIMD_OP_FLAGS_PRED_PARTIAL,	/* partial predicate */
	SIMD_OP_FLAGS_PRED_EMPTY,	/* empty predicate */
	SIMD_OP_FLAGS_PRED_FULL,	/* full predicate */
	SIMD_OP_FLAGS_PRED_DISABLED,	/* disabled predicate */
};

/**
 * struct perf_sample
 *
 * A sample is generally filled in by evlist__parse_sample/evsel__parse_sample
 * which fills in the variables from a "union perf_event *event" which is data
 * from a perf ring buffer or perf.data file. The "event" sample is variable in
 * length as determined by the perf_event_attr (in the evsel) and details within
 * the sample event itself. A struct perf_sample avoids needing to care about
 * the variable length nature of the original event.

Annotation

Implementation Notes