diff options
author | Ali Saidi <Ali.Saidi@ARM.com> | 2011-08-19 15:08:05 -0500 |
---|---|---|
committer | Ali Saidi <Ali.Saidi@ARM.com> | 2011-08-19 15:08:05 -0500 |
commit | 6779bd3e5da2355242cd3ba4967cb164c2a0b837 (patch) | |
tree | db07098bd8df412d48807f1583e115ed553f6a11 /src/mem | |
parent | b3a058f22034a52414304116021bf2b2acfaa258 (diff) | |
download | gem5-6779bd3e5da2355242cd3ba4967cb164c2a0b837.tar.xz |
Prefetcher: Fix some memory leaks with the prefetcher.
Diffstat (limited to 'src/mem')
-rw-r--r-- | src/mem/cache/cache_impl.hh | 4 | ||||
-rw-r--r-- | src/mem/cache/prefetch/base.cc | 24 | ||||
-rw-r--r-- | src/mem/cache/prefetch/stride.cc | 3 |
3 files changed, 19 insertions, 12 deletions
diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh index e1aed8b0c..e9a40a741 100644 --- a/src/mem/cache/cache_impl.hh +++ b/src/mem/cache/cache_impl.hh @@ -1443,6 +1443,10 @@ Cache<TagStore>::getNextMSHR() mshr_misses[pkt->cmdToIndex()][0/*pkt->req->threadId()*/]++; // Don't request bus, since we already have it return allocateMissBuffer(pkt, curTick(), false); + } else { + // free the request and packet + delete pkt->req; + delete pkt; } } } diff --git a/src/mem/cache/prefetch/base.cc b/src/mem/cache/prefetch/base.cc index 12028ac52..52d117140 100644 --- a/src/mem/cache/prefetch/base.cc +++ b/src/mem/cache/prefetch/base.cc @@ -139,25 +139,25 @@ BasePrefetcher::getPacket() } PacketPtr pkt; - bool keep_trying = false; - do { + while (!pf.empty()) { pkt = *pf.begin(); pf.pop_front(); - if (keep_trying) { - DPRINTF(HWPrefetch, "addr 0x%x in cache, skipping\n", - pkt->getAddr()); - delete pkt->req; - delete pkt; - } + Addr blk_addr = pkt->getAddr() & ~(Addr)(blkSize-1); + + if (!inCache(blk_addr) && !inMissQueue(blk_addr)) + // we found a prefetch, return it + break; + + DPRINTF(HWPrefetch, "addr 0x%x in cache, skipping\n", pkt->getAddr()); + delete pkt->req; + delete pkt; if (pf.empty()) { cache->deassertMemSideBusRequest(BaseCache::Request_PF); - if (keep_trying) { - return NULL; // None left, all were in cache - } + return NULL; // None left, all were in cache } - } while (keep_trying); + } pfIssued++; assert(pkt != NULL); diff --git a/src/mem/cache/prefetch/stride.cc b/src/mem/cache/prefetch/stride.cc index f71fd977d..a5cc805ef 100644 --- a/src/mem/cache/prefetch/stride.cc +++ b/src/mem/cache/prefetch/stride.cc @@ -118,6 +118,9 @@ StridePrefetcher::calculatePrefetch(PacketPtr &pkt, std::list<Addr> &addresses, } } DPRINTF(HWPrefetch, " replacing PC %x\n", (*min_pos)->instAddr); + + // free entry and delete it + delete *min_pos; tab.erase(min_pos); } |