|
Packit |
577717 |
/* $Id: libperfctr.h,v 1.35.2.3 2009/01/23 20:25:42 mikpe Exp $
|
|
Packit |
577717 |
* Library interface to Linux x86 Performance-Monitoring Counters.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Copyright (C) 1999-2009 Mikael Pettersson
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#ifndef __LIB_PERFCTR_H
|
|
Packit |
577717 |
#define __LIB_PERFCTR_H
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define CONFIG_KPERFCTR 1
|
|
Packit |
577717 |
#include <linux/perfctr.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct perfctr_cpus_info { /* malloc():d, use free() */
|
|
Packit |
577717 |
struct perfctr_cpu_mask *cpus;
|
|
Packit |
577717 |
struct perfctr_cpu_mask *cpus_forbidden;
|
|
Packit |
577717 |
};
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Operations on the process' own virtual-mode perfctrs.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int _vperfctr_open(int creat);
|
|
Packit |
577717 |
int _vperfctr_control(int fd, const struct vperfctr_control*);
|
|
Packit |
577717 |
int _vperfctr_read_control(int fd, struct vperfctr_control*);
|
|
Packit |
577717 |
int _vperfctr_read_sum(int fd, struct perfctr_sum_ctrs*);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct vperfctr; /* opaque */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct vperfctr *vperfctr_open_mode(unsigned int mode);
|
|
Packit |
577717 |
#define VPERFCTR_OPEN_CREAT_EXCL 3
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct vperfctr *vperfctr_open(void);
|
|
Packit |
577717 |
int vperfctr_info(const struct vperfctr*, struct perfctr_info*);
|
|
Packit |
577717 |
struct perfctr_cpus_info *vperfctr_cpus_info(const struct vperfctr*);
|
|
Packit |
577717 |
unsigned long long vperfctr_read_tsc(const struct vperfctr*);
|
|
Packit |
577717 |
unsigned long long vperfctr_read_pmc(const struct vperfctr*, unsigned);
|
|
Packit |
577717 |
int vperfctr_read_ctrs(const struct vperfctr*, struct perfctr_sum_ctrs*);
|
|
Packit |
577717 |
int vperfctr_read_state(const struct vperfctr*, struct perfctr_sum_ctrs*,
|
|
Packit |
577717 |
struct vperfctr_control*);
|
|
Packit |
577717 |
int vperfctr_control(const struct vperfctr*, struct vperfctr_control*);
|
|
Packit |
577717 |
int vperfctr_stop(const struct vperfctr*);
|
|
Packit |
577717 |
int vperfctr_is_running(const struct vperfctr*);
|
|
Packit |
577717 |
int vperfctr_iresume(const struct vperfctr*);
|
|
Packit |
577717 |
int vperfctr_unlink(const struct vperfctr*);
|
|
Packit |
577717 |
void vperfctr_close(struct vperfctr*);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Operations on other processes' virtual-mode perfctrs.
|
|
Packit |
577717 |
* (Preliminary, subject to change.)
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct rvperfctr; /* opaque */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct rvperfctr *rvperfctr_open(int pid);
|
|
Packit |
577717 |
int rvperfctr_pid(const struct rvperfctr*);
|
|
Packit |
577717 |
int rvperfctr_info(const struct rvperfctr*, struct perfctr_info*);
|
|
Packit |
577717 |
int rvperfctr_read_ctrs(const struct rvperfctr*, struct perfctr_sum_ctrs*);
|
|
Packit |
577717 |
int rvperfctr_read_state(const struct rvperfctr*, struct perfctr_sum_ctrs*,
|
|
Packit |
577717 |
struct vperfctr_control*);
|
|
Packit |
577717 |
int rvperfctr_control(const struct rvperfctr*, struct vperfctr_control*);
|
|
Packit |
577717 |
int rvperfctr_stop(const struct rvperfctr*);
|
|
Packit |
577717 |
int rvperfctr_iresume(const struct rvperfctr*);
|
|
Packit |
577717 |
int rvperfctr_unlink(const struct rvperfctr*);
|
|
Packit |
577717 |
void rvperfctr_close(struct rvperfctr*);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Operations on global-mode perfctrs.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct gperfctr; /* opaque */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct gperfctr *gperfctr_open(void);
|
|
Packit |
577717 |
void gperfctr_close(struct gperfctr*);
|
|
Packit |
577717 |
int gperfctr_control(const struct gperfctr*, struct gperfctr_cpu_control*);
|
|
Packit |
577717 |
int gperfctr_read(const struct gperfctr*, struct gperfctr_cpu_state*);
|
|
Packit |
577717 |
int gperfctr_stop(const struct gperfctr*);
|
|
Packit |
577717 |
int gperfctr_start(const struct gperfctr*, unsigned int interval_usec);
|
|
Packit |
577717 |
int gperfctr_info(const struct gperfctr*, struct perfctr_info*);
|
|
Packit |
577717 |
struct perfctr_cpus_info *gperfctr_cpus_info(const struct gperfctr*);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Descriptions of the events available for different processor types.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
enum perfctr_unit_mask_type {
|
|
Packit |
577717 |
perfctr_um_type_fixed, /* one fixed (required) value */
|
|
Packit |
577717 |
perfctr_um_type_exclusive, /* exactly one of N values */
|
|
Packit |
577717 |
perfctr_um_type_bitmask, /* bitwise 'or' of N power-of-2 values */
|
|
Packit |
577717 |
};
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct perfctr_unit_mask_value {
|
|
Packit |
577717 |
unsigned int value;
|
|
Packit |
577717 |
const char *description; /* [NAME:]text */
|
|
Packit |
577717 |
};
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct perfctr_unit_mask {
|
|
Packit |
577717 |
unsigned short default_value;
|
|
Packit |
577717 |
enum perfctr_unit_mask_type type:8;
|
|
Packit |
577717 |
unsigned char nvalues;
|
|
Packit |
577717 |
struct perfctr_unit_mask_value values[1/*nvalues*/];
|
|
Packit |
577717 |
};
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct perfctr_event {
|
|
Packit |
577717 |
unsigned short evntsel;
|
|
Packit |
577717 |
unsigned short counters_set; /* P4 force this to be CPU-specific */
|
|
Packit |
577717 |
const struct perfctr_unit_mask *unit_mask;
|
|
Packit |
577717 |
const char *name;
|
|
Packit |
577717 |
const char *description;
|
|
Packit |
577717 |
};
|
|
Packit |
577717 |
|
|
Packit |
577717 |
struct perfctr_event_set {
|
|
Packit |
577717 |
unsigned int cpu_type;
|
|
Packit |
577717 |
const char *event_prefix;
|
|
Packit |
577717 |
const struct perfctr_event_set *include;
|
|
Packit |
577717 |
unsigned int nevents;
|
|
Packit |
577717 |
const struct perfctr_event *events;
|
|
Packit |
577717 |
};
|
|
Packit |
577717 |
|
|
Packit |
577717 |
const struct perfctr_event_set *perfctr_cpu_event_set(unsigned int cpu_type);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/*
|
|
Packit |
577717 |
* Miscellaneous operations.
|
|
Packit |
577717 |
*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* this checks the ABI between library and kernel -- it can also
|
|
Packit |
577717 |
be used by applications operating on raw file descriptors */
|
|
Packit |
577717 |
int _perfctr_abi_check_fd(int fd, unsigned int user_abi_version);
|
|
Packit |
577717 |
static __inline__ int perfctr_abi_check_fd(int fd)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
return _perfctr_abi_check_fd(fd, PERFCTR_ABI_VERSION);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int perfctr_info(int fd, struct perfctr_info *info);
|
|
Packit |
577717 |
int perfctr_get_info(struct perfctr_info *info);
|
|
Packit |
577717 |
struct perfctr_cpus_info *perfctr_cpus_info(int fd);
|
|
Packit |
577717 |
unsigned int perfctr_info_nrctrs(const struct perfctr_info*);
|
|
Packit |
577717 |
const char *perfctr_info_cpu_name(const struct perfctr_info*);
|
|
Packit |
577717 |
void perfctr_info_print(const struct perfctr_info*);
|
|
Packit |
577717 |
void perfctr_cpus_info_print(const struct perfctr_cpus_info*);
|
|
Packit |
577717 |
void perfctr_cpu_control_print(const struct perfctr_cpu_control*);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#endif /* __LIB_PERFCTR_H */
|