|
Packit |
577717 |
.TH LIBPFM 3 "August, 2006" "" "Linux Programmer's Manual"
|
|
Packit |
577717 |
.SH NAME
|
|
Packit |
577717 |
pfm_get_event_name, pfm_get_full_event_name, pfm_get_event_mask_name, pfm_get_event_code,
|
|
Packit |
577717 |
pfm_get_event_mask_code, pfm_get_event_counters, pfm_get_num_events, pfm_get_max_event_name_len,
|
|
Packit |
577717 |
pfm_get_event_description, pfm_get_event_mask_description \- get event information
|
|
Packit |
577717 |
.SH SYNOPSIS
|
|
Packit |
577717 |
.nf
|
|
Packit |
577717 |
.B #include <perfmon/pfmlib.h>
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
.BI "int pfm_get_event_name(unsigned int " e ", char *"name ", size_t " maxlen ");"
|
|
Packit |
577717 |
.BI "int pfm_get_full_event_name(pfmlib_event_t *" ev ", char *"name ", size_t " maxlen ");"
|
|
Packit |
577717 |
.BI "int pfm_get_event_mask_name(unsigned int " e ", unsigned int "mask ", char *"name ", size_t " maxlen ");"
|
|
Packit |
577717 |
.BI "int pfm_get_event_code(unsigned int " e ", int *"code ");"
|
|
Packit |
577717 |
.BI "int pfm_get_event_mask_code(unsigned int " e ", unsigned int "mask ", int *"code ");"
|
|
Packit |
577717 |
.BI "int pfm_get_event_code_counter(unsigned int " e ", unsigned int " cnt ", int *"code ");"
|
|
Packit |
577717 |
.BI "int pfm_get_event_counters(int " e ", pfmlib_regmask_t "counters ");"
|
|
Packit |
577717 |
.BI "int pfm_get_num_events(unsigned int *" count ");"
|
|
Packit |
577717 |
.BI "int pfm_get_max_event_name_len(size_t *" len ");"
|
|
Packit |
577717 |
.BI "int pfm_get_event_description(unsigned int " ev ", char **" str ");"
|
|
Packit |
577717 |
.BI "int pfm_get_event_mask_description(unsigned int " ev ", unsigned int "mask ", char **" str ");"
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
.SH DESCRIPTION
|
|
Packit |
577717 |
The \fBpfm_get_event_name()\fR function returns in \fBname\fR the event
|
|
Packit |
577717 |
name given its opaque descriptor in \fBe\fR. The \fBmaxlen\fR argument
|
|
Packit |
577717 |
indicates the maximum length of the buffer provided for \fBname\fR. Up
|
|
Packit |
577717 |
to \fBmaxlen\fR-1 characters are stored in the buffer.
|
|
Packit |
577717 |
The buffer size must be large enough to store the event name, otherwise
|
|
Packit |
577717 |
an error is returned. This behavior is required to avoid returning partial
|
|
Packit |
577717 |
names with no way for the caller to verify this is not the full name, except
|
|
Packit |
577717 |
by failing other calls. The buffer can be appropriately sized using the
|
|
Packit |
577717 |
\fBpfm_get_max_event_name_len()\fR function. The returned name is a
|
|
Packit |
577717 |
null terminated string with all upper-case characters and no spaces.
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
The \fBpfm_get_full_event_name()\fR function returns in \fBname\fR the event
|
|
Packit |
577717 |
name given the full event description in \fBev\fR. The description contains
|
|
Packit |
577717 |
the event code in \fBev->event\fR and optional unit masks descriptors in
|
|
Packit |
577717 |
\fBev->unit_masks\fR. The \fBmaxlen\fR argument indicates the maximum length
|
|
Packit |
577717 |
of the buffer provided for \fBname\fR. If more than \fBmaxlen\fR-1 characters
|
|
Packit |
577717 |
are needed to represent the event, an error is returned. Applications may use
|
|
Packit |
577717 |
the \fBpfm_get_max_event_name_len()\fR function to size the buffer correctly.
|
|
Packit |
577717 |
In case unit masks are provided, the final event name string is structured as:
|
|
Packit |
577717 |
event_name:unit_masks1[:unit_masks2]. Event names and unit masks names are
|
|
Packit |
577717 |
returned in all upper case.
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
The \fBpfm_get_event_code()\fR function returns the event code in \fBcode\fR
|
|
Packit |
577717 |
given its opaque descriptor \fBe\fR.
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
On some PMU models, the code associated with an event is different based
|
|
Packit |
577717 |
on the counter it is programmed into. The \fBpfm_get_event_code_counter()\fR
|
|
Packit |
577717 |
function is used to retrieve the event code in \fBcode\fR when the event \fBe\fR
|
|
Packit |
577717 |
is programmed into counter \fBcnt\fR. The counter index \fBcnt\fR must correspond
|
|
Packit |
577717 |
to of a counting PMD register.
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
Given an opaque event descriptor \fBe\fR, the \fBpfm_get_event_counters()\fR
|
|
Packit |
577717 |
function returns in \fBcounters\fR a bitmask of type \fBpfmlib_regmask_t\fR where
|
|
Packit |
577717 |
each bit set represents a PMU config register which can be used to program this
|
|
Packit |
577717 |
event. The bitmask must be accessed using accessor macros defined by the library.
|
|
Packit |
577717 |
.so
|
|
Packit |
577717 |
The \fBpfm_get_num_events()\fR function returns in \fBcount\fR the
|
|
Packit |
577717 |
total number of events available for the PMU model. On some PMU
|
|
Packit |
577717 |
models, however, not all events in the table may be useable due
|
|
Packit |
577717 |
to processor stepping changes. However, The library guarantees that
|
|
Packit |
577717 |
no more that \fBcount\fR events are available.
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
It is possible to list all existing events for the detected host PMU
|
|
Packit |
577717 |
using accessor functions as the full table of events is not accessible
|
|
Packit |
577717 |
to the applications. The index of the first event is always zero,
|
|
Packit |
577717 |
then using the \fBpfm_get_num_events()\fR function you get the total number of events.
|
|
Packit |
577717 |
On some PMU models, e.g., AMD64, not all events are necessarily supported by the host
|
|
Packit |
577717 |
PMU, therefore the count returned by this calls may not be the actual number of available
|
|
Packit |
577717 |
events. Event descriptors are contiguous therefore a simple loop will allow
|
|
Packit |
577717 |
complete scanning. The typical scan loop is constructed as
|
|
Packit |
577717 |
follows:
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
.nf
|
|
Packit |
577717 |
unsigned int i, count;
|
|
Packit |
577717 |
char name[256];
|
|
Packit |
577717 |
int ret;
|
|
Packit |
577717 |
pfm_get_num_events(&count);
|
|
Packit |
577717 |
for(i=0;i < count; i++)
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
ret = pfm_get_event_name(i, name, 256);
|
|
Packit |
577717 |
if (ret != PFMLIB_SUCCESS)
|
|
Packit |
577717 |
continue;
|
|
Packit |
577717 |
printf("%s\\n", name);
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
.fi
|
|
Packit |
577717 |
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
The \fBpfm_get_max_event_name_len()\fR function returns in \fBlen\fR
|
|
Packit |
577717 |
the maximum length in bytes for the name of the events or its unit masks, if any,
|
|
Packit |
577717 |
available on one PMU implementation. The value excludes the string termination
|
|
Packit |
577717 |
character ('\\0').
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
The \fBpfm_get_event_description()\fR function returns in \fBstr\fR the
|
|
Packit |
577717 |
description string associated with the event specified in \fBev\fR.
|
|
Packit |
577717 |
The description is returned into a buffer that is allocated to hold the entire
|
|
Packit |
577717 |
description text. It is the responsibility of the caller to free the buffer when
|
|
Packit |
577717 |
it becomes useless by calling the \fBfree(3)\fR function.
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
The \fBpfm_get_event_mask_code()\fR function must be used to retrieve the actual
|
|
Packit |
577717 |
unit mask value given a event descriptor in \fBe\fR and a unit mask descriptor
|
|
Packit |
577717 |
in \fBmask\fR. The value is returned in \fBcode\fR.
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
The \fBpfm_get_event_mask_name()\fR function must be used to retrieve the name
|
|
Packit |
577717 |
associated with a unit mask specified in \fBmask\fR for event \fBe\fR. The
|
|
Packit |
577717 |
name is returned in the buffer specified in \fBname\fR. The maximum size
|
|
Packit |
577717 |
of the buffer must be specified in \fBmaxlen\fR.
|
|
Packit |
577717 |
.sp
|
|
Packit |
577717 |
The \fBpfm_get_event_mask_description()\fR function returns in \fBstr\fR the
|
|
Packit |
577717 |
description string associated with the unit mask specified in \fBmask\fR for
|
|
Packit |
577717 |
the event specified in \fBev\fR. The description is returned into a buffer that
|
|
Packit |
577717 |
is allocated to hold the entire description text. It is the responsibility of
|
|
Packit |
577717 |
the caller to free the buffer when it becomes useless by calling the \fBfree(3)\fR
|
|
Packit |
577717 |
function.
|
|
Packit |
577717 |
|
|
Packit |
577717 |
.SH RETURN
|
|
Packit |
577717 |
All functions return whether or not the call was successful. A return value of
|
|
Packit |
577717 |
\fBPFMLIB_SUCCESS\fR indicates success, otherwise the value is the error code.
|
|
Packit |
577717 |
.SH ERRORS
|
|
Packit |
577717 |
.B PFMLIB_ERR_NOINIT
|
|
Packit |
577717 |
the library has not been initialized properly.
|
|
Packit |
577717 |
.TP
|
|
Packit |
577717 |
.B PFMLIB_ERR_FULL
|
|
Packit |
577717 |
the string buffer provided is too small
|
|
Packit |
577717 |
.TP
|
|
Packit |
577717 |
.B PFMLIB_ERR_INVAL
|
|
Packit |
577717 |
the event or unit mask descriptor, or the \fBcnt\fR argument is invalid, or a pointer argument is NULL.
|
|
Packit |
577717 |
.SH SEE ALSO
|
|
Packit |
577717 |
pfm_get_impl_counters(3), pfm_get_max_event_name_len(3), free(3)
|
|
Packit |
577717 |
.SH AUTHOR
|
|
Packit |
577717 |
Stephane Eranian <eranian@gmail.com>
|
|
Packit |
577717 |
.PP
|