gem5 v24.0.0.0
|
An instance of a performance counter. More...
#include <perfevent.hh>
Public Member Functions | |
PerfKvmCounter (PerfKvmCounterConfig &config, pid_t tid) | |
Create and attach a new counter group. | |
PerfKvmCounter (PerfKvmCounterConfig &config, pid_t tid, const PerfKvmCounter &parent) | |
Create and attach a new counter and make it a member of an exist counter group. | |
PerfKvmCounter () | |
Create a new counter, but don't attach it. | |
~PerfKvmCounter () | |
void | attach (PerfKvmCounterConfig &config, pid_t tid) |
Attach a counter. | |
void | attach (PerfKvmCounterConfig &config, pid_t tid, const PerfKvmCounter &parent) |
Attach a counter and make it a member of an existing counter group. | |
void | detach () |
Detach a counter from PerfEvent. | |
bool | attached () const |
Check if a counter is attached. | |
void | start () |
Start counting. | |
void | stop () |
Stop counting. | |
void | period (uint64_t period) |
Update the period of an overflow counter. | |
void | refresh (int refresh) |
Enable a counter for a fixed number of events. | |
uint64_t | read () const |
Read the current value of a counter. | |
void | enableSignals (pid_t tid, int signal) |
Enable signal delivery to a thread on counter overflow. | |
void | enableSignals (int signal) |
Enable signal delivery on counter overflow. | |
Private Member Functions | |
PerfKvmCounter (const PerfKvmCounter &that) | |
PerfKvmCounter & | operator= (const PerfKvmCounter &that) |
void | attach (PerfKvmCounterConfig &config, pid_t tid, int group_fd) |
pid_t | sysGettid () |
Get the TID of the current thread. | |
void | mmapPerf (int pages) |
MMAP the PerfEvent file descriptor. | |
void | read (void *buf, size_t size) const |
Perform a read from the counter file descriptor. | |
int | fcntl (int cmd, long p1) |
PerfEvent fnctl interface. | |
int | fcntl (int cmd, void *p1) |
int | ioctl (int request, long p1) |
PerfEvent ioctl interface. | |
int | ioctl (int request, void *p1) |
int | ioctl (int request) |
Private Attributes | |
int | fd |
PerfEvent file descriptor associated with counter. | |
struct perf_event_mmap_page * | ringBuffer |
Memory mapped PerfEvent sample ring buffer. | |
int | ringNumPages |
Total number of pages in ring buffer. | |
long | pageSize |
Cached host page size. | |
An instance of a performance counter.
Definition at line 171 of file perfevent.hh.
gem5::PerfKvmCounter::PerfKvmCounter | ( | PerfKvmCounterConfig & | config, |
pid_t | tid ) |
Create and attach a new counter group.
config | Counter configuration |
tid | Thread to sample (0 indicates current thread) |
Definition at line 71 of file perfevent.cc.
References attach().
gem5::PerfKvmCounter::PerfKvmCounter | ( | PerfKvmCounterConfig & | config, |
pid_t | tid, | ||
const PerfKvmCounter & | parent ) |
Create and attach a new counter and make it a member of an exist counter group.
config | Counter configuration |
tid | Thread to sample (0 indicates current thread) |
parent | Group leader |
Definition at line 77 of file perfevent.cc.
References attach().
gem5::PerfKvmCounter::PerfKvmCounter | ( | ) |
Create a new counter, but don't attach it.
Definition at line 84 of file perfevent.cc.
gem5::PerfKvmCounter::~PerfKvmCounter | ( | ) |
Definition at line 89 of file perfevent.cc.
References attached(), and detach().
|
private |
|
inline |
Attach a counter.
config | Counter configuration |
tid | Thread to sample (0 indicates current thread) |
Definition at line 207 of file perfevent.hh.
References attach().
Referenced by attach(), attach(), PerfKvmCounter(), and PerfKvmCounter().
|
inline |
Attach a counter and make it a member of an existing counter group.
config | Counter configuration |
tid | Thread to sample (0 indicates current thread) |
parent | Group leader |
Definition at line 222 of file perfevent.hh.
|
private |
Definition at line 162 of file perfevent.cc.
References attached(), gem5::PerfKvmCounterConfig::attr, fd, mmapPerf(), and panic.
|
inline |
Check if a counter is attached.
Definition at line 231 of file perfevent.hh.
References fd.
Referenced by attach(), detach(), fcntl(), ioctl(), mmapPerf(), read(), and ~PerfKvmCounter().
void gem5::PerfKvmCounter::detach | ( | ) |
Detach a counter from PerfEvent.
Definition at line 96 of file perfevent.cc.
References attached(), fd, pageSize, ringBuffer, ringNumPages, and warn.
Referenced by ~PerfKvmCounter().
|
inline |
Enable signal delivery on counter overflow.
Identical to enableSignals(pid_t) when called with the current TID as its parameter.
signal | Signal to send upon overflow |
Definition at line 301 of file perfevent.hh.
References enableSignals(), and sysGettid().
Referenced by enableSignals().
void gem5::PerfKvmCounter::enableSignals | ( | pid_t | tid, |
int | signal ) |
Enable signal delivery to a thread on counter overflow.
tid | Thread to deliver signal to |
signal | Signal to send upon overflow |
Definition at line 147 of file perfevent.cc.
References fcntl(), and panic.
Referenced by gem5::PerfKvmTimer::PerfKvmTimer().
|
private |
PerfEvent fnctl interface.
cmd | fcntl command |
p1 | Request parameter |
Definition at line 227 of file perfevent.cc.
References attached(), and fd.
Referenced by enableSignals().
|
inlineprivate |
|
inlineprivate |
Definition at line 358 of file perfevent.hh.
References ioctl(), and gem5::X86ISA::L.
Referenced by ioctl().
|
private |
PerfEvent ioctl interface.
request | PerfEvent request |
p1 | Optional request parameter |
Definition at line 234 of file perfevent.cc.
References attached(), and fd.
|
inlineprivate |
|
private |
MMAP the PerfEvent file descriptor.
pages | number of pages in circular sample buffer. Must be an even power of 2. |
Definition at line 204 of file perfevent.cc.
References attached(), fd, pageSize, panic, ringBuffer, and ringNumPages.
Referenced by attach().
|
private |
void gem5::PerfKvmCounter::period | ( | uint64_t | period | ) |
Update the period of an overflow counter.
period | Overflow period in events |
Definition at line 124 of file perfevent.cc.
References ioctl(), panic, and period().
Referenced by gem5::PerfKvmTimer::arm(), and period().
uint64_t gem5::PerfKvmCounter::read | ( | ) | const |
Read the current value of a counter.
Definition at line 138 of file perfevent.cc.
References read().
|
private |
Perform a read from the counter file descriptor.
buf | Destination buffer |
size | Amount of data to read |
Definition at line 241 of file perfevent.cc.
References attached(), fd, panic, and read().
void gem5::PerfKvmCounter::refresh | ( | int | refresh | ) |
Enable a counter for a fixed number of events.
When this method is called, perf event enables the counter if it was disabled. It then leaves the counter enabled until it has overflowed a refresh times.
refresh | Number of overflows before disabling the counter. |
Definition at line 131 of file perfevent.cc.
References ioctl(), panic, and refresh().
Referenced by gem5::PerfKvmTimer::arm(), and refresh().
void gem5::PerfKvmCounter::start | ( | ) |
Start counting.
Definition at line 110 of file perfevent.cc.
void gem5::PerfKvmCounter::stop | ( | ) |
Stop counting.
Definition at line 117 of file perfevent.cc.
References ioctl(), and panic.
Referenced by gem5::PerfKvmTimer::disarm().
|
private |
Get the TID of the current thread.
Definition at line 198 of file perfevent.cc.
Referenced by enableSignals().
|
private |
PerfEvent file descriptor associated with counter.
-1 if not attached to PerfEvent.
Definition at line 373 of file perfevent.hh.
Referenced by attach(), attach(), attached(), detach(), fcntl(), ioctl(), mmapPerf(), and read().
|
private |
Cached host page size.
Definition at line 381 of file perfevent.hh.
Referenced by detach(), and mmapPerf().
|
private |
Memory mapped PerfEvent sample ring buffer.
Definition at line 376 of file perfevent.hh.
Referenced by detach(), and mmapPerf().
|
private |
Total number of pages in ring buffer.
Definition at line 378 of file perfevent.hh.
Referenced by detach(), and mmapPerf().