gem5 v24.0.0.0
|
This snoop filter keeps track of which connected port has a particular line of data. More...
#include <snoop_filter.hh>
Classes | |
struct | ReqLookupResult |
A request lookup must be followed by a call to finishRequest to inform the operation's success. More... | |
struct | SnoopFilterStats |
Statistics. More... | |
struct | SnoopItem |
Per cache line item tracking a bitmask of ResponsePorts 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< QueuedResponsePort * > | SnoopList |
Public Types inherited from gem5::SimObject | |
typedef SimObjectParams | Params |
Public Member Functions | |
SnoopFilter (const SnoopFilterParams &p) | |
void | setCPUSidePorts (const SnoopList &_cpu_side_ports) |
Init a new snoop filter and tell it about all the cpu_sideports of the enclosing bus. | |
std::pair< SnoopList, Cycles > | lookupRequest (const Packet *cpkt, const ResponsePort &cpu_side_port) |
Lookup a request (from a CPU-side port) in the snoop filter and return a list of other CPU-side ports that need forwarding of the resulting snoops. | |
void | finishRequest (bool will_retry, Addr addr, bool is_secure) |
For an un-successful request, revert the change to the snoop filter. | |
std::pair< SnoopList, Cycles > | lookupSnoop (const Packet *cpkt) |
Handle an incoming snoop from below (the memory-side port). | |
void | updateSnoopResponse (const Packet *cpkt, const ResponsePort &rsp_port, const ResponsePort &req_port) |
Let the snoop filter see any snoop responses that turn into request responses and indicate cache to cache transfers. | |
void | updateSnoopForward (const Packet *cpkt, const ResponsePort &rsp_port, const RequestPort &req_port) |
Pass snoop responses that travel downward through the snoop filter and let them update the snoop filter state. | |
void | updateResponse (const Packet *cpkt, const ResponsePort &cpu_side_port) |
Update the snoop filter with a response from below (outer / other cache, or memory) and update the tracking information in the snoop filter. | |
virtual void | regStats () |
Callback to set stat parameters. | |
Public Member Functions inherited from gem5::SimObject | |
const Params & | params () const |
SimObject (const Params &p) | |
virtual | ~SimObject () |
virtual void | init () |
init() is called after all C++ SimObjects have been created and all ports are connected. | |
virtual void | loadState (CheckpointIn &cp) |
loadState() is called on each SimObject when restoring from a checkpoint. | |
virtual void | initState () |
initState() is called on each SimObject when not restoring from a checkpoint. | |
virtual void | regProbePoints () |
Register probe points for this object. | |
virtual void | regProbeListeners () |
Register probe listeners for this object. | |
ProbeManager * | getProbeManager () |
Get the probe manager for this object. | |
virtual Port & | getPort (const std::string &if_name, PortID idx=InvalidPortID) |
Get a port with a given name and index. | |
virtual void | startup () |
startup() is the final initialization call before simulation. | |
DrainState | drain () override |
Provide a default implementation of the drain interface for objects that don't need draining. | |
virtual void | memWriteback () |
Write back dirty buffers to memory using functional writes. | |
virtual void | memInvalidate () |
Invalidate the contents of memory buffers. | |
void | serialize (CheckpointOut &cp) const override |
Serialize an object. | |
void | unserialize (CheckpointIn &cp) override |
Unserialize an object. | |
Public Member Functions inherited from gem5::EventManager | |
EventQueue * | eventQueue () 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) |
This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers. | |
void | setCurTick (Tick newVal) |
EventManager (EventManager &em) | |
Event manger manages events in the event queue. | |
EventManager (EventManager *em) | |
EventManager (EventQueue *eq) | |
Public Member Functions inherited from gem5::Serializable | |
Serializable () | |
virtual | ~Serializable () |
void | serializeSection (CheckpointOut &cp, const char *name) const |
Serialize an object into a new section. | |
void | serializeSection (CheckpointOut &cp, const std::string &name) const |
void | unserializeSection (CheckpointIn &cp, const char *name) |
Unserialize an a child object. | |
void | unserializeSection (CheckpointIn &cp, const std::string &name) |
Public Member Functions inherited from gem5::Drainable | |
DrainState | drainState () const |
Return the current drain state of an object. | |
virtual void | notifyFork () |
Notify a child process of a fork. | |
Public Member Functions inherited from gem5::statistics::Group | |
Group (Group *parent, const char *name=nullptr) | |
Construct a new statistics group. | |
virtual | ~Group () |
virtual void | resetStats () |
Callback to reset stats. | |
virtual void | preDumpStats () |
Callback before stats are dumped. | |
void | addStat (statistics::Info *info) |
Register a stat with this group. | |
const std::map< std::string, Group * > & | getStatGroups () const |
Get all child groups associated with this object. | |
const std::vector< Info * > & | getStats () const |
Get all stats associated with this object. | |
void | addStatGroup (const char *name, Group *block) |
Add a stat block as a child of this block. | |
const Info * | resolveStat (std::string name) const |
Resolve a stat by its name within this group. | |
void | mergeStatGroup (Group *block) |
Merge the contents (stats & children) of a block to this block. | |
Group ()=delete | |
Group (const Group &)=delete | |
Group & | operator= (const Group &)=delete |
Public Member Functions inherited from gem5::Named | |
Named (const std::string &name_) | |
virtual | ~Named ()=default |
virtual std::string | name () const |
Static Public Attributes | |
static const int | SNOOP_MASK_SIZE = 256 |
Protected Types | |
typedef std::bitset< SNOOP_MASK_SIZE > | SnoopMask |
The underlying type for the bitmask we use for tracking. | |
typedef std::unordered_map< Addr, SnoopItem > | SnoopFilterCache |
HashMap of SnoopItems indexed by line address. | |
Protected Member Functions | |
std::pair< SnoopList, Cycles > | snoopAll (Cycles latency) const |
Simple factory methods for standard return values. | |
std::pair< SnoopList, Cycles > | snoopSelected (const SnoopList &_cpu_side_ports, Cycles latency) const |
std::pair< SnoopList, Cycles > | snoopDown (Cycles latency) const |
SnoopMask | portToMask (const ResponsePort &port) const |
Convert a single port to a corresponding, one-hot bitmask. | |
SnoopList | maskToPortList (SnoopMask ports) const |
Converts a bitmask of ports into the corresponing list of ports. | |
Protected Member Functions inherited from gem5::Drainable | |
Drainable () | |
virtual | ~Drainable () |
virtual void | drainResume () |
Resume execution after a successful drain. | |
void | signalDrainDone () const |
Signal that an object is drained. | |
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 requestors and no holders. | |
Private Attributes | |
SnoopFilterCache | cachedLocations |
Simple hash set of cached addresses. | |
struct gem5::SnoopFilter::ReqLookupResult | reqLookupResult |
SnoopList | cpuSidePorts |
List of all attached snooping CPU-side ports. | |
std::vector< PortID > | localResponsePortIds |
Track the mapping from port ids to the local mask ids. | |
const Addr | linesize |
Cache line size. | |
const Cycles | lookupLatency |
Latency for doing a lookup in the filter. | |
const unsigned | maxEntryCount |
Max capacity in terms of cache blocks tracked, for sanity checking. | |
gem5::SnoopFilter::SnoopFilterStats | stats |
Additional Inherited Members | |
Static Public Member Functions inherited from gem5::SimObject | |
static void | serializeAll (const std::string &cpt_dir) |
Create a checkpoint by serializing all SimObjects in the system. | |
static SimObject * | find (const char *name) |
Find the SimObject with the given name and return a pointer to it. | |
static void | setSimObjectResolver (SimObjectResolver *resolver) |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
static SimObjectResolver * | getSimObjectResolver () |
There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. | |
Static Public Member Functions inherited from gem5::Serializable | |
static const std::string & | currentSection () |
Gets the fully-qualified name of the active section. | |
static void | generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream) |
Generate a checkpoint file so that the serialization can be routed to it. | |
Protected Attributes inherited from gem5::SimObject | |
const SimObjectParams & | _params |
Cached copy of the object parameters. | |
Protected Attributes inherited from gem5::EventManager | |
EventQueue * | eventq |
A pointer to this object's event queue. | |
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 89 of file snoop_filter.hh.
|
protected |
HashMap of SnoopItems indexed by line address.
Definition at line 226 of file snoop_filter.hh.
Definition at line 96 of file snoop_filter.hh.
|
protected |
The underlying type for the bitmask we use for tracking.
This limits the number of snooping ports supported per crossbar.
Definition at line 211 of file snoop_filter.hh.
|
private |
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 314 of file snoop_filter.hh.
|
inline |
Definition at line 98 of file snoop_filter.hh.
|
private |
Removes snoop filter items which have no requestors and no holders.
Definition at line 56 of file snoop_filter.cc.
References cachedLocations, DPRINTF, gem5::SnoopFilter::SnoopItem::holder, and gem5::SnoopFilter::SnoopItem::requested.
Referenced by finishRequest(), lookupSnoop(), updateResponse(), and updateSnoopForward().
void gem5::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.
will_retry | This request will retry on this bus / snoop filter |
addr | Packet address, merely for sanity checking |
Definition at line 160 of file snoop_filter.cc.
References gem5::X86ISA::addr, cachedLocations, DPRINTF, eraseIfNullEntry(), gem5::SnoopFilter::SnoopItem::holder, gem5::SnoopFilter::ReqLookupResult::it, LineSecure, linesize, reqLookupResult, gem5::SnoopFilter::SnoopItem::requested, and gem5::SnoopFilter::ReqLookupResult::retryItem.
Referenced by gem5::CoherentXBar::recvAtomicBackdoor(), and gem5::CoherentXBar::recvTimingReq().
std::pair< SnoopFilter::SnoopList, Cycles > gem5::SnoopFilter::lookupRequest | ( | const Packet * | cpkt, |
const ResponsePort & | cpu_side_port ) |
Lookup a request (from a CPU-side port) in the snoop filter and return a list of other CPU-side 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.
cpkt | Pointer to the request packet. Not changed. |
cpu_side_port | Response port where the request came from. |
Definition at line 67 of file snoop_filter.cc.
References cachedLocations, gem5::Packet::cacheResponding(), DPRINTF, gem5::Packet::fromCache(), gem5::Packet::getBlockAddr(), gem5::SnoopFilter::SnoopFilterStats::hitMultiRequests, gem5::SnoopFilter::SnoopFilterStats::hitSingleRequests, gem5::SnoopFilter::SnoopItem::holder, gem5::Packet::isBlockCached(), gem5::Packet::isEviction(), gem5::Packet::isSecure(), gem5::ResponsePort::isSnooping(), gem5::SnoopFilter::ReqLookupResult::it, LineSecure, linesize, lookupLatency, maskToPortList(), gem5::Port::name(), gem5::Packet::needsResponse(), panic_if, portToMask(), gem5::Packet::print(), gem5::Packet::req, reqLookupResult, gem5::SnoopFilter::SnoopItem::requested, gem5::SnoopFilter::ReqLookupResult::retryItem, snoopDown(), snoopSelected(), stats, and gem5::SnoopFilter::SnoopFilterStats::totRequests.
Referenced by gem5::CoherentXBar::recvAtomicBackdoor(), and gem5::CoherentXBar::recvTimingReq().
std::pair< SnoopFilter::SnoopList, Cycles > gem5::SnoopFilter::lookupSnoop | ( | const Packet * | cpkt | ) |
Handle an incoming snoop from below (the memory-side port).
These can upgrade the tracking logic and may also benefit from additional steering thanks to the snoop filter.
cpkt | Pointer to const Packet containing the snoop. |
Definition at line 184 of file snoop_filter.cc.
References cachedLocations, DPRINTF, eraseIfNullEntry(), gem5::Packet::getBlockAddr(), gem5::SnoopFilter::SnoopFilterStats::hitMultiSnoops, gem5::SnoopFilter::SnoopFilterStats::hitSingleSnoops, gem5::SnoopFilter::SnoopItem::holder, gem5::Packet::isInvalidate(), gem5::Packet::isRequest(), gem5::Packet::isSecure(), gem5::Packet::isWriteback(), LineSecure, linesize, lookupLatency, maskToPortList(), maxEntryCount, gem5::Packet::needsWritable(), panic_if, gem5::Packet::print(), gem5::Packet::req, gem5::SnoopFilter::SnoopItem::requested, snoopDown(), snoopSelected(), stats, and gem5::SnoopFilter::SnoopFilterStats::totSnoops.
Referenced by gem5::CoherentXBar::recvAtomicSnoop(), and gem5::CoherentXBar::recvTimingSnoopReq().
|
inlineprotected |
Converts a bitmask of ports into the corresponing list of ports.
ports | SnoopMask of the requested ports |
Definition at line 345 of file snoop_filter.hh.
References cpuSidePorts, gem5::MipsISA::p, and portToMask().
Referenced by lookupRequest(), and lookupSnoop().
|
inlineprotected |
Convert a single port to a corresponding, one-hot bitmask.
port | ResponsePort that should be converted. |
Definition at line 336 of file snoop_filter.hh.
References gem5::Port::getId(), gem5::InvalidPortID, gem5::ResponsePort::isSnooping(), and localResponsePortIds.
Referenced by lookupRequest(), maskToPortList(), updateResponse(), and updateSnoopResponse().
|
virtual |
Callback to set stat parameters.
This callback is typically used for complex stats (e.g., distributions) that need parameters in addition to a name and a description. Stat names and descriptions should typically be set from the constructor usingo from the constructor using the ADD_STAT macro.
Reimplemented from gem5::statistics::Group.
Definition at line 412 of file snoop_filter.cc.
References gem5::statistics::Group::regStats().
|
inline |
Init a new snoop filter and tell it about all the cpu_sideports of the enclosing bus.
_cpu_side_ports | Response ports that the bus is attached to. |
Definition at line 112 of file snoop_filter.hh.
References cpuSidePorts, fatal_if, gem5::InvalidPortID, localResponsePortIds, gem5::MipsISA::p, and SNOOP_MASK_SIZE.
Referenced by gem5::CoherentXBar::init().
Simple factory methods for standard return values.
Definition at line 231 of file snoop_filter.hh.
References cpuSidePorts.
Definition at line 240 of file snoop_filter.hh.
Referenced by lookupRequest(), and lookupSnoop().
|
inlineprotected |
Definition at line 235 of file snoop_filter.hh.
Referenced by lookupRequest(), and lookupSnoop().
void gem5::SnoopFilter::updateResponse | ( | const Packet * | cpkt, |
const ResponsePort & | cpu_side_port ) |
Update the snoop filter with a response from below (outer / other cache, or memory) and update the tracking information in the snoop filter.
cpkt | Pointer to const Packet holding the snoop response. |
cpu_side_port | ResponsePort that made the original request and is the target of this response. |
Definition at line 338 of file snoop_filter.cc.
References cachedLocations, DPRINTF, eraseIfNullEntry(), gem5::Packet::getBlockAddr(), gem5::SnoopFilter::SnoopItem::holder, gem5::Packet::isInvalidate(), gem5::Packet::isResponse(), gem5::Packet::isSecure(), gem5::ResponsePort::isSnooping(), LineSecure, linesize, gem5::Port::name(), panic_if, portToMask(), gem5::Packet::print(), gem5::Packet::req, and gem5::SnoopFilter::SnoopItem::requested.
Referenced by gem5::CoherentXBar::recvAtomicBackdoor(), gem5::CoherentXBar::recvTimingReq(), and gem5::CoherentXBar::recvTimingResp().
void gem5::SnoopFilter::updateSnoopForward | ( | const Packet * | cpkt, |
const ResponsePort & | rsp_port, | ||
const RequestPort & | req_port ) |
Pass snoop responses that travel downward through the snoop filter and let them update the snoop filter state.
No additional routing happens.
cpkt | Pointer to const Packet holding the snoop response. |
rsp_port | ResponsePort that sends the response. |
req_port | RequestPort through which the response is forwarded. |
Definition at line 301 of file snoop_filter.cc.
References cachedLocations, gem5::Packet::cacheResponding(), DPRINTF, eraseIfNullEntry(), gem5::Packet::getBlockAddr(), gem5::Packet::hasSharers(), gem5::SnoopFilter::SnoopItem::holder, gem5::Packet::isResponse(), gem5::Packet::isSecure(), LineSecure, linesize, gem5::Port::name(), gem5::Packet::print(), and gem5::SnoopFilter::SnoopItem::requested.
Referenced by gem5::CoherentXBar::forwardAtomic(), and gem5::CoherentXBar::recvTimingSnoopResp().
void gem5::SnoopFilter::updateSnoopResponse | ( | const Packet * | cpkt, |
const ResponsePort & | rsp_port, | ||
const ResponsePort & | 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.
cpkt | Pointer to const Packet holding the snoop response. |
rsp_port | ResponsePort that sends the response. |
req_port | ResponsePort that made the original request and is the destination of the snoop response. |
Definition at line 244 of file snoop_filter.cc.
References cachedLocations, gem5::Packet::cacheResponding(), DPRINTF, gem5::Packet::getBlockAddr(), gem5::Packet::hasSharers(), gem5::SnoopFilter::SnoopItem::holder, gem5::Packet::isResponse(), gem5::Packet::isSecure(), gem5::ResponsePort::isSnooping(), gem5::Packet::isWriteback(), LineSecure, linesize, gem5::Port::name(), panic_if, portToMask(), gem5::Packet::print(), gem5::Packet::req, and gem5::SnoopFilter::SnoopItem::requested.
Referenced by gem5::CoherentXBar::forwardAtomic(), and gem5::CoherentXBar::recvTimingSnoopResp().
|
private |
Simple hash set of cached addresses.
Definition at line 267 of file snoop_filter.hh.
Referenced by eraseIfNullEntry(), finishRequest(), lookupRequest(), lookupSnoop(), updateResponse(), updateSnoopForward(), and updateSnoopResponse().
|
private |
List of all attached snooping CPU-side ports.
Definition at line 301 of file snoop_filter.hh.
Referenced by maskToPortList(), setCPUSidePorts(), and snoopAll().
|
private |
Cache line size.
Definition at line 305 of file snoop_filter.hh.
Referenced by finishRequest(), lookupRequest(), lookupSnoop(), updateResponse(), updateSnoopForward(), and updateSnoopResponse().
|
private |
Track the mapping from port ids to the local mask ids.
Definition at line 303 of file snoop_filter.hh.
Referenced by portToMask(), and setCPUSidePorts().
|
private |
Latency for doing a lookup in the filter.
Definition at line 307 of file snoop_filter.hh.
Referenced by lookupRequest(), and lookupSnoop().
|
private |
Max capacity in terms of cache blocks tracked, for sanity checking.
Definition at line 309 of file snoop_filter.hh.
Referenced by lookupSnoop().
|
private |
Referenced by finishRequest(), and lookupRequest().
|
static |
Definition at line 94 of file snoop_filter.hh.
Referenced by setCPUSidePorts().
|
private |
Referenced by lookupRequest(), and lookupSnoop().