#include <syscall.h>#include <perfmon.h>long perfmonctl(int fd, int cmd, void *arg, int narg);
描述
perfmonctl system call provides an interface to PMU (performance monitoring unit). PMU consists of PMD (performance monitoring data) registers and PMC (performance monitoring control) registers, where are gathered the hardware statistic.
perfmonctl will apply a function cmd to input arguments arg. The number of arguments is defined by input variable narg. fd specifies the perfmon context to operate on.
The fd parameter is ignored. A new context is created as specified in ctxtand its file descriptor is returned in ctxt->ctx_fd.
The file descriptor, apart from passing it to perfmonctl, can be used to read event notifications (type pfm_msg_t) using the read(2) system call. Both select(2) and poll(2) can be used to wait for event notifications.
The context can be destroyed using the close(2) system call.