Blame src/libpfm-3.y/include/perfmon/perfmon_pebs_core_smpl.h

Packit 577717
/*
Packit 577717
 * Copyright (c) 2005-2007 Hewlett-Packard Development Company, L.P.
Packit 577717
 *               Contributed by Stephane Eranian <eranian@hpl.hp.com>
Packit 577717
 *
Packit 577717
 * This file implements the sampling format to support Intel
Packit 577717
 * Precise Event Based Sampling (PEBS) feature of Intel
Packit 577717
 * Core and Atom processors.
Packit 577717
 *
Packit 577717
 * What is PEBS?
Packit 577717
 * ------------
Packit 577717
 *  This is a hardware feature to enhance sampling by providing
Packit 577717
 *  better precision as to where a sample is taken. This avoids the
Packit 577717
 *  typical skew in the instruction one can observe with any
Packit 577717
 *  interrupt-based sampling technique.
Packit 577717
 *
Packit 577717
 *  PEBS also lowers sampling overhead significantly by having the
Packit 577717
 *  processor store samples instead of the OS. PMU interrupt are only
Packit 577717
 *  generated after multiple samples are written.
Packit 577717
 *
Packit 577717
 *  Another benefit of PEBS is that samples can be captured inside
Packit 577717
 *  critical sections where interrupts are masked.
Packit 577717
 *
Packit 577717
 * How does it work?
Packit 577717
 *  PEBS effectively implements a Hw buffer. The Os must pass a region
Packit 577717
 *  of memory where samples are to be stored. The region can have any
Packit 577717
 *  size. The OS must also specify the sampling period to reload. The PMU
Packit 577717
 *  will interrupt when it reaches the end of the buffer or a specified
Packit 577717
 *  threshold location inside the memory region.
Packit 577717
 *
Packit 577717
 *  The description of the buffer is stored in the Data Save Area (DS).
Packit 577717
 *  The samples are stored sequentially in the buffer. The format of the
Packit 577717
 *  buffer is fixed and specified in the PEBS documentation.  The sample
Packit 577717
 *  format does not change between 32-bit and 64-bit modes unlike on the
Packit 577717
 *  Pentium 4 version of PEBS.
Packit 577717
 *
Packit 577717
 *  What does the format do?
Packit 577717
 *   It provides access to the PEBS feature for both 32-bit and 64-bit
Packit 577717
 *   processors that support it.
Packit 577717
 *
Packit 577717
 *   The same code and data structures are used for both 32-bit and 64-bi
Packit 577717
 *   modes. A single format name is used for both modes. In 32-bit mode,
Packit 577717
 *   some of the extended registers are written to zero in each sample.
Packit 577717
 *
Packit 577717
 *   It is important to realize that the format provides a zero-copy
Packit 577717
 *   environment for the samples, i.e,, the OS never touches the
Packit 577717
 *   samples. Whatever the processor write is directly accessible to
Packit 577717
 *   the user.
Packit 577717
 *
Packit 577717
 *   Parameters to the buffer can be passed via pfm_create_context() in
Packit 577717
 *   the pfm_pebs_smpl_arg structure.
Packit 577717
 */
Packit 577717
#ifndef __PERFMON_PEBS_CORE_SMPL_H__
Packit 577717
#define __PERFMON_PEBS_CORE_SMPL_H__ 1
Packit 577717
Packit 577717
#ifdef __cplusplus
Packit 577717
extern "C" {
Packit 577717
#endif
Packit 577717
Packit 577717
#include <perfmon/perfmon.h>
Packit 577717
Packit 577717
#define PFM_PEBS_CORE_SMPL_NAME	"pebs_core"
Packit 577717
Packit 577717
/*
Packit 577717
 * format specific parameters (passed at context creation)
Packit 577717
 */
Packit 577717
typedef struct {
Packit 577717
	uint64_t	cnt_reset;	/* counter reset value */
Packit 577717
	uint64_t	buf_size;	/* size of the buffer in bytes */
Packit 577717
	uint64_t	intr_thres;	/* index of interrupt threshold entry */
Packit 577717
	uint64_t	reserved[6];	/* for future use */
Packit 577717
} pfm_pebs_core_smpl_arg_t;
Packit 577717
Packit 577717
/*
Packit 577717
 * DS Save Area
Packit 577717
 */
Packit 577717
typedef struct {
Packit 577717
	uint64_t	bts_buf_base;
Packit 577717
	uint64_t	bts_index;
Packit 577717
	uint64_t	bts_abs_max;
Packit 577717
	uint64_t	bts_intr_thres;
Packit 577717
	uint64_t	pebs_buf_base;
Packit 577717
	uint64_t	pebs_index;
Packit 577717
	uint64_t	pebs_abs_max;
Packit 577717
	uint64_t	pebs_intr_thres;
Packit 577717
	uint64_t	pebs_cnt_reset;
Packit 577717
} pfm_ds_area_core_t; 
Packit 577717
Packit 577717
/*
Packit 577717
 * This header is at the beginning of the sampling buffer returned to the user.
Packit 577717
 *
Packit 577717
 * Because of PEBS alignement constraints, the actual PEBS buffer area does
Packit 577717
 * not necessarily begin right after the header. The hdr_start_offs must be
Packit 577717
 * used to compute the first byte of the buffer. The offset is defined as
Packit 577717
 * the number of bytes between the end of the header and the beginning of
Packit 577717
 * the buffer. As such the formula is:
Packit 577717
 * 	actual_buffer = (unsigned long)(hdr+1)+hdr->hdr_start_offs
Packit 577717
 */
Packit 577717
typedef struct {
Packit 577717
	uint64_t		overflows;	/* #overflows for buffer */
Packit 577717
	size_t			buf_size;	/* bytes in the buffer */
Packit 577717
	size_t			start_offs;	/* actual buffer start offset */
Packit 577717
	uint32_t		version;	/* smpl format version */
Packit 577717
	uint32_t		reserved1;	/* for future use */
Packit 577717
	uint64_t		reserved2[5];	/* for future use */
Packit 577717
	pfm_ds_area_core_t	ds;		/* DS management Area */
Packit 577717
} pfm_pebs_core_smpl_hdr_t;
Packit 577717
Packit 577717
/*
Packit 577717
 * PEBS record format as for both 32-bit and 64-bit modes
Packit 577717
 */
Packit 577717
typedef struct {
Packit 577717
	uint64_t eflags;
Packit 577717
	uint64_t ip;
Packit 577717
	uint64_t eax;
Packit 577717
	uint64_t ebx;
Packit 577717
	uint64_t ecx;
Packit 577717
	uint64_t edx;
Packit 577717
	uint64_t esi;
Packit 577717
	uint64_t edi;
Packit 577717
	uint64_t ebp;
Packit 577717
	uint64_t esp;
Packit 577717
	uint64_t r8;	/* 0 in 32-bit mode */
Packit 577717
	uint64_t r9;	/* 0 in 32-bit mode */
Packit 577717
	uint64_t r10;	/* 0 in 32-bit mode */
Packit 577717
	uint64_t r11;	/* 0 in 32-bit mode */
Packit 577717
	uint64_t r12;	/* 0 in 32-bit mode */
Packit 577717
	uint64_t r13;	/* 0 in 32-bit mode */
Packit 577717
	uint64_t r14;	/* 0 in 32-bit mode */
Packit 577717
	uint64_t r15;	/* 0 in 32-bit mode */
Packit 577717
} pfm_pebs_core_smpl_entry_t;
Packit 577717
Packit 577717
#define PFM_PEBS_CORE_SMPL_VERSION_MAJ 1U
Packit 577717
#define PFM_PEBS_CORE_SMPL_VERSION_MIN 0U
Packit 577717
#define PFM_PEBS_CORE_SMPL_VERSION (((PFM_PEBS_CORE_SMPL_VERSION_MAJ&0xffff)<<16)|\
Packit 577717
				   (PFM_PEBS_CORE_SMPL_VERSION_MIN & 0xffff))
Packit 577717
Packit 577717
#ifdef __cplusplus
Packit 577717
};
Packit 577717
#endif
Packit 577717
Packit 577717
#endif /* __PERFMON_PEBS_CORE_SMPL_H__ */