mem: Clarify cache MSHR handling on fill

This patch addresses the upgrading of deferred targets in the MSHR,
and makes it clearer by explicitly calling out what is happening
(deferred targets are promoted if we get exclusivity without asking
for it).
This commit is contained in:
Andreas Hansson 2015-10-29 08:48:20 -04:00
parent 58cb57bacc
commit d8b7a652e1
3 changed files with 14 additions and 11 deletions

View file

@ -1190,7 +1190,6 @@ Cache::recvTimingResp(PacketPtr pkt)
// Initial target is used just for stats // Initial target is used just for stats
MSHR::Target *initial_tgt = mshr->getTarget(); MSHR::Target *initial_tgt = mshr->getTarget();
CacheBlk *blk = tags->findBlock(pkt->getAddr(), pkt->isSecure());
int stats_cmd_idx = initial_tgt->pkt->cmdToIndex(); int stats_cmd_idx = initial_tgt->pkt->cmdToIndex();
Tick miss_latency = curTick() - initial_tgt->recvTime; Tick miss_latency = curTick() - initial_tgt->recvTime;
PacketList writebacks; PacketList writebacks;
@ -1212,16 +1211,20 @@ Cache::recvTimingResp(PacketPtr pkt)
miss_latency; miss_latency;
} }
// upgrade deferred targets if we got exclusive
if (!pkt->sharedAsserted()) {
mshr->promoteExclusive();
}
bool is_fill = !mshr->isForward && bool is_fill = !mshr->isForward &&
(pkt->isRead() || pkt->cmd == MemCmd::UpgradeResp); (pkt->isRead() || pkt->cmd == MemCmd::UpgradeResp);
CacheBlk *blk = tags->findBlock(pkt->getAddr(), pkt->isSecure());
if (is_fill && !is_error) { if (is_fill && !is_error) {
DPRINTF(Cache, "Block for addr %#llx being updated in Cache\n", DPRINTF(Cache, "Block for addr %#llx being updated in Cache\n",
pkt->getAddr()); pkt->getAddr());
// give mshr a chance to do some dirty work
mshr->handleFill(pkt, blk);
blk = handleFill(pkt, blk, writebacks); blk = handleFill(pkt, blk, writebacks);
assert(blk != NULL); assert(blk != NULL);
} }
@ -1262,9 +1265,10 @@ Cache::recvTimingResp(PacketPtr pkt)
// from above. // from above.
if (tgt_pkt->cmd == MemCmd::WriteLineReq) { if (tgt_pkt->cmd == MemCmd::WriteLineReq) {
assert(!is_error); assert(!is_error);
// we got the block in exclusive state, so promote any
// deferred targets if possible
mshr->promoteExclusive();
// NB: we use the original packet here and not the response! // NB: we use the original packet here and not the response!
mshr->handleFill(tgt_pkt, blk);
blk = handleFill(tgt_pkt, blk, writebacks); blk = handleFill(tgt_pkt, blk, writebacks);
assert(blk != NULL); assert(blk != NULL);

View file

@ -430,11 +430,10 @@ MSHR::promoteDeferredTargets()
void void
MSHR::handleFill(PacketPtr pkt, CacheBlk *blk) MSHR::promoteExclusive()
{ {
if (!pkt->sharedAsserted() if (deferredTargets.needsExclusive &&
&& !(hasPostInvalidate() || hasPostDowngrade()) !(hasPostInvalidate() || hasPostDowngrade())) {
&& deferredTargets.needsExclusive) {
// We got an exclusive response, but we have deferred targets // We got an exclusive response, but we have deferred targets
// which are waiting to request an exclusive copy (not because // which are waiting to request an exclusive copy (not because
// of a pending invalidate). This can happen if the original // of a pending invalidate). This can happen if the original

View file

@ -282,7 +282,7 @@ class MSHR : public Packet::SenderState, public Printable
bool promoteDeferredTargets(); bool promoteDeferredTargets();
void handleFill(PacketPtr pkt, CacheBlk *blk); void promoteExclusive();
bool checkFunctional(PacketPtr pkt); bool checkFunctional(PacketPtr pkt);