gem5
|
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. More... | |
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. More... | |
PerfKvmCounter () | |
Create a new counter, but don't attach it. More... | |
~PerfKvmCounter () | |
void | attach (PerfKvmCounterConfig &config, pid_t tid) |
Attach a counter. More... | |
void | attach (PerfKvmCounterConfig &config, pid_t tid, const PerfKvmCounter &parent) |
Attach a counter and make it a member of an existing counter group. More... | |
void | detach () |
Detach a counter from PerfEvent. More... | |
bool | attached () const |
Check if a counter is attached. More... | |
void | start () |
Start counting. More... | |
void | stop () |
Stop counting. More... | |
void | period (uint64_t period) |
Update the period of an overflow counter. More... | |
void | refresh (int refresh) |
Enable a counter for a fixed number of events. More... | |
uint64_t | read () const |
Read the current value of a counter. More... | |
void | enableSignals (pid_t tid, int signal) |
Enable signal delivery to a thread on counter overflow. More... | |
void | enableSignals (int signal) |
Enable signal delivery on counter overflow. More... | |
Private Member Functions | |
PerfKvmCounter (const PerfKvmCounter &that) | |
PerfKvmCounter & | operator= (const PerfKvmCounter &that) |
void | attach (PerfKvmCounterConfig &config, pid_t tid, int group_fd) |
pid_t | gettid () |
Get the TID of the current thread. More... | |
void | mmapPerf (int pages) |
MMAP the PerfEvent file descriptor. More... | |
void | read (void *buf, size_t size) const |
Perform a read from the counter file descriptor. More... | |
int | fcntl (int cmd, long p1) |
PerfEvent fnctl interface. More... | |
int | fcntl (int cmd, void *p1) |
int | ioctl (int request, long p1) |
PerfEvent ioctl interface. More... | |
int | ioctl (int request, void *p1) |
int | ioctl (int request) |
Private Attributes | |
int | fd |
PerfEvent file descriptor associated with counter. More... | |
struct perf_event_mmap_page * | ringBuffer |
Memory mapped PerfEvent sample ring buffer. More... | |
int | ringNumPages |
Total number of pages in ring buffer. More... | |
long | pageSize |
Cached host page size. More... | |
An instance of a performance counter.
Definition at line 170 of file perfevent.hh.
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 70 of file perfevent.cc.
References attach().
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 76 of file perfevent.cc.
References attach().
PerfKvmCounter::PerfKvmCounter | ( | ) |
Create a new counter, but don't attach it.
Definition at line 83 of file perfevent.cc.
PerfKvmCounter::~PerfKvmCounter | ( | ) |
Definition at line 88 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 206 of file perfevent.hh.
Referenced by attach(), PerfKvmCounter(), BaseKvmCPU::setupCounters(), and BaseKvmCPU::setupInstCounter().
|
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 221 of file perfevent.hh.
|
private |
Definition at line 161 of file perfevent.cc.
References attached(), PerfKvmCounterConfig::attr, fd, mmapPerf(), and panic.
|
inline |
Check if a counter is attached.
Definition at line 230 of file perfevent.hh.
References fd.
Referenced by attach(), detach(), fcntl(), ioctl(), mmapPerf(), read(), BaseKvmCPU::setupInstCounter(), and ~PerfKvmCounter().
void PerfKvmCounter::detach | ( | ) |
Detach a counter from PerfEvent.
Definition at line 95 of file perfevent.cc.
References attached(), fd, pageSize, ringBuffer, ringNumPages, and warn.
Referenced by BaseKvmCPU::notifyFork(), BaseKvmCPU::setupInstCounter(), and ~PerfKvmCounter().
void 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 146 of file perfevent.cc.
References fcntl(), and panic.
Referenced by PerfKvmTimer::PerfKvmTimer(), and BaseKvmCPU::setupInstCounter().
|
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 300 of file perfevent.hh.
References enableSignals(), and gettid().
Referenced by enableSignals().
|
private |
PerfEvent fnctl interface.
cmd | fcntl command |
p1 | Request parameter |
Definition at line 207 of file perfevent.cc.
References attached(), and fd.
Referenced by enableSignals().
|
inlineprivate |
|
private |
Get the TID of the current thread.
Definition at line 178 of file perfevent.cc.
Referenced by enableSignals().
|
private |
PerfEvent ioctl interface.
request | PerfEvent request |
p1 | Optional request parameter |
Definition at line 214 of file perfevent.cc.
References attached(), and fd.
|
inlineprivate |
|
inlineprivate |
Definition at line 357 of file perfevent.hh.
References ioctl(), and X86ISA::L.
Referenced by ioctl().
|
private |
MMAP the PerfEvent file descriptor.
pages | number of pages in circular sample buffer. Must be an even power of 2. |
Definition at line 184 of file perfevent.cc.
References attached(), fd, pageSize, panic, ringBuffer, and ringNumPages.
Referenced by attach().
|
private |
void PerfKvmCounter::period | ( | uint64_t | period | ) |
Update the period of an overflow counter.
period | Overflow period in events |
Definition at line 123 of file perfevent.cc.
References ioctl(), and panic.
Referenced by PerfKvmTimer::arm().
uint64_t PerfKvmCounter::read | ( | ) | const |
Read the current value of a counter.
Definition at line 137 of file perfevent.cc.
Referenced by BaseKvmCPU::getHostCycles(), BaseKvmCPU::kvmRun(), and read().
|
private |
Perform a read from the counter file descriptor.
buf | Destination buffer |
size | Amount of data to read |
Definition at line 221 of file perfevent.cc.
References attached(), fd, panic, read(), and X86ISA::size().
void 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 130 of file perfevent.cc.
References ioctl(), and panic.
Referenced by PerfKvmTimer::arm().
void PerfKvmCounter::start | ( | ) |
Start counting.
Definition at line 109 of file perfevent.cc.
References ioctl(), and panic.
Referenced by BaseKvmCPU::kvmRun().
void PerfKvmCounter::stop | ( | ) |
Stop counting.
Definition at line 116 of file perfevent.cc.
References ioctl(), and panic.
Referenced by PerfKvmTimer::disarm(), and BaseKvmCPU::kvmRun().
|
private |
PerfEvent file descriptor associated with counter.
-1 if not attached to PerfEvent.
Definition at line 372 of file perfevent.hh.
Referenced by attach(), attached(), detach(), fcntl(), ioctl(), mmapPerf(), and read().
|
private |
Cached host page size.
Definition at line 380 of file perfevent.hh.
Referenced by detach(), and mmapPerf().
|
private |
Memory mapped PerfEvent sample ring buffer.
Definition at line 375 of file perfevent.hh.
Referenced by detach(), and mmapPerf().
|
private |
Total number of pages in ring buffer.
Definition at line 377 of file perfevent.hh.
Referenced by detach(), and mmapPerf().