1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_SAMPLE_H
3 #define __PERF_SAMPLE_H
5 #include <linux/perf_event.h>
6 #include <linux/types.h>
8 /* number of register is bound by the number of bits in regs_dump::mask (64) */
9 #define PERF_SAMPLE_REGS_CACHE_SIZE (8 * sizeof(u64))
16 /* Cached values/mask filled by first register access. */
17 u64 cache_regs[PERF_SAMPLE_REGS_CACHE_SIZE];
27 struct sample_read_value {
29 u64 id; /* only if PERF_FORMAT_ID */
30 u64 lost; /* only if PERF_FORMAT_LOST */
39 struct sample_read_value *values;
41 struct sample_read_value one;
45 static inline size_t sample_read_value_size(u64 read_format)
47 /* PERF_FORMAT_ID is forced for PERF_SAMPLE_READ */
48 if (read_format & PERF_FORMAT_LOST)
49 return sizeof(struct sample_read_value);
51 return offsetof(struct sample_read_value, lost);
54 static inline struct sample_read_value *next_sample_read_value(struct sample_read_value *v, u64 read_format)
56 return (void *)v + sample_read_value_size(read_format);
59 #define sample_read_group__for_each(v, nr, rf) \
60 for (int __i = 0; __i < (int)nr; v = next_sample_read_value(v, rf), __i++)
96 bool no_hw_idx; /* No hw_idx collected in branch_stack */
99 struct ip_callchain *callchain;
100 struct branch_stack *branch_stack;
101 struct regs_dump user_regs;
102 struct regs_dump intr_regs;
103 struct stack_dump user_stack;
104 struct sample_read read;
105 struct aux_sample aux_sample;
109 * raw_data is always 4 bytes from an 8-byte boundary, so subtract 4 to get
112 static inline void *perf_sample__synth_ptr(struct perf_sample *sample)
114 return sample->raw_data - 4;
117 #endif /* __PERF_SAMPLE_H */