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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/perf_event.hlinux/types.h
Detected Declarations
struct evselstruct machinestruct threadstruct regs_dumpstruct stack_dumpstruct sample_read_valuestruct sample_readstruct aux_samplestruct simd_flagsstruct perf_sampleenum simd_op_flagsenum simd_pred_flagsfunction sample_read_value_size
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
- Immediate include surface: `linux/perf_event.h`, `linux/types.h`.
- Detected declarations: `struct evsel`, `struct machine`, `struct thread`, `struct regs_dump`, `struct stack_dump`, `struct sample_read_value`, `struct sample_read`, `struct aux_sample`, `struct simd_flags`, `struct perf_sample`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.