PAPI 7.1.0.0
Loading...
Searching...
No Matches
perfmon_pebs_core_smpl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005-2007 Hewlett-Packard Development Company, L.P.
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
4 *
5 * This file implements the sampling format to support Intel
6 * Precise Event Based Sampling (PEBS) feature of Intel
7 * Core and Atom processors.
8 *
9 * What is PEBS?
10 * ------------
11 * This is a hardware feature to enhance sampling by providing
12 * better precision as to where a sample is taken. This avoids the
13 * typical skew in the instruction one can observe with any
14 * interrupt-based sampling technique.
15 *
16 * PEBS also lowers sampling overhead significantly by having the
17 * processor store samples instead of the OS. PMU interrupt are only
18 * generated after multiple samples are written.
19 *
20 * Another benefit of PEBS is that samples can be captured inside
21 * critical sections where interrupts are masked.
22 *
23 * How does it work?
24 * PEBS effectively implements a Hw buffer. The Os must pass a region
25 * of memory where samples are to be stored. The region can have any
26 * size. The OS must also specify the sampling period to reload. The PMU
27 * will interrupt when it reaches the end of the buffer or a specified
28 * threshold location inside the memory region.
29 *
30 * The description of the buffer is stored in the Data Save Area (DS).
31 * The samples are stored sequentially in the buffer. The format of the
32 * buffer is fixed and specified in the PEBS documentation. The sample
33 * format does not change between 32-bit and 64-bit modes unlike on the
34 * Pentium 4 version of PEBS.
35 *
36 * What does the format do?
37 * It provides access to the PEBS feature for both 32-bit and 64-bit
38 * processors that support it.
39 *
40 * The same code and data structures are used for both 32-bit and 64-bi
41 * modes. A single format name is used for both modes. In 32-bit mode,
42 * some of the extended registers are written to zero in each sample.
43 *
44 * It is important to realize that the format provides a zero-copy
45 * environment for the samples, i.e,, the OS never touches the
46 * samples. Whatever the processor write is directly accessible to
47 * the user.
48 *
49 * Parameters to the buffer can be passed via pfm_create_context() in
50 * the pfm_pebs_smpl_arg structure.
51 */
52#ifndef __PERFMON_PEBS_CORE_SMPL_H__
53#define __PERFMON_PEBS_CORE_SMPL_H__ 1
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59#include <perfmon/perfmon.h>
60
61#define PFM_PEBS_CORE_SMPL_NAME "pebs_core"
62
63/*
64 * format specific parameters (passed at context creation)
65 */
66typedef struct {
67 uint64_t cnt_reset; /* counter reset value */
68 uint64_t buf_size; /* size of the buffer in bytes */
69 uint64_t intr_thres; /* index of interrupt threshold entry */
70 uint64_t reserved[6]; /* for future use */
72
73/*
74 * DS Save Area
75 */
76typedef struct {
77 uint64_t bts_buf_base;
78 uint64_t bts_index;
79 uint64_t bts_abs_max;
81 uint64_t pebs_buf_base;
82 uint64_t pebs_index;
83 uint64_t pebs_abs_max;
87
88/*
89 * This header is at the beginning of the sampling buffer returned to the user.
90 *
91 * Because of PEBS alignement constraints, the actual PEBS buffer area does
92 * not necessarily begin right after the header. The hdr_start_offs must be
93 * used to compute the first byte of the buffer. The offset is defined as
94 * the number of bytes between the end of the header and the beginning of
95 * the buffer. As such the formula is:
96 * actual_buffer = (unsigned long)(hdr+1)+hdr->hdr_start_offs
97 */
98typedef struct {
99 uint64_t overflows; /* #overflows for buffer */
100 size_t buf_size; /* bytes in the buffer */
101 size_t start_offs; /* actual buffer start offset */
102 uint32_t version; /* smpl format version */
103 uint32_t reserved1; /* for future use */
104 uint64_t reserved2[5]; /* for future use */
105 pfm_ds_area_core_t ds; /* DS management Area */
107
108/*
109 * PEBS record format as for both 32-bit and 64-bit modes
110 */
111typedef struct {
112 uint64_t eflags;
113 uint64_t ip;
114 uint64_t eax;
115 uint64_t ebx;
116 uint64_t ecx;
117 uint64_t edx;
118 uint64_t esi;
119 uint64_t edi;
120 uint64_t ebp;
121 uint64_t esp;
122 uint64_t r8; /* 0 in 32-bit mode */
123 uint64_t r9; /* 0 in 32-bit mode */
124 uint64_t r10; /* 0 in 32-bit mode */
125 uint64_t r11; /* 0 in 32-bit mode */
126 uint64_t r12; /* 0 in 32-bit mode */
127 uint64_t r13; /* 0 in 32-bit mode */
128 uint64_t r14; /* 0 in 32-bit mode */
129 uint64_t r15; /* 0 in 32-bit mode */
131
132#define PFM_PEBS_CORE_SMPL_VERSION_MAJ 1U
133#define PFM_PEBS_CORE_SMPL_VERSION_MIN 0U
134#define PFM_PEBS_CORE_SMPL_VERSION (((PFM_PEBS_CORE_SMPL_VERSION_MAJ&0xffff)<<16)|\
135 (PFM_PEBS_CORE_SMPL_VERSION_MIN & 0xffff))
136
137#ifdef __cplusplus
138};
139#endif
140
141#endif /* __PERFMON_PEBS_CORE_SMPL_H__ */
uint16_t reserved
uint64_t edi
uint64_t ecx
uint64_t r10
uint64_t ebp
uint64_t ip
uint64_t esi
uint64_t r8
uint64_t r12
uint64_t eflags
uint64_t edx
uint64_t esp
uint64_t ebx
uint64_t r14
uint64_t r15
uint64_t r13
uint64_t r9
uint64_t eax
uint64_t r11