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

This snoop filter keeps track of which connected port has a particular line of data. More...

#include <snoop_filter.hh>

Inheritance diagram for SnoopFilter:
SimObject EventManager Serializable Drainable

Classes

struct  SnoopItem
 Per cache line item tracking a bitmask of SlavePorts who have an outstanding request to this line (requested) or already share a cache line with this address (holder). More...
 

Public Types

typedef std::vector
< QueuedSlavePort * > 
SnoopList
 
- Public Types inherited from SimObject
typedef SimObjectParams Params
 

Public Member Functions

 SnoopFilter (const SnoopFilterParams *p)
 
void setSlavePorts (const SnoopList &slave_ports)
 Init a new snoop filter and tell it about all the slave ports of the enclosing bus. More...
 
std::pair< SnoopList, CycleslookupRequest (const Packet *cpkt, const SlavePort &slave_port)
 Lookup a request (from a slave port) in the snoop filter and return a list of other slave ports that need forwarding of the resulting snoops. More...
 
void finishRequest (bool will_retry, Addr addr, bool is_secure)
 For an un-successful request, revert the change to the snoop filter. More...
 
std::pair< SnoopList, CycleslookupSnoop (const Packet *cpkt)
 Handle an incoming snoop from below (the master port). More...
 
void updateSnoopResponse (const Packet *cpkt, const SlavePort &rsp_port, const SlavePort &req_port)
 Let the snoop filter see any snoop responses that turn into request responses and indicate cache to cache transfers. More...
 
void updateSnoopForward (const Packet *cpkt, const SlavePort &rsp_port, const MasterPort &req_port)
 Pass snoop responses that travel downward through the snoop filter and let them update the snoop filter state. More...
 
void updateResponse (const Packet *cpkt, const SlavePort &slave_port)
 Update the snoop filter with a response from below (outer / other cache, or memory) and update the tracking information in the snoop filter. More...
 
virtual void regStats ()
 Register statistics for this object. More...
 
- Public Member Functions inherited from SimObject
const Paramsparams () const
 
 SimObject (const Params *_params)
 
virtual ~SimObject ()
 
virtual const std::string name () const
 
virtual void init ()
 init() is called after all C++ SimObjects have been created and all ports are connected. More...
 
virtual void loadState (CheckpointIn &cp)
 loadState() is called on each SimObject when restoring from a checkpoint. More...
 
virtual void initState ()
 initState() is called on each SimObject when not restoring from a checkpoint. More...
 
virtual void resetStats ()
 Reset statistics associated with this object. More...
 
virtual void regProbePoints ()
 Register probe points for this object. More...
 
virtual void regProbeListeners ()
 Register probe listeners for this object. More...
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object. More...
 
virtual void startup ()
 startup() is the final initialization call before simulation. More...
 
DrainState drain () override
 Provide a default implementation of the drain interface for objects that don't need draining. More...
 
virtual void memWriteback ()
 Write back dirty buffers to memory using functional writes. More...
 
virtual void memInvalidate ()
 Invalidate the contents of memory buffers. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
- Public Member Functions inherited from EventManager
 EventManager (EventManager &em)
 
 EventManager (EventManager *em)
 
 EventManager (EventQueue *eq)
 
EventQueueeventQueue () const
 
void schedule (Event &event, Tick when)
 
void deschedule (Event &event)
 
void reschedule (Event &event, Tick when, bool always=false)
 
void schedule (Event *event, Tick when)
 
void deschedule (Event *event)
 
void reschedule (Event *event, Tick when, bool always=false)
 
void wakeupEventQueue (Tick when=(Tick)-1)
 
void setCurTick (Tick newVal)
 
- Public Member Functions inherited from Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section. More...
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object. More...
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 
- Public Member Functions inherited from Drainable
DrainState drainState () const
 Return the current drain state of an object. More...
 
virtual void notifyFork ()
 Notify a child process of a fork. More...
 

Protected Types

typedef uint64_t SnoopMask
 The underlying type for the bitmask we use for tracking. More...
 
typedef std::unordered_map
< Addr, SnoopItem
SnoopFilterCache
 HashMap of SnoopItems indexed by line address. More...
 

Protected Member Functions

std::pair< SnoopList, CyclessnoopAll (Cycles latency) const
 Simple factory methods for standard return values. More...
 
std::pair< SnoopList, CyclessnoopSelected (const SnoopList &slave_ports, Cycles latency) const
 
std::pair< SnoopList, CyclessnoopDown (Cycles latency) const
 
SnoopMask portToMask (const SlavePort &port) const
 Convert a single port to a corresponding, one-hot bitmask. More...
 
SnoopList maskToPortList (SnoopMask ports) const
 Converts a bitmask of ports into the corresponing list of ports. More...
 
- Protected Member Functions inherited from Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain. More...
 
void signalDrainDone () const
 Signal that an object is drained. More...
 

Private Types

enum  LineStatus { LineSecure = 0x01 }
 Use the lower bits of the address to keep track of the line status. More...
 

Private Member Functions

void eraseIfNullEntry (SnoopFilterCache::iterator &sf_it)
 Removes snoop filter items which have no requesters and no holders. More...
 

Private Attributes

SnoopFilterCache cachedLocations
 Simple hash set of cached addresses. More...
 
SnoopFilterCache::iterator reqLookupResult
 Iterator used to store the result from lookupRequest until we call finishRequest. More...
 
SnoopItem retryItem
 Variable to temporarily store value of snoopfilter entry incase finishRequest needs to undo changes made in lookupRequest (because of crossbar retry) More...
 
SnoopList slavePorts
 List of all attached snooping slave ports. More...
 
std::vector< PortIDlocalSlavePortIds
 Track the mapping from port ids to the local mask ids. More...
 
const unsigned linesize
 Cache line size. More...
 
const Cycles lookupLatency
 Latency for doing a lookup in the filter. More...
 
const unsigned maxEntryCount
 Max capacity in terms of cache blocks tracked, for sanity checking. More...
 
Stats::Scalar totRequests
 Statistics. More...
 
Stats::Scalar hitSingleRequests
 
Stats::Scalar hitMultiRequests
 
Stats::Scalar totSnoops
 
Stats::Scalar hitSingleSnoops
 
Stats::Scalar hitMultiSnoops
 

Additional Inherited Members

- Static Public Member Functions inherited from SimObject
static void serializeAll (CheckpointOut &cp)
 Serialize all SimObjects in the system. More...
 
static SimObjectfind (const char *name)
 Find the SimObject with the given name and return a pointer to it. More...
 
- Static Public Member Functions inherited from Serializable
static const std::string & currentSection ()
 Get the fully-qualified name of the active section. More...
 
static void serializeAll (const std::string &cpt_dir)
 
static void unserializeGlobals (CheckpointIn &cp)
 
- Static Public Attributes inherited from Serializable
static int ckptCount = 0
 
static int ckptMaxCount = 0
 
static int ckptPrevCount = -1
 
- Protected Attributes inherited from SimObject
const SimObjectParams * _params
 Cached copy of the object parameters. More...
 
- Protected Attributes inherited from EventManager
EventQueueeventq
 A pointer to this object's event queue. More...
 

Detailed Description

This snoop filter keeps track of which connected port has a particular line of data.

It can be queried (through lookup*) on memory requests from above (reads / writes / ...); and also from below (snoops). The snoop filter precisely knows about the location of lines "above" it through a map from cache line address to sharers/ports. The snoop filter ties into the flows of requests (when they succeed at the lower interface), regular responses from below and also responses from sideway's caches (in update*). This allows the snoop filter to model cache-line residency by snooping the messages.

The tracking happens in two fields to be able to distinguish between in-flight requests (in requested) and already pulled in lines (in holder). This distinction is used for producing tighter assertions and tracking request completion. For safety, (requested | holder) should be notified and the requesting MSHRs will take care of ordering.

Overall, some trickery is required because: (1) snoops are not followed by an ACK, but only evoke a response if they need to (hit dirty) (2) side-channel information is funnelled through direct modifications of pkt, instead of proper messages through the bus (3) there are no clean evict messages telling the snoop filter that a local, upper cache dropped a line, making the snoop filter pessimistic for now (4) ordering: there is no single point of order in the system. Instead, requesting MSHRs track order between local requests and remote snoops

Definition at line 87 of file snoop_filter.hh.

Member Typedef Documentation

typedef std::unordered_map<Addr, SnoopItem> SnoopFilter::SnoopFilterCache
protected

HashMap of SnoopItems indexed by line address.

Definition at line 221 of file snoop_filter.hh.

Definition at line 89 of file snoop_filter.hh.

typedef uint64_t SnoopFilter::SnoopMask
protected

The underlying type for the bitmask we use for tracking.

This limits the number of snooping ports supported per crossbar. For the moment it is an uint64_t to offer maximum scalability. However, it is possible to use e.g. a uint16_t or uint32_to slim down the footprint of the hash map (and ultimately improve the simulation performance).

Definition at line 207 of file snoop_filter.hh.

Member Enumeration Documentation

Use the lower bits of the address to keep track of the line status.

Enumerator
LineSecure 

block holds data from the secure memory space

Definition at line 288 of file snoop_filter.hh.

Constructor & Destructor Documentation

SnoopFilter::SnoopFilter ( const SnoopFilterParams *  p)
inline

Definition at line 91 of file snoop_filter.hh.

Member Function Documentation

void SnoopFilter::eraseIfNullEntry ( SnoopFilterCache::iterator &  sf_it)
private

Removes snoop filter items which have no requesters and no holders.

Definition at line 53 of file snoop_filter.cc.

References cachedLocations, DPRINTF, SnoopFilter::SnoopItem::holder, and SnoopFilter::SnoopItem::requested.

Referenced by finishRequest(), lookupSnoop(), and updateSnoopForward().

void SnoopFilter::finishRequest ( bool  will_retry,
Addr  addr,
bool  is_secure 
)

For an un-successful request, revert the change to the snoop filter.

Also take care of erasing any null entries. This method relies on the result from lookupRequest being stored in reqLookupResult.

Parameters
will_retryThis request will retry on this bus / snoop filter
addrPacket address, merely for sanity checking

Definition at line 153 of file snoop_filter.cc.

References cachedLocations, DPRINTF, eraseIfNullEntry(), SnoopFilter::SnoopItem::holder, LineSecure, linesize, reqLookupResult, SnoopFilter::SnoopItem::requested, and retryItem.

Referenced by CoherentXBar::recvAtomic(), and CoherentXBar::recvTimingReq().

std::pair< SnoopFilter::SnoopList, Cycles > SnoopFilter::lookupRequest ( const Packet cpkt,
const SlavePort slave_port 
)

Lookup a request (from a slave port) in the snoop filter and return a list of other slave ports that need forwarding of the resulting snoops.

Additionally, update the tracking structures with new request information. Note that the caller must also call finishRequest once it is known if the request needs to retry or not.

Parameters
cpktPointer to the request packet. Not changed.
slave_portSlave port where the request came from.
Returns
Pair of a vector of snoop target ports and lookup latency.

Definition at line 64 of file snoop_filter.cc.

References cachedLocations, Packet::cacheResponding(), DPRINTF, Packet::fromCache(), Packet::getBlockAddr(), hitMultiRequests, hitSingleRequests, SnoopFilter::SnoopItem::holder, Packet::isBlockCached(), Packet::isEviction(), isPow2(), Packet::isSecure(), SlavePort::isSnooping(), Request::isUncacheable(), LineSecure, linesize, lookupLatency, maskToPortList(), Port::name(), Packet::needsResponse(), panic_if(), portToMask(), Packet::print(), Packet::req, reqLookupResult, SnoopFilter::SnoopItem::requested, retryItem, snoopDown(), snoopSelected(), and totRequests.

Referenced by CoherentXBar::recvAtomic(), and CoherentXBar::recvTimingReq().

std::pair< SnoopFilter::SnoopList, Cycles > SnoopFilter::lookupSnoop ( const Packet cpkt)

Handle an incoming snoop from below (the master port).

These can upgrade the tracking logic and may also benefit from additional steering thanks to the snoop filter.

Parameters
cpktPointer to const Packet containing the snoop.
Returns
Pair with a vector of SlavePorts that need snooping and a lookup latency.

Definition at line 178 of file snoop_filter.cc.

References cachedLocations, DPRINTF, eraseIfNullEntry(), Packet::getBlockAddr(), hitMultiSnoops, hitSingleSnoops, SnoopFilter::SnoopItem::holder, Packet::isInvalidate(), isPow2(), Packet::isRequest(), Packet::isSecure(), Request::isUncacheable(), Packet::isWriteback(), LineSecure, linesize, lookupLatency, maskToPortList(), maxEntryCount, Packet::needsWritable(), panic_if(), Packet::print(), Packet::req, SnoopFilter::SnoopItem::requested, snoopDown(), snoopSelected(), and totSnoops.

Referenced by CoherentXBar::recvAtomicSnoop(), and CoherentXBar::recvTimingSnoopReq().

SnoopFilter::SnoopList SnoopFilter::maskToPortList ( SnoopMask  ports) const
inlineprotected

Converts a bitmask of ports into the corresponing list of ports.

Parameters
portsSnoopMask of the requested ports
Returns
SnoopList containing all the requested SlavePorts

Definition at line 313 of file snoop_filter.hh.

References MipsISA::p, portToMask(), and slavePorts.

Referenced by lookupRequest(), and lookupSnoop().

SnoopFilter::SnoopMask SnoopFilter::portToMask ( const SlavePort port) const
inlineprotected

Convert a single port to a corresponding, one-hot bitmask.

Parameters
portSlavePort that should be converted.
Returns
One-hot bitmask corresponding to the port.

Definition at line 304 of file snoop_filter.hh.

References Port::getId(), InvalidPortID, SlavePort::isSnooping(), and localSlavePortIds.

Referenced by lookupRequest(), maskToPortList(), updateResponse(), and updateSnoopResponse().

void SnoopFilter::regStats ( )
virtual
void SnoopFilter::setSlavePorts ( const SnoopList slave_ports)
inline

Init a new snoop filter and tell it about all the slave ports of the enclosing bus.

Parameters
slave_portsSlave ports that the bus is attached to.

Definition at line 104 of file snoop_filter.hh.

References fatal_if(), InvalidPortID, localSlavePortIds, MipsISA::p, and slavePorts.

Referenced by CoherentXBar::init().

std::pair<SnoopList, Cycles> SnoopFilter::snoopAll ( Cycles  latency) const
inlineprotected

Simple factory methods for standard return values.

Definition at line 226 of file snoop_filter.hh.

References slavePorts.

std::pair<SnoopList, Cycles> SnoopFilter::snoopDown ( Cycles  latency) const
inlineprotected

Definition at line 235 of file snoop_filter.hh.

Referenced by lookupRequest(), and lookupSnoop().

std::pair<SnoopList, Cycles> SnoopFilter::snoopSelected ( const SnoopList slave_ports,
Cycles  latency 
) const
inlineprotected

Definition at line 230 of file snoop_filter.hh.

Referenced by lookupRequest(), and lookupSnoop().

void SnoopFilter::updateResponse ( const Packet cpkt,
const SlavePort slave_port 
)

Update the snoop filter with a response from below (outer / other cache, or memory) and update the tracking information in the snoop filter.

Parameters
cpktPointer to const Packet holding the snoop response.
slave_portSlavePort that made the original request and is the target of this response.

Definition at line 331 of file snoop_filter.cc.

References cachedLocations, DPRINTF, Packet::getBlockAddr(), SnoopFilter::SnoopItem::holder, Packet::isResponse(), Packet::isSecure(), SlavePort::isSnooping(), Request::isUncacheable(), LineSecure, linesize, Port::name(), panic_if(), portToMask(), Packet::print(), Packet::req, and SnoopFilter::SnoopItem::requested.

Referenced by CoherentXBar::recvAtomic(), CoherentXBar::recvTimingReq(), and CoherentXBar::recvTimingResp().

void SnoopFilter::updateSnoopForward ( const Packet cpkt,
const SlavePort rsp_port,
const MasterPort req_port 
)

Pass snoop responses that travel downward through the snoop filter and let them update the snoop filter state.

No additional routing happens.

Parameters
cpktPointer to const Packet holding the snoop response.
rsp_portSlavePort that sends the response.
req_portMasterPort through which the response is forwarded.

Definition at line 293 of file snoop_filter.cc.

References cachedLocations, Packet::cacheResponding(), DPRINTF, eraseIfNullEntry(), Packet::getBlockAddr(), Packet::hasSharers(), SnoopFilter::SnoopItem::holder, Packet::isResponse(), Packet::isSecure(), LineSecure, linesize, Port::name(), Packet::print(), and SnoopFilter::SnoopItem::requested.

Referenced by CoherentXBar::forwardAtomic(), and CoherentXBar::recvTimingSnoopResp().

void SnoopFilter::updateSnoopResponse ( const Packet cpkt,
const SlavePort rsp_port,
const SlavePort req_port 
)

Let the snoop filter see any snoop responses that turn into request responses and indicate cache to cache transfers.

These will update the corresponding state in the filter.

Parameters
cpktPointer to const Packet holding the snoop response.
rsp_portSlavePort that sends the response.
req_portSlavePort that made the original request and is the destination of the snoop response.

Definition at line 237 of file snoop_filter.cc.

References cachedLocations, Packet::cacheResponding(), DPRINTF, Packet::getBlockAddr(), Packet::hasSharers(), SnoopFilter::SnoopItem::holder, Packet::isResponse(), Packet::isSecure(), SlavePort::isSnooping(), Request::isUncacheable(), Packet::isWriteback(), LineSecure, linesize, Port::name(), panic_if(), portToMask(), Packet::print(), Packet::req, and SnoopFilter::SnoopItem::requested.

Referenced by CoherentXBar::forwardAtomic(), and CoherentXBar::recvTimingSnoopResp().

Member Data Documentation

SnoopFilterCache SnoopFilter::cachedLocations
private

Simple hash set of cached addresses.

Definition at line 262 of file snoop_filter.hh.

Referenced by eraseIfNullEntry(), finishRequest(), lookupRequest(), lookupSnoop(), updateResponse(), updateSnoopForward(), and updateSnoopResponse().

Stats::Scalar SnoopFilter::hitMultiRequests
private

Definition at line 296 of file snoop_filter.hh.

Referenced by lookupRequest(), and regStats().

Stats::Scalar SnoopFilter::hitMultiSnoops
private

Definition at line 300 of file snoop_filter.hh.

Referenced by lookupSnoop(), and regStats().

Stats::Scalar SnoopFilter::hitSingleRequests
private

Definition at line 295 of file snoop_filter.hh.

Referenced by lookupRequest(), and regStats().

Stats::Scalar SnoopFilter::hitSingleSnoops
private

Definition at line 299 of file snoop_filter.hh.

Referenced by lookupSnoop(), and regStats().

const unsigned SnoopFilter::linesize
private
std::vector<PortID> SnoopFilter::localSlavePortIds
private

Track the mapping from port ids to the local mask ids.

Definition at line 277 of file snoop_filter.hh.

Referenced by portToMask(), and setSlavePorts().

const Cycles SnoopFilter::lookupLatency
private

Latency for doing a lookup in the filter.

Definition at line 281 of file snoop_filter.hh.

Referenced by lookupRequest(), and lookupSnoop().

const unsigned SnoopFilter::maxEntryCount
private

Max capacity in terms of cache blocks tracked, for sanity checking.

Definition at line 283 of file snoop_filter.hh.

Referenced by lookupSnoop().

SnoopFilterCache::iterator SnoopFilter::reqLookupResult
private

Iterator used to store the result from lookupRequest until we call finishRequest.

Definition at line 267 of file snoop_filter.hh.

Referenced by finishRequest(), and lookupRequest().

SnoopItem SnoopFilter::retryItem
private

Variable to temporarily store value of snoopfilter entry incase finishRequest needs to undo changes made in lookupRequest (because of crossbar retry)

Definition at line 273 of file snoop_filter.hh.

Referenced by finishRequest(), and lookupRequest().

SnoopList SnoopFilter::slavePorts
private

List of all attached snooping slave ports.

Definition at line 275 of file snoop_filter.hh.

Referenced by maskToPortList(), setSlavePorts(), and snoopAll().

Stats::Scalar SnoopFilter::totRequests
private

Statistics.

Definition at line 294 of file snoop_filter.hh.

Referenced by lookupRequest(), and regStats().

Stats::Scalar SnoopFilter::totSnoops
private

Definition at line 298 of file snoop_filter.hh.

Referenced by lookupSnoop(), and regStats().


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

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