mem-cache: Virtualize block print

Encapsulate and virtualize block print, so that relevant
information can be easily printed anywhere.

Change-Id: I91109c29c126755183a0fd2b4446f5335e64076b
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/13415
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
Daniel R. Carvalho
2018-10-10 14:44:05 +02:00
committed by Daniel Carvalho
parent 160bcba0d6
commit 1b44e883a2
9 changed files with 38 additions and 15 deletions

View File

@@ -52,6 +52,7 @@
#include "base/logging.hh"
#include "debug/Cache.hh"
#include "debug/CachePort.hh"
#include "debug/CacheRepl.hh"
#include "debug/CacheVerbose.hh"
#include "mem/cache/mshr.hh"
#include "mem/cache/prefetch/base.hh"
@@ -1237,6 +1238,9 @@ BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks)
if (!victim)
return nullptr;
// Print victim block's information
DPRINTF(CacheRepl, "Replacement victim: %s\n", victim->print());
// Check for transient state allocations. If any of the entries listed
// for eviction has a transient state, the allocation fails
for (const auto& blk : evict_blks) {

View File

@@ -292,12 +292,12 @@ class CacheBlk : public ReplaceableEntry
}
/**
* Pretty-print a tag, and interpret state bits to readable form
* Pretty-print tag, set and way, and interpret state bits to readable form
* including mapping to a MOESI state.
*
* @return string with basic state information
*/
std::string print() const
virtual std::string print() const
{
/**
* state M O E S I
@@ -334,8 +334,9 @@ class CacheBlk : public ReplaceableEntry
default: s = 'T'; break; // @TODO add other types
}
return csprintf("state: %x (%c) valid: %d writable: %d readable: %d "
"dirty: %d tag: %x", status, s, isValid(),
isWritable(), isReadable(), isDirty(), tag);
"dirty: %d | tag: %#x set: %#x way: %#x", status, s,
isValid(), isWritable(), isReadable(), isDirty(), tag,
getSet(), getWay());
}
/**

View File

@@ -37,6 +37,7 @@
#include <cassert>
#include "base/cprintf.hh"
#include "base/logging.hh"
void
@@ -86,6 +87,13 @@ SectorSubBlk::insert(const Addr tag, const bool is_secure,
_sectorBlk->setTag(tag);
}
std::string
SectorSubBlk::print() const
{
return csprintf("%s sector offset: %#x", CacheBlk::print(),
getSectorOffset());
}
bool
SectorBlk::isValid() const
{

View File

@@ -114,6 +114,13 @@ class SectorSubBlk : public CacheBlk
*/
void insert(const Addr tag, const bool is_secure, const int src_master_ID,
const uint32_t task_ID) override;
/**
* Pretty-print sector offset and other CacheBlk information.
*
* @return string with basic state information
*/
std::string print() const override;
};
/**

View File

@@ -201,8 +201,7 @@ BaseTags::print()
auto print_blk = [&str](CacheBlk &blk) {
if (blk.isValid())
str += csprintf("\tset: %x, way: %x %s\n", blk.getSet(),
blk.getWay(), blk.print());
str += csprintf("\tBlock: %s\n", blk.print());
};
forEachBlk(print_blk);

View File

@@ -54,7 +54,6 @@
#include "base/logging.hh"
#include "base/types.hh"
#include "debug/CacheRepl.hh"
#include "mem/cache/base.hh"
#include "mem/cache/blk.hh"
#include "mem/cache/replacement_policies/base.hh"
@@ -187,9 +186,6 @@ class BaseSetAssoc : public BaseTags
// There is only one eviction for this replacement
evict_blks.push_back(victim);
DPRINTF(CacheRepl, "set %x, way %x: selecting blk for replacement\n",
victim->getSet(), victim->getWay());
return victim;
}

View File

@@ -57,6 +57,12 @@
#include "base/logging.hh"
#include "mem/cache/base.hh"
std::string
FALRUBlk::print() const
{
return csprintf("%s inCachesMask: %#x", CacheBlk::print(), inCachesMask);
}
FALRU::FALRU(const Params *p)
: BaseTags(p),

View File

@@ -92,6 +92,13 @@ class FALRUBlk : public CacheBlk
/** A bit mask of the caches that fit this block. */
CachesMask inCachesMask;
/**
* Pretty-print inCachesMask and other CacheBlk information.
*
* @return string with basic state information
*/
std::string print() const override;
};
/**

View File

@@ -42,7 +42,6 @@
#include "base/intmath.hh"
#include "base/logging.hh"
#include "base/types.hh"
#include "debug/CacheRepl.hh"
#include "mem/cache/base.hh"
#include "mem/cache/replacement_policies/base.hh"
#include "mem/cache/tags/indexing_policies/base.hh"
@@ -277,10 +276,6 @@ SectorTags::findVictim(Addr addr, const bool is_secure,
}
}
DPRINTF(CacheRepl, "set %x, way %x, sector offset %x: selecting blk " \
"for replacement\n", victim->getSet(), victim->getWay(),
victim->getSectorOffset());
return victim;
}