gem5  v22.1.0.0
Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
gem5::MSHR Class Reference

Miss Status and handling Register. More...

#include <mshr.hh>

Inheritance diagram for gem5::MSHR:
gem5::QueueEntry gem5::Printable gem5::Packet::SenderState gem5::Named

Classes

class  Target
 
class  TargetList
 

Public Types

typedef std::list< MSHR * > List
 A list of MSHRs. More...
 
typedef List::iterator Iterator
 MSHR list iterator. More...
 

Public Member Functions

bool needsWritable () const
 The pending* and post* flags are only valid if inService is true. More...
 
bool isCleaning () const
 
bool isPendingModified () const
 
bool hasPostInvalidate () const
 
bool hasPostDowngrade () const
 
bool sendPacket (BaseCache &cache) override
 Send this queue entry as a downstream packet, with the exact behaviour depending on the specific entry type. More...
 
bool allocOnFill () const
 
bool hasFromCache () const
 Determine if there are non-deferred requests from other caches. More...
 
void updateLockedRMWReadTarget (PacketPtr pkt)
 Replaces the matching packet in the Targets list with a dummy packet to ensure the MSHR remains allocated until the corresponding locked write arrives. More...
 
bool hasLockedRMWReadTarget ()
 Determine if there are any LockedRMWReads in the Targets list. More...
 
bool isWholeLineWrite () const
 Check if this MSHR contains only compatible writes, and if they span the entire cache line. More...
 
void allocate (Addr blk_addr, unsigned blk_size, PacketPtr pkt, Tick when_ready, Counter _order, bool alloc_on_fill)
 Allocate a miss to this MSHR. More...
 
void markInService (bool pending_modified_resp)
 
void clearDownstreamPending ()
 
void deallocate ()
 Mark this MSHR as free. More...
 
void allocateTarget (PacketPtr target, Tick when, Counter order, bool alloc_on_fill)
 Add a request to the list of targets. More...
 
bool handleSnoop (PacketPtr target, Counter order)
 
 MSHR (const std::string &name)
 A simple constructor. More...
 
int getNumTargets () const
 Returns the current number of allocated targets. More...
 
TargetList extractServiceableTargets (PacketPtr pkt)
 Extracts the subset of the targets that can be serviced given a received response. More...
 
bool hasTargets () const
 Returns true if there are targets left. More...
 
QueueEntry::TargetgetTarget () override
 Returns a reference to the first target. More...
 
void popTarget ()
 Pop first target. More...
 
bool promoteDeferredTargets ()
 
void promoteReadable ()
 Promotes deferred targets that do not require writable. More...
 
void promoteWritable ()
 Promotes deferred targets that do not require writable. More...
 
bool trySatisfyFunctional (PacketPtr pkt)
 
void delay (Tick delay_ticks)
 Adds a delay relative to the current tick to the current MSHR. More...
 
void print (std::ostream &os, int verbosity=0, const std::string &prefix="") const override
 Prints the contents of this MSHR for debugging. More...
 
std::string print () const
 A no-args wrapper of print(std::ostream...) meant to be invoked from DPRINTFs avoiding string overheads in fast mode. More...
 
bool matchBlockAddr (const Addr addr, const bool is_secure) const override
 Check if entry corresponds to the one being looked for. More...
 
bool matchBlockAddr (const PacketPtr pkt) const override
 Check if entry contains a packet that corresponds to the one being looked for. More...
 
bool conflictAddr (const QueueEntry *entry) const override
 Check if given entry's packets conflict with this' entries packets. More...
 
- Public Member Functions inherited from gem5::QueueEntry
 QueueEntry (const std::string &name)
 
bool isUncacheable () const
 
- Public Member Functions inherited from gem5::Packet::SenderState
 SenderState ()
 
virtual ~SenderState ()
 
- Public Member Functions inherited from gem5::Named
 Named (const std::string &name_)
 
virtual ~Named ()=default
 
virtual std::string name () const
 
- Public Member Functions inherited from gem5::Printable
 Printable ()
 
virtual ~Printable ()
 

Public Attributes

bool wasWholeLineWrite
 Track if we sent this as a whole line write or not. More...
 
bool isForward
 True if the entry is just a simple forward from an upper level. More...
 
- Public Attributes inherited from gem5::QueueEntry
bool inService
 True if the entry has been sent downstream. More...
 
Counter order
 Order number assigned to disambiguate writes and misses. More...
 
Addr blkAddr
 Block aligned address. More...
 
unsigned blkSize
 Block size of the cache. More...
 
bool isSecure
 True if the entry targets the secure memory space. More...
 
- Public Attributes inherited from gem5::Packet::SenderState
SenderStatepredecessor
 

Private Member Functions

void promoteIf (const std::function< bool(Target &)> &pred)
 Promotes deferred targets that satisfy a predicate. More...
 

Private Attributes

bool downstreamPending
 Flag set by downstream caches. More...
 
bool pendingModified
 Here we use one flag to track both if: More...
 
bool postInvalidate
 Did we snoop an invalidate while waiting for data? More...
 
bool postDowngrade
 Did we snoop a read while waiting for data? More...
 
Iterator readyIter
 Pointer to this MSHR on the ready list. More...
 
Iterator allocIter
 Pointer to this MSHR on the allocated list. More...
 
TargetList targets
 List of all requests that match the address. More...
 
TargetList deferredTargets
 

Friends

template<typename Entry >
class Queue
 Consider the queues friends to avoid making everything public. More...
 
class MSHRQueue
 

Additional Inherited Members

- Protected Attributes inherited from gem5::QueueEntry
Tick readyTime
 Tick when ready to issue. More...
 
bool _isUncacheable
 True if the entry is uncacheable. More...
 

Detailed Description

Miss Status and handling Register.

This class keeps all the information needed to handle a cache miss including a list of target requests.

See also
gem5 Memory System

Definition at line 74 of file mshr.hh.

Member Typedef Documentation

◆ Iterator

typedef List::iterator gem5::MSHR::Iterator

MSHR list iterator.

Definition at line 311 of file mshr.hh.

◆ List

A list of MSHRs.

Definition at line 309 of file mshr.hh.

Constructor & Destructor Documentation

◆ MSHR()

gem5::MSHR::MSHR ( const std::string &  name)

A simple constructor.

Definition at line 62 of file mshr.cc.

Member Function Documentation

◆ allocate()

void gem5::MSHR::allocate ( Addr  blk_addr,
unsigned  blk_size,
PacketPtr  pkt,
Tick  when_ready,
Counter  _order,
bool  alloc_on_fill 
)

Allocate a miss to this MSHR.

Parameters
blk_addrThe address of the block.
blk_sizeThe number of bytes to request.
pktThe original miss.
when_readyWhen should the MSHR be ready to act upon.
_orderThe logical order of this MSHR
alloc_on_fillShould the cache allocate a block on fill

Definition at line 303 of file mshr.cc.

References gem5::QueueEntry::_isUncacheable, gem5::MSHR::TargetList::add(), gem5::QueueEntry::blkAddr, gem5::QueueEntry::blkSize, gem5::Packet::cmd, deferredTargets, downstreamPending, gem5::MSHR::Target::FromCPU, gem5::MSHR::Target::FromPrefetcher, gem5::MemCmd::HardPFReq, gem5::MSHR::TargetList::init(), gem5::QueueEntry::inService, isForward, gem5::QueueEntry::isSecure, gem5::Packet::isSecure(), gem5::Packet::matchBlockAddr(), gem5::QueueEntry::order, gem5::QueueEntry::readyTime, gem5::Packet::req, targets, and wasWholeLineWrite.

Referenced by gem5::MSHRQueue::allocate().

◆ allocateTarget()

void gem5::MSHR::allocateTarget ( PacketPtr  target,
Tick  when,
Counter  order,
bool  alloc_on_fill 
)

◆ allocOnFill()

bool gem5::MSHR::allocOnFill ( ) const
inline

◆ clearDownstreamPending()

void gem5::MSHR::clearDownstreamPending ( )

◆ conflictAddr()

bool gem5::MSHR::conflictAddr ( const QueueEntry entry) const
overridevirtual

Check if given entry's packets conflict with this' entries packets.

Parameters
entryOther entry to compare against.
Returns
True if entry matches given information.

Implements gem5::QueueEntry.

Definition at line 778 of file mshr.cc.

References gem5::QueueEntry::blkAddr, hasTargets(), gem5::QueueEntry::isSecure, and gem5::QueueEntry::matchBlockAddr().

◆ deallocate()

void gem5::MSHR::deallocate ( )

◆ delay()

void gem5::MSHR::delay ( Tick  delay_ticks)
inline

Adds a delay relative to the current tick to the current MSHR.

Parameters
delay_ticksthe desired delay in ticks

Definition at line 516 of file mshr.hh.

References gem5::curTick(), and gem5::QueueEntry::readyTime.

Referenced by gem5::MSHRQueue::delay().

◆ extractServiceableTargets()

MSHR::TargetList gem5::MSHR::extractServiceableTargets ( PacketPtr  pkt)

Extracts the subset of the targets that can be serviced given a received response.

This function returns the targets list unless the response is a ReadRespWithInvalidate. The ReadRespWithInvalidate is only invalidating response that its invalidation was not expected when the request (a ReadSharedReq) was sent out. For ReadRespWithInvalidate we can safely service only the first FromCPU target and all FromSnoop targets (inform all snoopers that we no longer have the block).

Parameters
pktThe response from the downstream memory

Definition at line 547 of file mshr.cc.

References gem5::QueueEntry::blkAddr, gem5::QueueEntry::blkSize, gem5::Packet::cmd, gem5::MSHR::Target::FromCPU, gem5::MSHR::Target::FromPrefetcher, gem5::MSHR::Target::FromSnoop, gem5::MSHR::TargetList::init(), gem5::MemCmd::LockedRMWReadReq, gem5::MSHR::TargetList::populateFlags(), gem5::MemCmd::ReadRespWithInvalidate, and targets.

Referenced by gem5::Cache::serviceMSHRTargets(), and gem5::NoncoherentCache::serviceMSHRTargets().

◆ getNumTargets()

int gem5::MSHR::getNumTargets ( ) const
inline

Returns the current number of allocated targets.

Returns
The current number of allocated targets.

Definition at line 446 of file mshr.hh.

References deferredTargets, and targets.

Referenced by gem5::MSHRQueue::allocate(), gem5::BaseCache::handleTimingReqMiss(), gem5::Cache::recvTimingSnoopReq(), and gem5::NoncoherentCache::serviceMSHRTargets().

◆ getTarget()

QueueEntry::Target* gem5::MSHR::getTarget ( )
inlineoverridevirtual

Returns a reference to the first target.

Returns
A pointer to the first target.

Implements gem5::QueueEntry.

Definition at line 473 of file mshr.hh.

References hasTargets(), and targets.

Referenced by gem5::BaseCache::recvTimingResp(), gem5::BaseCache::sendMSHRQueuePacket(), gem5::Cache::sendMSHRQueuePacket(), gem5::Cache::serviceMSHRTargets(), and gem5::NoncoherentCache::serviceMSHRTargets().

◆ handleSnoop()

bool gem5::MSHR::handleSnoop ( PacketPtr  target,
Counter  order 
)

◆ hasFromCache()

bool gem5::MSHR::hasFromCache ( ) const
inline

Determine if there are non-deferred requests from other caches.

Returns
true if any of the targets is from another cache

Definition at line 349 of file mshr.hh.

References gem5::MSHR::TargetList::hasFromCache, and targets.

Referenced by print(), and gem5::MSHR::TargetList::updateFlags().

◆ hasLockedRMWReadTarget()

bool gem5::MSHR::hasLockedRMWReadTarget ( )

Determine if there are any LockedRMWReads in the Targets list.

Returns
true if Targets list contains a LockedRMWRead

Definition at line 793 of file mshr.cc.

References gem5::MemCmd::LockedRMWReadReq, and targets.

Referenced by gem5::BaseCache::recvTimingResp(), and gem5::Cache::serviceMSHRTargets().

◆ hasPostDowngrade()

bool gem5::MSHR::hasPostDowngrade ( ) const
inline

◆ hasPostInvalidate()

bool gem5::MSHR::hasPostInvalidate ( ) const
inline

◆ hasTargets()

bool gem5::MSHR::hasTargets ( ) const
inline

Returns true if there are targets left.

Returns
true if there are targets

Definition at line 467 of file mshr.hh.

References targets.

Referenced by conflictAddr(), gem5::MSHRQueue::forceDeallocateTarget(), getTarget(), and matchBlockAddr().

◆ isCleaning()

bool gem5::MSHR::isCleaning ( ) const
inline

Definition at line 321 of file mshr.hh.

References gem5::Packet::isClean(), and targets.

Referenced by gem5::BaseCache::handleEvictions().

◆ isPendingModified()

bool gem5::MSHR::isPendingModified ( ) const
inline

◆ isWholeLineWrite()

bool gem5::MSHR::isWholeLineWrite ( ) const
inline

Check if this MSHR contains only compatible writes, and if they span the entire cache line.

This is used as part of the miss-packet creation. Note that new requests may arrive after a miss-packet has been created, and for the fill we therefore use the wasWholeLineWrite field.

Definition at line 406 of file mshr.hh.

References gem5::MSHR::TargetList::isWholeLineWrite(), and targets.

Referenced by markInService(), gem5::BaseCache::sendMSHRQueuePacket(), and gem5::MSHR::TargetList::updateWriteFlags().

◆ markInService()

void gem5::MSHR::markInService ( bool  pending_modified_resp)

◆ matchBlockAddr() [1/2]

bool gem5::MSHR::matchBlockAddr ( const Addr  addr,
const bool  is_secure 
) const
overridevirtual

Check if entry corresponds to the one being looked for.

Parameters
addrAddress to match against.
is_secureWhether the target should be in secure space or not.
Returns
True if entry matches given information.

Implements gem5::QueueEntry.

Definition at line 764 of file mshr.cc.

References gem5::X86ISA::addr, gem5::QueueEntry::blkAddr, hasTargets(), and gem5::QueueEntry::isSecure.

◆ matchBlockAddr() [2/2]

bool gem5::MSHR::matchBlockAddr ( const PacketPtr  pkt) const
overridevirtual

Check if entry contains a packet that corresponds to the one being looked for.

Parameters
pktThe packet to search for.
Returns
True if any of its targets' packets matches the given one.

Implements gem5::QueueEntry.

Definition at line 771 of file mshr.cc.

References gem5::QueueEntry::blkAddr, gem5::QueueEntry::blkSize, hasTargets(), gem5::QueueEntry::isSecure, and gem5::Packet::matchBlockAddr().

◆ needsWritable()

bool gem5::MSHR::needsWritable ( ) const
inline

The pending* and post* flags are only valid if inService is true.

Using the accessor functions lets us detect if these flags are accessed improperly. True if we need to get a writable copy of the block.

Definition at line 319 of file mshr.hh.

References gem5::MSHR::TargetList::needsWritable, and targets.

Referenced by gem5::BaseCache::handleEvictions(), print(), gem5::BaseCache::sendMSHRQueuePacket(), and gem5::MSHR::TargetList::updateFlags().

◆ popTarget()

void gem5::MSHR::popTarget ( )
inline

Pop first target.

Definition at line 482 of file mshr.hh.

References DPRINTF, gem5::MSHR::TargetList::print(), and targets.

Referenced by gem5::MSHRQueue::forceDeallocateTarget(), and gem5::Cache::serviceMSHRTargets().

◆ print() [1/2]

std::string gem5::MSHR::print ( ) const

A no-args wrapper of print(std::ostream...) meant to be invoked from DPRINTFs avoiding string overheads in fast mode.

Returns
string with mshr fields + [deferred]targets

Definition at line 756 of file mshr.cc.

Referenced by allocateTarget().

◆ print() [2/2]

void gem5::MSHR::print ( std::ostream &  os,
int  verbosity = 0,
const std::string &  prefix = "" 
) const
overridevirtual

◆ promoteDeferredTargets()

bool gem5::MSHR::promoteDeferredTargets ( )

◆ promoteIf()

void gem5::MSHR::promoteIf ( const std::function< bool(Target &)> &  pred)
private

Promotes deferred targets that satisfy a predicate.

Deferred targets are promoted to the target list if they satisfy a given condition. The operation stops at the first deferred target that doesn't satisfy the condition.

Parameters
predA condition on a Target

Definition at line 635 of file mshr.cc.

References gem5::MSHR::TargetList::clearDownstreamPending(), deferredTargets, downstreamPending, gem5::MSHR::TargetList::populateFlags(), and targets.

Referenced by promoteReadable(), and promoteWritable().

◆ promoteReadable()

void gem5::MSHR::promoteReadable ( )

Promotes deferred targets that do not require writable.

Move targets from the deferred targets list to the target list starting from the first deferred target until the first target that is a cache maintenance operation or needs a writable copy of the block

Definition at line 658 of file mshr.cc.

References deferredTargets, gem5::MSHR::Target::FromCPU, hasPostInvalidate(), promoteIf(), and gem5::VegaISA::t.

Referenced by gem5::BaseCache::recvTimingResp().

◆ promoteWritable()

void gem5::MSHR::promoteWritable ( )

Promotes deferred targets that do not require writable.

Requests in the deferred target list are moved to the target list up until the first target that is a cache maintenance operation or needs a writable copy of the block

Definition at line 679 of file mshr.cc.

References deferredTargets, gem5::MSHR::Target::FromCPU, hasPostDowngrade(), hasPostInvalidate(), gem5::MSHR::TargetList::needsWritable, promoteIf(), gem5::Packet::req, gem5::VegaISA::t, and targets.

Referenced by gem5::BaseCache::recvTimingResp().

◆ sendPacket()

bool gem5::MSHR::sendPacket ( BaseCache cache)
overridevirtual

Send this queue entry as a downstream packet, with the exact behaviour depending on the specific entry type.

Implements gem5::QueueEntry.

Definition at line 724 of file mshr.cc.

References gem5::BaseCache::sendMSHRQueuePacket().

◆ trySatisfyFunctional()

bool gem5::MSHR::trySatisfyFunctional ( PacketPtr  pkt)

◆ updateLockedRMWReadTarget()

void gem5::MSHR::updateLockedRMWReadTarget ( PacketPtr  pkt)

Replaces the matching packet in the Targets list with a dummy packet to ensure the MSHR remains allocated until the corresponding locked write arrives.

Parameters
pktThe LockedRMWRead packet to be updated

Definition at line 785 of file mshr.cc.

References gem5::MemCmd::LockedRMWReadReq, gem5::VegaISA::r, gem5::Packet::req, and targets.

Referenced by gem5::Cache::serviceMSHRTargets().

Friends And Related Function Documentation

◆ MSHRQueue

friend class MSHRQueue
friend

Definition at line 82 of file mshr.hh.

◆ Queue

template<typename Entry >
friend class Queue
friend

Consider the queues friends to avoid making everything public.

Definition at line 81 of file mshr.hh.

Member Data Documentation

◆ allocIter

Iterator gem5::MSHR::allocIter
private

Pointer to this MSHR on the allocated list.

See also
MissQueue, MSHRQueue::allocatedList

Definition at line 391 of file mshr.hh.

Referenced by gem5::MSHRQueue::allocate().

◆ deferredTargets

TargetList gem5::MSHR::deferredTargets
private

◆ downstreamPending

bool gem5::MSHR::downstreamPending
private

Flag set by downstream caches.

Definition at line 87 of file mshr.hh.

Referenced by gem5::MSHR::TargetList::add(), allocate(), clearDownstreamPending(), handleSnoop(), markInService(), print(), and promoteIf().

◆ isForward

bool gem5::MSHR::isForward

True if the entry is just a simple forward from an upper level.

Definition at line 127 of file mshr.hh.

Referenced by allocate(), allocateTarget(), print(), gem5::BaseCache::recvTimingResp(), gem5::BaseCache::sendMSHRQueuePacket(), and gem5::Cache::serviceMSHRTargets().

◆ pendingModified

bool gem5::MSHR::pendingModified
private

Here we use one flag to track both if:

  1. We are going to become owner or not, i.e., we will get the block in an ownership state (Owned or Modified) with BlkDirty set. This determines whether or not we are going to become the responder and ordering point for future requests that we snoop.
  2. We know that we are going to get a writable block, i.e. we will get the block in writable state (Exclusive or Modified state) with BlkWritable set. That determines whether additional targets with needsWritable set will be able to be satisfied, or if not should be put on the deferred list to possibly wait for another request that does give us writable access.

Condition 2 is actually just a shortcut that saves us from possibly building a deferred target list and calling promoteWritable() every time we get a writable block. Condition 1, tracking ownership, is what is important. However, we never receive ownership without marking the block dirty, and consequently use pendingModified to track both ownership and writability rather than having separate pendingDirty and pendingWritable flags.

Definition at line 113 of file mshr.hh.

Referenced by isPendingModified(), and markInService().

◆ postDowngrade

bool gem5::MSHR::postDowngrade
private

Did we snoop a read while waiting for data?

Definition at line 119 of file mshr.hh.

Referenced by handleSnoop(), hasPostDowngrade(), markInService(), and print().

◆ postInvalidate

bool gem5::MSHR::postInvalidate
private

Did we snoop an invalidate while waiting for data?

Definition at line 116 of file mshr.hh.

Referenced by handleSnoop(), hasPostInvalidate(), markInService(), and print().

◆ readyIter

Iterator gem5::MSHR::readyIter
private

◆ targets

TargetList gem5::MSHR::targets
private

◆ wasWholeLineWrite

bool gem5::MSHR::wasWholeLineWrite

Track if we sent this as a whole line write or not.

Definition at line 124 of file mshr.hh.

Referenced by allocate(), markInService(), gem5::BaseCache::recvTimingResp(), and gem5::Cache::serviceMSHRTargets().


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

Generated on Wed Dec 21 2022 10:23:26 for gem5 by doxygen 1.9.1