PAPI 7.1.0.0
Loading...
Searching...
No Matches
pfmlib_os_linux_v2.c File Reference
Include dependency graph for pfmlib_os_linux_v2.c:

Go to the source code of this file.

Data Structures

struct  pfarg_ctx22_t
 

Macros

#define PFM_pfm_create_context   (_pfmlib_get_sys_base()+0)
 
#define PFM_pfm_write_pmcs   (_pfmlib_get_sys_base()+1)
 
#define PFM_pfm_write_pmds   (_pfmlib_get_sys_base()+2)
 
#define PFM_pfm_read_pmds   (_pfmlib_get_sys_base()+3)
 
#define PFM_pfm_load_context   (_pfmlib_get_sys_base()+4)
 
#define PFM_pfm_start   (_pfmlib_get_sys_base()+5)
 
#define PFM_pfm_stop   (_pfmlib_get_sys_base()+6)
 
#define PFM_pfm_restart   (_pfmlib_get_sys_base()+7)
 
#define PFM_pfm_create_evtsets   (_pfmlib_get_sys_base()+8)
 
#define PFM_pfm_getinfo_evtsets   (_pfmlib_get_sys_base()+9)
 
#define PFM_pfm_delete_evtsets   (_pfmlib_get_sys_base()+10)
 
#define PFM_pfm_unload_context   (_pfmlib_get_sys_base()+11)
 

Functions

static int pfm_create_context_2v3 (pfarg_ctx_t *ctx, char *name, void *smpl_arg, size_t smpl_size)
 
static int pfm_write_pmcs_2v3 (int fd, pfarg_pmc_t *pmcs, int count)
 
static int pfm_write_pmds_2v3 (int fd, pfarg_pmd_t *pmds, int count)
 
static int pfm_read_pmds_2v3 (int fd, pfarg_pmd_t *pmds, int count)
 
static int pfm_load_context_2v3 (int fd, pfarg_load_t *load)
 
static int pfm_start_2v3 (int fd, pfarg_start_t *start)
 
static int pfm_stop_2v3 (int fd)
 
static int pfm_restart_2v3 (int fd)
 
static int pfm_create_evtsets_2v3 (int fd, pfarg_setdesc_t *setd, int count)
 
static int pfm_delete_evtsets_2v3 (int fd, pfarg_setdesc_t *setd, int count)
 
static int pfm_getinfo_evtsets_2v3 (int fd, pfarg_setinfo_t *info, int count)
 
static int pfm_unload_context_2v3 (int fd)
 
int pfm_load_context (int fd, pfarg_load_t *load)
 
int pfm_start (int fd, pfarg_start_t *start)
 
int pfm_stop (int fd)
 
int pfm_restart (int fd)
 
int pfm_create_evtsets (int fd, pfarg_setdesc_t *setd, int count)
 
int pfm_delete_evtsets (int fd, pfarg_setdesc_t *setd, int count)
 
int pfm_getinfo_evtsets (int fd, pfarg_setinfo_t *info, int count)
 
int pfm_unload_context (int fd)
 
int pfm_create_context (pfarg_ctx_t *ctx, char *name, void *smpl_arg, size_t smpl_size)
 
int pfm_write_pmcs (int fd, pfarg_pmc_t *pmcs, int count)
 
int pfm_write_pmds (int fd, pfarg_pmd_t *pmds, int count)
 
int pfm_read_pmds (int fd, pfarg_pmd_t *pmds, int count)
 

Macro Definition Documentation

◆ PFM_pfm_create_context

#define PFM_pfm_create_context   (_pfmlib_get_sys_base()+0)

Definition at line 41 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_create_evtsets

#define PFM_pfm_create_evtsets   (_pfmlib_get_sys_base()+8)

Definition at line 49 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_delete_evtsets

#define PFM_pfm_delete_evtsets   (_pfmlib_get_sys_base()+10)

Definition at line 51 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_getinfo_evtsets

#define PFM_pfm_getinfo_evtsets   (_pfmlib_get_sys_base()+9)

Definition at line 50 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_load_context

#define PFM_pfm_load_context   (_pfmlib_get_sys_base()+4)

Definition at line 45 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_read_pmds

#define PFM_pfm_read_pmds   (_pfmlib_get_sys_base()+3)

Definition at line 44 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_restart

#define PFM_pfm_restart   (_pfmlib_get_sys_base()+7)

Definition at line 48 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_start

#define PFM_pfm_start   (_pfmlib_get_sys_base()+5)

Definition at line 46 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_stop

#define PFM_pfm_stop   (_pfmlib_get_sys_base()+6)

Definition at line 47 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_unload_context

#define PFM_pfm_unload_context   (_pfmlib_get_sys_base()+11)

Definition at line 52 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_write_pmcs

#define PFM_pfm_write_pmcs   (_pfmlib_get_sys_base()+1)

Definition at line 42 of file pfmlib_os_linux_v2.c.

◆ PFM_pfm_write_pmds

#define PFM_pfm_write_pmds   (_pfmlib_get_sys_base()+2)

Definition at line 43 of file pfmlib_os_linux_v2.c.

Function Documentation

◆ pfm_create_context()

int pfm_create_context ( pfarg_ctx_t ctx,
char *  name,
void *  smpl_arg,
size_t  smpl_size 
)

Definition at line 483 of file pfmlib_os_linux_v2.c.

484{
485 if (_pfmlib_major_version < 3) {
486 /*
487 * In perfmon v2.2, the pfm_create_context() call had a
488 * different return value. It used to return errno, in v2.3
489 * it returns the file descriptor.
490 */
491 if (_pfmlib_minor_version < 3) {
492 int r;
493 pfarg_ctx22_t ctx22;
494
495 /* transfer the v2.3 contents to v2.2 for sys call */
496 memset (&ctx22, 0, sizeof(ctx22));
497 if (name != NULL) {
498 memcpy (ctx22.ctx_smpl_buf_id, name, 16);
499 }
500 ctx22.ctx_flags = ctx->ctx_flags;
501 /* ctx22.ctx_fd returned */
502 /* ctx22.ctx_smpl_buf_size returned */
503 memcpy (ctx22.ctx_reserved3, &ctx->ctx_reserved1, 64);
504
505 r = syscall (PFM_pfm_create_context, &ctx22, smpl_arg, smpl_size);
506
507 /* transfer the v2.2 contents back to v2.3 */
508 ctx->ctx_flags = ctx22.ctx_flags;
509 memcpy (&ctx->ctx_reserved1, ctx22.ctx_reserved3, 64);
510
511 return (r < 0 ? r : ctx22.ctx_fd);
512 } else {
513 return (int)syscall(PFM_pfm_create_context, ctx, name, smpl_arg, smpl_size);
514 }
515 }
516 return pfm_create_context_2v3(ctx, name, smpl_arg, smpl_size);
517}
int _pfmlib_major_version
int _pfmlib_minor_version
#define PFM_pfm_create_context
static int pfm_create_context_2v3(pfarg_ctx_t *ctx, char *name, void *smpl_arg, size_t smpl_size)
const char * name
Definition: rocs.c:225
uint64_t ctx_reserved3[12]
unsigned char ctx_smpl_buf_id[16]
uint32_t ctx_flags
Definition: perfmon_v2.h:19
uint32_t ctx_reserved1
Definition: perfmon_v2.h:20
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_create_context_2v3()

static int pfm_create_context_2v3 ( pfarg_ctx_t ctx,
char *  name,
void *  smpl_arg,
size_t  smpl_size 
)
static

Definition at line 72 of file pfmlib_os_linux_v2.c.

73{
74 pfarg_sinfo_t cinfo;
75 uint32_t fl;
76
77 /*
78 * simulate kernel returning error on NULL ctx
79 */
80 if (!ctx) {
81 errno = EINVAL;
82 return -1;
83 }
84
85 /*
86 * if sampling format is used, then force SMPL_FMT
87 * and PFM_FL_SINFO because it comes first
88 */
89 fl = ctx->ctx_flags;
90 if (name || smpl_arg || smpl_size)
91 fl |= PFM_FL_SMPL_FMT;
92
93 return pfm_create(fl, &cinfo, name, smpl_arg, smpl_size);
94}
int errno
os_err_t pfm_create(int flags, pfarg_sinfo_t *sif,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_create_evtsets()

int pfm_create_evtsets ( int  fd,
pfarg_setdesc_t setd,
int  count 
)

Definition at line 449 of file pfmlib_os_linux_v2.c.

450{
451 if (_pfmlib_major_version < 3)
452 return (int)syscall(PFM_pfm_create_evtsets, fd, setd, count);
453 return pfm_create_evtsets_2v3(fd, setd, count);
454}
static long count
static int pfm_create_evtsets_2v3(int fd, pfarg_setdesc_t *setd, int count)
#define PFM_pfm_create_evtsets
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_create_evtsets_2v3()

static int pfm_create_evtsets_2v3 ( int  fd,
pfarg_setdesc_t setd,
int  count 
)
static

Definition at line 257 of file pfmlib_os_linux_v2.c.

258{
259 /* set_desc an setdesc are identical so we can cast */
260 return pfm_create_sets(fd, 0, (pfarg_set_desc_t *)setd, count * sizeof(pfarg_setdesc_t));
261}
os_err_t pfm_create_sets(int fd, int flags, pfarg_set_desc_t *s, size_t sz)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_delete_evtsets()

int pfm_delete_evtsets ( int  fd,
pfarg_setdesc_t setd,
int  count 
)

Definition at line 457 of file pfmlib_os_linux_v2.c.

458{
459 if (_pfmlib_major_version < 3)
460 return (int)syscall(PFM_pfm_delete_evtsets, fd, setd, count);
461 return pfm_delete_evtsets_2v3(fd, setd, count);
462}
static int pfm_delete_evtsets_2v3(int fd, pfarg_setdesc_t *setd, int count)
#define PFM_pfm_delete_evtsets
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_delete_evtsets_2v3()

static int pfm_delete_evtsets_2v3 ( int  fd,
pfarg_setdesc_t setd,
int  count 
)
static

Definition at line 264 of file pfmlib_os_linux_v2.c.

265{
266 __pfm_vbprintf("pfm_delete_evtsets not supported in v3.x\n");
267 errno = EINVAL;
268 return -1;
269}
void __pfm_vbprintf(const char *fmt,...)
Definition: pfmlib_priv.c:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_getinfo_evtsets()

int pfm_getinfo_evtsets ( int  fd,
pfarg_setinfo_t info,
int  count 
)

Definition at line 465 of file pfmlib_os_linux_v2.c.

466{
467 if (_pfmlib_major_version < 3)
468 return (int)syscall(PFM_pfm_getinfo_evtsets, fd, info, count);
469
470 return pfm_getinfo_evtsets_2v3(fd, info, count);
471}
static int pfm_getinfo_evtsets_2v3(int fd, pfarg_setinfo_t *info, int count)
#define PFM_pfm_getinfo_evtsets
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_getinfo_evtsets_2v3()

static int pfm_getinfo_evtsets_2v3 ( int  fd,
pfarg_setinfo_t info,
int  count 
)
static

Definition at line 272 of file pfmlib_os_linux_v2.c.

273{
274 pfarg_sinfo_t cinfo;
275 pfarg_set_info_t *sif;
276 int fdx, i, ret, errno_save;
277
278 if (!info) {
279 errno = EFAULT;
280 return -1;
281 }
282 /*
283 * initialize bitmask to all available and defer checking
284 * until kernel. That means libpfm must be misled but we
285 * have no other way of fixing this
286 */
287 memset(&cinfo, -1, sizeof(cinfo));
288
289 /*
290 * XXX: relies on the fact that cinfo is independent
291 * of the session type (which is wrong in the future)
292 */
293 fdx = pfm_create(0, &cinfo);
294 if (fdx > -1)
295 close(fdx);
296
297 sif = calloc(count, sizeof(*sif));
298 if (!sif) {
299 errno = ENOMEM;
300 return -1;
301 }
302
303 for (i=0 ; i < count; i++)
304 sif[i].set_id = info[i].set_id;
305
306 ret = pfm_getinfo_sets(fd, 0, sif, count * sizeof(pfarg_set_info_t));
307 errno_save = errno;
308 if (ret)
309 goto skip;
310
311 for (i=0 ; i < count; i++) {
312 info[i].set_flags = 0;
313
314 memcpy(info[i].set_ovfl_pmds,
315 sif[i].set_ovfl_pmds,
316 sizeof(info[i].set_ovfl_pmds));
317
318 info[i].set_runs = sif[i].set_runs;
319 info[i].set_timeout = sif[i].set_timeout;
320 info[i].set_act_duration = sif[i].set_duration;
321
322 memcpy(info[i].set_avail_pmcs,
323 cinfo.sif_avail_pmcs,
324 sizeof(info[i].set_avail_pmcs));
325
326 memcpy(info[i].set_avail_pmds,
327 cinfo.sif_avail_pmds,
328 sizeof(info[i].set_avail_pmds));
329 }
330skip:
331 free(sif);
332 errno = errno_save;
333 return ret;
334}
int i
int close(int fd)
Definition: appio.c:179
os_err_t pfm_getinfo_sets(int fd, int flags, pfarg_set_info_t *s, size_t sz)
static int skip
uint64_t set_act_duration
Definition: perfmon_v2.h:91
uint32_t set_flags
Definition: perfmon_v2.h:87
uint64_t set_runs
Definition: perfmon_v2.h:89
uint64_t set_timeout
Definition: perfmon_v2.h:90
uint64_t sif_avail_pmds[PFM_PMD_BV]
uint64_t sif_avail_pmcs[PFM_PMC_BV]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_load_context()

int pfm_load_context ( int  fd,
pfarg_load_t load 
)

Definition at line 417 of file pfmlib_os_linux_v2.c.

418{
419 if (_pfmlib_major_version < 3)
420 return (int)syscall(PFM_pfm_load_context, fd, load);
421 return pfm_load_context_2v3(fd, load);
422}
static int pfm_load_context_2v3(int fd, pfarg_load_t *load)
#define PFM_pfm_load_context
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_load_context_2v3()

static int pfm_load_context_2v3 ( int  fd,
pfarg_load_t load 
)
static

Definition at line 225 of file pfmlib_os_linux_v2.c.

226{
227 if (!load) {
228 errno = EINVAL;
229 return -1;
230 }
231 return pfm_attach(fd, 0, load->load_pid);
232}
os_err_t pfm_attach(int fd, int flags, int target)
uint32_t load_pid
Definition: perfmon_v2.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_read_pmds()

int pfm_read_pmds ( int  fd,
pfarg_pmd_t pmds,
int  count 
)

Definition at line 536 of file pfmlib_os_linux_v2.c.

537{
538 if (_pfmlib_major_version < 3)
539 return (int)syscall(PFM_pfm_read_pmds, fd, pmds, count);
540 return pfm_read_pmds_2v3(fd, pmds, count);
541}
#define PFM_pfm_read_pmds
static int pfm_read_pmds_2v3(int fd, pfarg_pmd_t *pmds, int count)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_read_pmds_2v3()

static int pfm_read_pmds_2v3 ( int  fd,
pfarg_pmd_t pmds,
int  count 
)
static

Definition at line 177 of file pfmlib_os_linux_v2.c.

178{
179 pfarg_pmd_attr_t *pmas;
180 int errno_save;
181 int i, ret;
182 size_t sz;
183
184 sz = count * sizeof(*pmas);
185
186 if (!pmds)
187 return pfm_write(fd, 0, PFM_RW_PMD, NULL, sz);
188
189 pmas = calloc(count, sizeof(*pmas));
190 if (!pmas) {
191 errno = ENOMEM;
192 return -1;
193 }
194
195 for (i=0 ; i < count; i++) {
196 pmas[i].reg_num = pmds[i].reg_num;
197 pmas[i].reg_set = pmds[i].reg_set;
198 pmas[i].reg_flags = pmds[i].reg_flags;
199 pmas[i].reg_value = pmds[i].reg_value;
200 }
201
202 ret = pfm_read(fd, 0, PFM_RW_PMD_ATTR, pmas, sz);
203
204 errno_save = errno;
205
206 for (i=0 ; i < count; i++) {
207 pmds[i].reg_value = pmas[i].reg_value;
208
209 pmds[i].reg_long_reset = pmas[i].reg_long_reset;
210 pmds[i].reg_short_reset = pmas[i].reg_short_reset;
211 pmds[i].reg_last_reset_val = pmas[i].reg_last_value;
212
214 /* skip reg_smpl_pmds */
215 /* skip reg_reset_pmds */
216 /* skip reg_smpl_eventid */
217 /* skip reg_random_mask */
218 }
219 free(pmas);
220 errno = errno_save;
221 return ret;
222}
os_err_t pfm_read(int fd, int flags, int type, void *reg, size_t n)
os_err_t pfm_write(int fd, int flags, int type, void *reg, size_t n)
uint64_t reg_value
Definition: perfmon_v2.h:42
uint64_t reg_short_reset
Definition: perfmon_v2.h:44
uint64_t reg_ovfl_switch_cnt
Definition: perfmon_v2.h:46
uint32_t reg_flags
Definition: perfmon_v2.h:41
uint64_t reg_last_reset_val
Definition: perfmon_v2.h:45
uint16_t reg_set
Definition: perfmon_v2.h:40
uint64_t reg_long_reset
Definition: perfmon_v2.h:43
uint16_t reg_num
Definition: perfmon_v2.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_restart()

int pfm_restart ( int  fd)

Definition at line 441 of file pfmlib_os_linux_v2.c.

442{
443 if (_pfmlib_major_version < 3)
444 return (int)syscall(PFM_pfm_restart, fd);
445 return pfm_restart_2v3(fd);
446}
static int pfm_restart_2v3(int fd)
#define PFM_pfm_restart
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_restart_2v3()

static int pfm_restart_2v3 ( int  fd)
static

Definition at line 251 of file pfmlib_os_linux_v2.c.

252{
253 return pfm_set_state(fd, 0, PFM_ST_RESTART);
254}
os_err_t pfm_set_state(int fd, int flags, int state)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_start()

int pfm_start ( int  fd,
pfarg_start_t start 
)

Definition at line 425 of file pfmlib_os_linux_v2.c.

426{
427 if (_pfmlib_major_version < 3)
428 return (int)syscall(PFM_pfm_start, fd, start);
429 return pfm_start_2v3(fd, start);
430}
static struct timeval start
#define PFM_pfm_start
static int pfm_start_2v3(int fd, pfarg_start_t *start)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_start_2v3()

static int pfm_start_2v3 ( int  fd,
pfarg_start_t start 
)
static

Definition at line 235 of file pfmlib_os_linux_v2.c.

236{
237 if (start) {
238 __pfm_vbprintf("pfarg_start_t not supported in v3.x\n");
239 errno = EINVAL;
240 return -1;
241 }
242 return pfm_set_state(fd, 0, PFM_ST_START);
243}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_stop()

int pfm_stop ( int  fd)

Definition at line 433 of file pfmlib_os_linux_v2.c.

434{
435 if (_pfmlib_major_version < 3)
436 return (int)syscall(PFM_pfm_stop, fd);
437 return pfm_stop_2v3(fd);
438}
static int pfm_stop_2v3(int fd)
#define PFM_pfm_stop
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_stop_2v3()

static int pfm_stop_2v3 ( int  fd)
static

Definition at line 245 of file pfmlib_os_linux_v2.c.

246{
247 return pfm_set_state(fd, 0, PFM_ST_STOP);
248}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_unload_context()

int pfm_unload_context ( int  fd)

Definition at line 474 of file pfmlib_os_linux_v2.c.

475{
476 if (_pfmlib_major_version < 3)
477 return (int)syscall(PFM_pfm_unload_context, fd);
478
479 return pfm_unload_context_2v3(fd);
480}
#define PFM_pfm_unload_context
static int pfm_unload_context_2v3(int fd)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_unload_context_2v3()

static int pfm_unload_context_2v3 ( int  fd)
static

Definition at line 337 of file pfmlib_os_linux_v2.c.

338{
339 return pfm_attach(fd, 0, PFM_NO_TARGET);
340}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_write_pmcs()

int pfm_write_pmcs ( int  fd,
pfarg_pmc_t pmcs,
int  count 
)

Definition at line 520 of file pfmlib_os_linux_v2.c.

521{
522 if (_pfmlib_major_version < 3)
523 return (int)syscall(PFM_pfm_write_pmcs, fd, pmcs, count);
524 return pfm_write_pmcs_2v3(fd, pmcs, count);
525}
static int pfm_write_pmcs_2v3(int fd, pfarg_pmc_t *pmcs, int count)
#define PFM_pfm_write_pmcs
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_write_pmcs_2v3()

static int pfm_write_pmcs_2v3 ( int  fd,
pfarg_pmc_t pmcs,
int  count 
)
static

Definition at line 97 of file pfmlib_os_linux_v2.c.

98{
99 pfarg_pmr_t *pmrs;
100 int errno_save;
101 int i, ret;
102 size_t sz;
103
104 sz = count * sizeof(pfarg_pmr_t);
105
106 if (!pmcs)
107 return pfm_write(fd, 0, PFM_RW_PMC, NULL, sz);
108
109 pmrs = calloc(count, sizeof(*pmrs));
110 if (!pmrs) {
111 errno = ENOMEM;
112 return -1;
113 }
114
115 for (i=0 ; i < count; i++) {
116 pmrs[i].reg_num = pmcs[i].reg_num;
117 pmrs[i].reg_set = pmcs[i].reg_set;
118 pmrs[i].reg_flags = pmcs[i].reg_flags;
119 pmrs[i].reg_value = pmcs[i].reg_value;
120 }
121
122 ret = pfm_write(fd, 0, PFM_RW_PMC, pmrs, sz);
123 errno_save = errno;
124 free(pmrs);
125 errno = errno_save;
126 return ret;
127}
uint32_t reg_flags
Definition: perfmon_v2.h:30
uint16_t reg_set
Definition: perfmon_v2.h:29
uint16_t reg_num
Definition: perfmon_v2.h:28
uint64_t reg_value
Definition: perfmon_v2.h:31
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_write_pmds()

int pfm_write_pmds ( int  fd,
pfarg_pmd_t pmds,
int  count 
)

Definition at line 528 of file pfmlib_os_linux_v2.c.

529{
530 if (_pfmlib_major_version < 3)
531 return (int)syscall(PFM_pfm_write_pmds, fd, pmds, count);
532 return pfm_write_pmds_2v3(fd, pmds, count);
533}
#define PFM_pfm_write_pmds
static int pfm_write_pmds_2v3(int fd, pfarg_pmd_t *pmds, int count)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pfm_write_pmds_2v3()

static int pfm_write_pmds_2v3 ( int  fd,
pfarg_pmd_t pmds,
int  count 
)
static

Definition at line 130 of file pfmlib_os_linux_v2.c.

131{
132 pfarg_pmd_attr_t *pmas;
133 size_t sz;
134 int errno_save;
135 int i, ret;
136
137 sz = count * sizeof(*pmas);
138
139 if (!pmds)
140 return pfm_write(fd, 0, PFM_RW_PMD, NULL, sz);
141
142 pmas = calloc(count, sizeof(*pmas));
143 if (!pmas) {
144 errno = ENOMEM;
145 return -1;
146 }
147
148 for (i=0 ; i < count; i++) {
149 pmas[i].reg_num = pmds[i].reg_num;
150 pmas[i].reg_set = pmds[i].reg_set;
151 pmas[i].reg_flags = pmds[i].reg_flags;
152 pmas[i].reg_value = pmds[i].reg_value;
153
154 pmas[i].reg_long_reset = pmds[i].reg_long_reset;
155 pmas[i].reg_short_reset = pmds[i].reg_short_reset;
156 /* skip last_value not used on write */
157
159
160 memcpy(pmas[i].reg_smpl_pmds, pmds[i].reg_smpl_pmds, sizeof(pmds[i].reg_smpl_pmds));
161 memcpy(pmas[i].reg_reset_pmds, pmds[i].reg_reset_pmds, sizeof(pmds[i].reg_reset_pmds));
162
163 pmas[i].reg_smpl_eventid = pmds[i].reg_smpl_eventid;
164 pmas[i].reg_random_mask = pmds[i].reg_random_mask;
165 }
166
167 ret = pfm_write(fd, 0, PFM_RW_PMD_ATTR, pmas, sz);
168
169 errno_save = errno;
170 free(pmas);
171 errno = errno_save;
172
173 return ret;
174}
uint64_t reg_random_mask
Definition: perfmon_v2.h:50
uint64_t reg_smpl_eventid
Definition: perfmon_v2.h:49
Here is the call graph for this function:
Here is the caller graph for this function: