gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
PerfKvmTimer Class Reference

PerfEvent based timer using the host's CPU cycle counter. More...

#include <timer.hh>

Inheritance diagram for PerfKvmTimer:
BaseKvmTimer

Public Member Functions

 PerfKvmTimer (PerfKvmCounter &ctr, int signo, float hostFactor, Tick hostFreq)
 Create a timer that uses an existing hardware cycle counter. More...
 
 ~PerfKvmTimer ()
 
void arm (Tick ticks)
 Arm the timer so that it fires after a certain number of ticks. More...
 
void disarm ()
 Disarm the timer. More...
 
- Public Member Functions inherited from BaseKvmTimer
 BaseKvmTimer (int signo, float hostFactor, Tick hostFreq)
 Setup basic timer functionality shared by all timer implementations. More...
 
virtual ~BaseKvmTimer ()
 
Tick resolution ()
 Determine the resolution of the timer in ticks. More...
 
Tick ticksFromHostCycles (uint64_t cycles)
 Convert cycles executed on the host into Ticks executed in the simulator. More...
 
Tick ticksFromHostNs (uint64_t ns)
 Convert nanoseconds executed on the host into Ticks executed in the simulator. More...
 

Protected Member Functions

Tick calcResolution ()
 Calculate the timer resolution, used by resolution() which caches the result. More...
 
- Protected Member Functions inherited from BaseKvmTimer
uint64_t hostNs (Tick ticks)
 Convert a time in simulator ticks to host nanoseconds. More...
 
uint64_t hostCycles (Tick ticks)
 Convert a time in simulator ticks to host cycles. More...
 

Private Attributes

PerfKvmCounterhwOverflow
 

Additional Inherited Members

- Protected Attributes inherited from BaseKvmTimer
int signo
 Signal to deliver when the timer times out. More...
 

Detailed Description

PerfEvent based timer using the host's CPU cycle counter.

Warning
There is a known problem in some versions of the PerfEvent API that prevents the counter overflow period from being updated reliably, which might break this timer. See PerfKvmCounter::period() for details.

Definition at line 215 of file timer.hh.

Constructor & Destructor Documentation

PerfKvmTimer::PerfKvmTimer ( PerfKvmCounter ctr,
int  signo,
float  hostFactor,
Tick  hostFreq 
)

Create a timer that uses an existing hardware cycle counter.

Note
The performance counter must be configured for overflow sampling, which in practice means that it must have a non-zero sample period. The initial sample period is ignored since period will be updated when arm() is called.
Parameters
ctrAttached performance counter configured for overflow reporting.
signoSignal to deliver
hostFactorPerformance scaling factor
hostFreqClock frequency of the host

Definition at line 161 of file timer.cc.

References PerfKvmCounter::enableSignals(), and hwOverflow.

PerfKvmTimer::~PerfKvmTimer ( )

Definition at line 169 of file timer.cc.

Member Function Documentation

void PerfKvmTimer::arm ( Tick  ticks)
virtual

Arm the timer so that it fires after a certain number of ticks.

Note
A timer implementation is free to convert between simulation ticks and virtualized time using any method it chooses. The accuracy of the timer therefore depends on what it measures, an accurate timer implementation should measure the number of cycles or instructions executed in the guest. If such counters are unavailable, it may fallback to wall clock time.
Parameters
ticksNumber of ticks until the timer fires

Implements BaseKvmTimer.

Definition at line 174 of file timer.cc.

References BaseKvmTimer::hostCycles(), hwOverflow, PerfKvmCounter::period(), and PerfKvmCounter::refresh().

Tick PerfKvmTimer::calcResolution ( )
protectedvirtual

Calculate the timer resolution, used by resolution() which caches the result.

Returns
Minimum number of ticks the timer can resolve

Implements BaseKvmTimer.

Definition at line 187 of file timer.cc.

References MIN_HOST_CYCLES, and BaseKvmTimer::ticksFromHostCycles().

void PerfKvmTimer::disarm ( )
virtual

Disarm the timer.

When this method has returned, the timer may no longer deliver signals upon timeout.

Implements BaseKvmTimer.

Definition at line 181 of file timer.cc.

References hwOverflow, and PerfKvmCounter::stop().

Member Data Documentation

PerfKvmCounter& PerfKvmTimer::hwOverflow
private

Definition at line 244 of file timer.hh.

Referenced by arm(), disarm(), and PerfKvmTimer().


The documentation for this class was generated from the following files:

Generated on Fri Jun 9 2017 13:04:16 for gem5 by doxygen 1.8.6