PAPI 7.1.0.0
Loading...
Searching...
No Matches
libperfnec/include/perfmon/perfmon.h
Go to the documentation of this file.
1/*
2 * This file contains the user level interface description for
3 * the perfmon3.x interface on Linux.
4 *
5 * It also includes perfmon2.x interface definitions.
6 *
7 * Copyright (c) 2001-2006 Hewlett-Packard Development Company, L.P.
8 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
9 */
10#ifndef __PERFMON_H__
11#define __PERFMON_H__
12
13#include <sys/types.h>
14#include <stdint.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20
21#ifdef __x86_64__
23#endif
24
25#define PFM_MAX_PMCS PFM_ARCH_MAX_PMCS
26#define PFM_MAX_PMDS PFM_ARCH_MAX_PMDS
27
28#ifndef SWIG
29/*
30 * number of element for each type of bitvector
31 */
32#define PFM_BPL (sizeof(uint64_t)<<3)
33#define PFM_BVSIZE(x) (((x)+PFM_BPL-1) / PFM_BPL)
34#define PFM_PMD_BV PFM_BVSIZE(PFM_MAX_PMDS)
35#define PFM_PMC_BV PFM_BVSIZE(PFM_MAX_PMCS)
36#endif
37
38/*
39 * special data type for syscall error value used to help
40 * with Python support and in particular for SWIG. By using
41 * a specific type we can detect syscalls and trap errors
42 * in one SWIG statement as opposed to having to keep track of
43 * each syscall individually. Programs can use 'int' safely for
44 * the return value.
45 */
46typedef int os_err_t; /* error if -1 */
47
48/*
49 * passed to pfm_create
50 * contains list of available register upon return
51 */
52
53#define PFM_ARCH_MAX_PMCS 32
54#define PFM_ARCH_MAX_PMDS 32
55typedef struct {
56 uint64_t sif_avail_pmcs[PFM_PMC_BV]; /* out: available PMCs */
57 uint64_t sif_avail_pmds[PFM_PMD_BV]; /* out: available PMDs */
58 uint64_t sif_reserved[4];
60
61//os_err_t pfm_create(int flags, pfarg_sinfo_t *sif,
62// char *smpl_name, void *smpl_arg, size_t arg_size);
63extern os_err_t pfm_create(int flags, pfarg_sinfo_t *sif, ...);
64
65
66/*
67 * pfm_create flags:
68 * bits[00-15]: generic flags
69 * bits[16-31]: arch-specific flags (see perfmon_const.h)
70 */
71#define PFM_FL_NOTIFY_BLOCK 0x01 /* block task on user notifications */
72#define PFM_FL_SYSTEM_WIDE 0x02 /* create a system wide context */
73#define PFM_FL_SMPL_FMT 0x04 /* session uses sampling format */
74#define PFM_FL_OVFL_NO_MSG 0x80 /* no overflow msgs */
75
76/*
77 * PMC and PMD generic (simplified) register description
78 */
79typedef struct {
80 uint16_t reg_num; /* which register */
81 uint16_t reg_set; /* which event set */
82 uint32_t reg_flags; /* REGFL flags */
83 uint64_t reg_value; /* 64-bit value */
85
86/*
87 * pfarg_pmr_t flags:
88 * bit[00-15] : generic flags
89 * bit[16-31] : arch-specific flags
90 *
91 * PFM_REGFL_NO_EMUL64: must be set on the PMC controlling the PMD
92 */
93#define PFM_REGFL_OVFL_NOTIFY 0x1 /* PMD: send notification on event */
94#define PFM_REGFL_RANDOM 0x2 /* PMD: randomize value after event */
95#define PFM_REGFL_NO_EMUL64 0x4 /* PMC: no 64-bit emulation */
96
97/*
98 * PMD extended description
99 * to be used with pfm_writeand pfm_read
100 * must be used with type = PFM_RW_PMD_ATTR
101 */
102typedef struct {
103 uint16_t reg_num; /* which register */
104 uint16_t reg_set; /* which event set */
105 uint32_t reg_flags; /* REGFL flags */
106 uint64_t reg_value; /* 64-bit value */
107 uint64_t reg_long_reset; /* write: value to reload after notification */
108 uint64_t reg_short_reset; /* write: reset after counter overflow */
109 uint64_t reg_random_mask; /* write: bitmask used to limit random value */
110 uint64_t reg_smpl_pmds[PFM_PMD_BV]; /* write: record in sample */
111 uint64_t reg_reset_pmds[PFM_PMD_BV]; /* write: reset on overflow */
112 uint64_t reg_ovfl_swcnt; /* write: # overflows before switch */
113 uint64_t reg_smpl_eventid; /* write: opaque event identifier */
114 uint64_t reg_last_value; /* read: PMD last reset value */
115 uint64_t reg_reserved[8]; /* for future use */
117
118
119/*
120 * pfm_write, pfm_read type:
121 */
122#define PFM_RW_PMD 1 /* simplified PMD (pfarg_pmr_t) */
123#define PFM_RW_PMC 2 /* PMC registers (pfarg_pmr_t) */
124#define PFM_RW_PMD_ATTR 3 /* extended PMD (pfarg_pmd_attr) */
125
126/*
127 * pfm_attach special target for detach
128 */
129#define PFM_NO_TARGET -1 /* no target, detach */
130
131
132/*
133 * pfm_set_state state:
134 */
135#define PFM_ST_START 0x1 /* start monitoring */
136#define PFM_ST_STOP 0x2 /* stop monitoring */
137#define PFM_ST_RESTART 0x3 /* resume after notify */
138
139#ifndef PFMLIB_OLD_PFMV2
140typedef struct {
141 uint16_t set_id; /* which set */
142 uint16_t set_reserved1; /* for future use */
143 uint32_t set_flags; /* SETFL flags */
144 uint64_t set_timeout; /* requested/effective switch timeout in nsecs */
145 uint64_t reserved[6]; /* for future use */
147
148typedef struct {
149 uint16_t set_id; /* which set */
150 uint16_t set_reserved1; /* for future use */
151 uint32_t set_reserved2; /* for future use */
152 uint64_t set_ovfl_pmds[PFM_PMD_BV]; /* out: last ovfl PMDs */
153 uint64_t set_runs; /* out: #times set was active */
154 uint64_t set_timeout; /* out: leftover switch timeout (nsecs) */
155 uint64_t set_duration; /* out: time set was active (nsecs) */
156 uint64_t set_reserved3[4]; /* for future use */
158#endif
159
160/*
161 * pfm_set_desc_t flags:
162 */
163#define PFM_SETFL_OVFL_SWITCH 0x01 /* enable switch on overflow (subject to individual switch_cnt */
164#define PFM_SETFL_TIME_SWITCH 0x02 /* switch set on timeout */
165
166#ifndef PFMLIB_OLD_PFMV2
167typedef struct {
168 uint32_t msg_type; /* PFM_MSG_OVFL */
169 uint32_t msg_ovfl_pid; /* process id */
170 uint16_t msg_active_set; /* active set at the time of overflow */
171 uint16_t msg_ovfl_cpu; /* cpu on which the overflow occurred */
172 uint32_t msg_ovfl_tid; /* thread id */
173 uint64_t msg_ovfl_ip; /* instruction pointer where overflow interrupt happened */
174 uint64_t msg_ovfl_pmds[PFM_PMD_BV];/* which PMDs overflowed */
176
177extern os_err_t pfm_write(int fd, int flags, int type, void *reg, size_t n);
178extern os_err_t pfm_read(int fd, int flags, int type, void *reg, size_t n);
179extern os_err_t pfm_set_state(int fd, int flags, int state);
180extern os_err_t pfm_create_sets(int fd, int flags, pfarg_set_desc_t *s, size_t sz);
181extern os_err_t pfm_getinfo_sets(int fd, int flags, pfarg_set_info_t *s, size_t sz);
182extern os_err_t pfm_attach(int fd, int flags, int target);
183
184#endif
185
186#include "perfmon_v2.h"
187
188typedef union {
189 uint32_t type;
192
193#define PFM_MSG_OVFL 1 /* an overflow happened */
194#define PFM_MSG_END 2 /* thread to which context was attached ended */
195
196#define PFM_VERSION_MAJOR(x) (((x)>>16) & 0xffff)
197#define PFM_VERSION_MINOR(x) ((x) & 0xffff)
198
199#ifdef __cplusplus
200};
201#endif
202
203#endif /* _PERFMON_H */
double s
Definition: byte_profile.c:36
os_err_t pfm_read(int fd, int flags, int type, void *reg, size_t n)
os_err_t pfm_set_state(int fd, int flags, int state)
os_err_t pfm_create(int flags, pfarg_sinfo_t *sif,...)
os_err_t pfm_write(int fd, int flags, int type, void *reg, size_t n)
os_err_t pfm_getinfo_sets(int fd, int flags, pfarg_set_info_t *s, size_t sz)
os_err_t pfm_attach(int fd, int flags, int target)
os_err_t pfm_create_sets(int fd, int flags, pfarg_set_desc_t *s, size_t sz)
uint16_t reserved
uint16_t type
bool state
Definition: papi_hl.c:155