summaryrefslogtreecommitdiff
path: root/src/mem/cache/tags/sector_blk.cc
diff options
context:
space:
mode:
authorDaniel R. Carvalho <odanrc@yahoo.com.br>2018-10-25 17:52:26 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2018-12-03 15:44:36 +0000
commitab31213316a6334660eff8fa47434c0e25f2b5c0 (patch)
tree6a3b08dc29a5a1382f147d571455e63c332249bc /src/mem/cache/tags/sector_blk.cc
parent9af1214ffe48178c0dadfb874fd62bd0ff2e0f31 (diff)
downloadgem5-ab31213316a6334660eff8fa47434c0e25f2b5c0.tar.xz
mem-cache: Optimize sector valid and secure check
Previously a loop was being done to check whether the block was valid/secure or not. Variables have been added to skip this loop and save and update sector block state when sub-blocks are validated, invalidated and secured. Change-Id: Ie1734f7dfda9698c7bf22a1fcbfc47ffb9239cea Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/14363 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src/mem/cache/tags/sector_blk.cc')
-rw-r--r--src/mem/cache/tags/sector_blk.cc62
1 files changed, 50 insertions, 12 deletions
diff --git a/src/mem/cache/tags/sector_blk.cc b/src/mem/cache/tags/sector_blk.cc
index de9153639..93b1961d8 100644
--- a/src/mem/cache/tags/sector_blk.cc
+++ b/src/mem/cache/tags/sector_blk.cc
@@ -72,6 +72,27 @@ SectorSubBlk::getTag() const
}
void
+SectorSubBlk::setValid()
+{
+ CacheBlk::setValid();
+ _sectorBlk->validateSubBlk();
+}
+
+void
+SectorSubBlk::setSecure()
+{
+ CacheBlk::setSecure();
+ _sectorBlk->setSecure();
+}
+
+void
+SectorSubBlk::invalidate()
+{
+ CacheBlk::invalidate();
+ _sectorBlk->invalidateSubBlk();
+}
+
+void
SectorSubBlk::insert(const Addr tag, const bool is_secure,
const int src_master_ID, const uint32_t task_ID)
{
@@ -94,28 +115,23 @@ SectorSubBlk::print() const
getSectorOffset());
}
+SectorBlk::SectorBlk()
+ : ReplaceableEntry(), _tag(MaxAddr), _validCounter(0), _secureBit(false)
+{
+}
+
bool
SectorBlk::isValid() const
{
// If any of the blocks in the sector is valid, so is the sector
- for (const auto& blk : blks) {
- if (blk->isValid()) {
- return true;
- }
- }
- return false;
+ return _validCounter > 0;
}
bool
SectorBlk::isSecure() const
{
// If any of the valid blocks in the sector is secure, so is the sector
- for (const auto& blk : blks) {
- if (blk->isValid()) {
- return blk->isSecure();
- }
- }
- return false;
+ return _secureBit;
}
void
@@ -129,3 +145,25 @@ SectorBlk::getTag() const
{
return _tag;
}
+
+void
+SectorBlk::validateSubBlk()
+{
+ _validCounter++;
+}
+
+void
+SectorBlk::invalidateSubBlk()
+{
+ // If all sub-blocks have been invalidated, the sector becomes invalid,
+ // so clear secure bit
+ if (--_validCounter == 0) {
+ _secureBit = false;
+ }
+}
+
+void
+SectorBlk::setSecure()
+{
+ _secureBit = true;
+}