From 3beeea0f40f367c25df30838e4e9cd109524974d Mon Sep 17 00:00:00 2001 From: Tom Rollet Date: Tue, 22 Jun 2021 10:37:53 +0200 Subject: [PATCH] mem-cache: Add MSHR debuging information Add debug statment in MSHR and MSHRQueue class to track the number of free MSHR each time a new one is allocated/deallocated. Also track the allocation/deallocation of each MSHR target. Change-Id: I2533e7660da1cde3052425f8db8852e59d463b42 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47041 Reviewed-by: Daniel Carvalho Maintainer: Daniel Carvalho Tested-by: kokoro --- src/mem/cache/mshr.cc | 12 ++++++++---- src/mem/cache/mshr.hh | 4 ++++ src/mem/cache/mshr_queue.cc | 15 +++++++++++++++ src/mem/cache/mshr_queue.hh | 5 +++++ src/mem/cache/queue.hh | 3 ++- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/mem/cache/mshr.cc b/src/mem/cache/mshr.cc index 2927d053f9..71bf6aefc5 100644 --- a/src/mem/cache/mshr.cc +++ b/src/mem/cache/mshr.cc @@ -178,6 +178,8 @@ MSHR::TargetList::add(PacketPtr pkt, Tick readyTime, } emplace_back(pkt, readyTime, order, source, markPending, alloc_on_fill); + + DPRINTF(MSHR, "New target allocated: %s\n", pkt->print()); } @@ -411,6 +413,8 @@ MSHR::allocateTarget(PacketPtr pkt, Tick whenReady, Counter _order, targets.add(pkt, whenReady, _order, Target::FromCPU, !inService, alloc_on_fill); } + + DPRINTF(MSHR, "After target allocation: %s", print()); } bool @@ -719,12 +723,12 @@ MSHR::print(std::ostream &os, int verbosity, const std::string &prefix) const hasFromCache() ? "HasFromCache" : ""); if (!targets.empty()) { - ccprintf(os, "%s Targets:\n", prefix); - targets.print(os, verbosity, prefix + " "); + ccprintf(os, "%s Targets:\n", prefix); + targets.print(os, verbosity, prefix + " "); } if (!deferredTargets.empty()) { - ccprintf(os, "%s Deferred Targets:\n", prefix); - deferredTargets.print(os, verbosity, prefix + " "); + ccprintf(os, "%s Deferred Targets:\n", prefix); + deferredTargets.print(os, verbosity, prefix + " "); } } diff --git a/src/mem/cache/mshr.hh b/src/mem/cache/mshr.hh index b23ed28056..c8fc5dae94 100644 --- a/src/mem/cache/mshr.hh +++ b/src/mem/cache/mshr.hh @@ -53,7 +53,9 @@ #include #include "base/printable.hh" +#include "base/trace.hh" #include "base/types.hh" +#include "debug/MSHR.hh" #include "mem/cache/queue_entry.hh" #include "mem/packet.hh" #include "mem/request.hh" @@ -460,6 +462,8 @@ class MSHR : public QueueEntry, public Printable */ void popTarget() { + DPRINTF(MSHR, "Force deallocating MSHR targets: %s\n", + targets.front().pkt->print()); targets.pop_front(); } diff --git a/src/mem/cache/mshr_queue.cc b/src/mem/cache/mshr_queue.cc index cea32fdf4c..4a32d908d8 100644 --- a/src/mem/cache/mshr_queue.cc +++ b/src/mem/cache/mshr_queue.cc @@ -46,6 +46,7 @@ #include +#include "debug/MSHR.hh" #include "mem/cache/mshr.hh" MSHRQueue::MSHRQueue(const std::string &_label, @@ -64,6 +65,9 @@ MSHRQueue::allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, assert(mshr->getNumTargets() == 0); freeList.pop_front(); + DPRINTF(MSHR, "Allocating new MSHR. Number in use will be %lu/%lu\n", + allocatedList.size() + 1, numEntries); + mshr->allocate(blk_addr, blk_size, pkt, when_ready, order, alloc_on_fill); mshr->allocIter = allocatedList.insert(allocatedList.end(), mshr); mshr->readyIter = addToReadyList(mshr); @@ -72,6 +76,17 @@ MSHRQueue::allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, return mshr; } +void +MSHRQueue::deallocate(MSHR* mshr) +{ + + DPRINTF(MSHR, "Deallocating all targets: %s", mshr->print()); + Queue::deallocate(mshr); + DPRINTF(MSHR, "MSHR deallocated. Number in use: %lu/%lu\n", + allocatedList.size(), numEntries); +} + + void MSHRQueue::moveToFront(MSHR *mshr) { diff --git a/src/mem/cache/mshr_queue.hh b/src/mem/cache/mshr_queue.hh index 98147fab7a..253ffd0f50 100644 --- a/src/mem/cache/mshr_queue.hh +++ b/src/mem/cache/mshr_queue.hh @@ -96,6 +96,11 @@ class MSHRQueue : public Queue MSHR *allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, Tick when_ready, Counter order, bool alloc_on_fill); + /** + * Deallocate a MSHR and its targets + */ + void deallocate(MSHR *mshr) override; + /** * Moves the MSHR to the front of the pending list if it is not * in service. diff --git a/src/mem/cache/queue.hh b/src/mem/cache/queue.hh index 81999a7384..a725016743 100644 --- a/src/mem/cache/queue.hh +++ b/src/mem/cache/queue.hh @@ -234,7 +234,8 @@ class Queue : public Drainable, public Named * * @param entry */ - void deallocate(Entry *entry) + virtual void + deallocate(Entry *entry) { allocatedList.erase(entry->allocIter); freeList.push_front(entry);