diff options
Diffstat (limited to 'tools/perf/util/event.h')
| -rw-r--r-- | tools/perf/util/event.h | 121 | 
1 files changed, 121 insertions, 0 deletions
| diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 7c3fa1c8cbcd..9967c87af7a6 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -252,6 +252,127 @@ enum auxtrace_error_type {  	PERF_AUXTRACE_ERROR_MAX  }; +/* Attribute type for custom synthesized events */ +#define PERF_TYPE_SYNTH		(INT_MAX + 1U) + +/* Attribute config for custom synthesized events */ +enum perf_synth_id { +	PERF_SYNTH_INTEL_PTWRITE, +	PERF_SYNTH_INTEL_MWAIT, +	PERF_SYNTH_INTEL_PWRE, +	PERF_SYNTH_INTEL_EXSTOP, +	PERF_SYNTH_INTEL_PWRX, +	PERF_SYNTH_INTEL_CBR, +}; + +/* + * Raw data formats for synthesized events. Note that 4 bytes of padding are + * present to match the 'size' member of PERF_SAMPLE_RAW data which is always + * 8-byte aligned. That means we must dereference raw_data with an offset of 4. + * Refer perf_sample__synth_ptr() and perf_synth__raw_data().  It also means the + * structure sizes are 4 bytes bigger than the raw_size, refer + * perf_synth__raw_size(). + */ + +struct perf_synth_intel_ptwrite { +	u32 padding; +	union { +		struct { +			u32	ip		:  1, +				reserved	: 31; +		}; +		u32	flags; +	}; +	u64	payload; +}; + +struct perf_synth_intel_mwait { +	u32 padding; +	u32 reserved; +	union { +		struct { +			u64	hints		:  8, +				reserved1	: 24, +				extensions	:  2, +				reserved2	: 30; +		}; +		u64	payload; +	}; +}; + +struct perf_synth_intel_pwre { +	u32 padding; +	u32 reserved; +	union { +		struct { +			u64	reserved1	:  7, +				hw		:  1, +				subcstate	:  4, +				cstate		:  4, +				reserved2	: 48; +		}; +		u64	payload; +	}; +}; + +struct perf_synth_intel_exstop { +	u32 padding; +	union { +		struct { +			u32	ip		:  1, +				reserved	: 31; +		}; +		u32	flags; +	}; +}; + +struct perf_synth_intel_pwrx { +	u32 padding; +	u32 reserved; +	union { +		struct { +			u64	deepest_cstate	:  4, +				last_cstate	:  4, +				wake_reason	:  4, +				reserved1	: 52; +		}; +		u64	payload; +	}; +}; + +struct perf_synth_intel_cbr { +	u32 padding; +	union { +		struct { +			u32	cbr		:  8, +				reserved1	:  8, +				max_nonturbo	:  8, +				reserved2	:  8; +		}; +		u32	flags; +	}; +	u32 freq; +	u32 reserved3; +}; + +/* + * raw_data is always 4 bytes from an 8-byte boundary, so subtract 4 to get + * 8-byte alignment. + */ +static inline void *perf_sample__synth_ptr(struct perf_sample *sample) +{ +	return sample->raw_data - 4; +} + +static inline void *perf_synth__raw_data(void *p) +{ +	return p + 4; +} + +#define perf_synth__raw_size(d) (sizeof(d) - 4) + +#define perf_sample__bad_synth_size(s, d) ((s)->raw_size < sizeof(d) - 4) +  /*   * The kernel collects the number of events it couldn't send in a stretch and   * when possible sends this number in a PERF_RECORD_LOST event. The number of |