Giacomo Travaglini has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/35245 )

Change subject: arch-arm: Move TLB stats update within the lookup method
......................................................................

arch-arm: Move TLB stats update within the lookup method

This is preparing for getTE becoming a MMU method: we still want
those stats to be part of the TLB class as they are TLB related

Change-Id: I7078385fd150144dc5dd4924961e4eaaa7e2446a
Signed-off-by: Giacomo Travaglini <[email protected]>
---
M src/arch/arm/table_walker.cc
M src/arch/arm/tlb.cc
M src/arch/arm/tlb.hh
3 files changed, 31 insertions(+), 25 deletions(-)



diff --git a/src/arch/arm/table_walker.cc b/src/arch/arm/table_walker.cc
index 9462e27..6151c31 100644
--- a/src/arch/arm/table_walker.cc
+++ b/src/arch/arm/table_walker.cc
@@ -386,7 +386,7 @@
// @TODO Should this always be the TLB or should we look in the stage2 TLB?
     TlbEntry* te = tlb->lookup(currState->vaddr, currState->asid,
currState->vmid, currState->isHyp, currState->isSecure, true, false,
-            currState->el, false);
+            currState->el, false, BaseTLB::Read);

// Check if we still need to have a walk for this request. If the requesting // instruction has been squashed, or a previous walk has filled the TLB with
@@ -452,7 +452,7 @@
             currState = pendingQueue.front();
             te = tlb->lookup(currState->vaddr, currState->asid,
currState->vmid, currState->isHyp, currState->isSecure, true,
-                false, currState->el, false);
+                false, currState->el, false, BaseTLB::Read);
         } else {
             // Terminate the loop, nothing more to do
             currState = NULL;
diff --git a/src/arch/arm/tlb.cc b/src/arch/arm/tlb.cc
index 03ab153..f3a66e9 100644
--- a/src/arch/arm/tlb.cc
+++ b/src/arch/arm/tlb.cc
@@ -125,7 +125,7 @@
     }

     TlbEntry *e = lookup(va, asid, vmid, isHyp, isSecure, true, false,
-                         aarch64 ? aarch64EL : EL1, false);
+                         aarch64 ? aarch64EL : EL1, false, BaseTLB::Read);
     if (!e)
         return false;
     pa = e->pAddr(va);
@@ -159,7 +159,7 @@
 TlbEntry*
 TLB::lookup(Addr va, uint16_t asn, uint8_t vmid, bool hyp, bool secure,
             bool functional, bool ignore_asn, ExceptionLevel target_el,
-            bool in_host)
+            bool in_host, BaseTLB::Mode mode)
 {

     TlbEntry *retval = NULL;
@@ -197,6 +197,25 @@
             retval ? retval->global    : 0, retval ? retval->asid  : 0,
             retval ? retval->el        : 0);

+    // Updating stats if this was not a functional lookup
+    if (!functional) {
+        if (!retval) {
+            if (mode == BaseTLB::Execute)
+                stats.instMisses++;
+            else if (mode == BaseTLB::Write)
+                stats.writeMisses++;
+            else
+                stats.readMisses++;
+        } else {
+            if (mode == BaseTLB::Execute)
+                stats.instHits++;
+            else if (mode == BaseTLB::Write)
+               stats.writeHits++;
+            else
+                stats.readHits++;
+        }
+    }
+
     return retval;
 }

@@ -446,7 +465,7 @@
     bool hyp = target_el == EL2;

     te = lookup(mva, asn, vmid, hyp, secure_lookup, true, ignore_asn,
-                target_el, in_host);
+                target_el, in_host, BaseTLB::Read);
     while (te != NULL) {
         if (secure_lookup == !te->nstid) {
             DPRINTF(TLB, " -  %s\n", te->print());
@@ -454,7 +473,7 @@
             stats.flushedEntries++;
         }
         te = lookup(mva, asn, vmid, hyp, secure_lookup, false, ignore_asn,
-                    target_el, in_host);
+                    target_el, in_host, BaseTLB::Read);
     }
 }

@@ -1553,8 +1572,6 @@
     if (isStage2) {
         updateMiscReg(tc, tranType);
     }
-    bool is_fetch = (mode == Execute);
-    bool is_write = (mode == Write);

     Addr vaddr_tainted = req->getVaddr();
     Addr vaddr = 0;
@@ -1566,7 +1583,7 @@
         vaddr = vaddr_tainted;
     }
*te = lookup(vaddr, asid, vmid, isHyp, is_secure, false, false, target_el,
-                 false);
+                 false, mode);
     if (*te == NULL) {
         if (req->isPrefetch()) {
// if the request is a prefetch don't attempt to fill the TLB or go
@@ -1577,13 +1594,6 @@
                vaddr_tainted, ArmFault::PrefetchTLBMiss, isStage2);
         }

-        if (is_fetch)
-            stats.instMisses++;
-        else if (is_write)
-            stats.writeMisses++;
-        else
-            stats.readMisses++;
-
         // start translation table walk, pass variables rather than
         // re-retreaving in table walker for speed
DPRINTF(TLB, "TLB Miss: Starting hardware table walker for %#x(%d:%d)\n",
@@ -1598,17 +1608,10 @@
         }

         *te = lookup(vaddr, asid, vmid, isHyp, is_secure, false, false,
-                     target_el, false);
+                     target_el, false, mode);
         if (!*te)
             printTlb();
         assert(*te);
-    } else {
-        if (is_fetch)
-            stats.instHits++;
-        else if (is_write)
-           stats.writeHits++;
-        else
-            stats.readHits++;
     }
     return NoFault;
 }
diff --git a/src/arch/arm/tlb.hh b/src/arch/arm/tlb.hh
index ee827e3..eae7b25 100644
--- a/src/arch/arm/tlb.hh
+++ b/src/arch/arm/tlb.hh
@@ -215,12 +215,15 @@
      * @param hyp if the lookup is done from hyp mode
      * @param functional if the lookup should modify state
      * @param ignore_asn if on lookup asn should be ignored
+     * @param target_el selecting the translation regime
+     * @param in_host if we are in host (EL2&0 regime)
+     * @param mode to differentiate between read/writes/fetches.
      * @return pointer to TLB entry if it exists
      */
     TlbEntry *lookup(Addr vpn, uint16_t asn, uint8_t vmid, bool hyp,
                      bool secure, bool functional,
                      bool ignore_asn, ExceptionLevel target_el,
-                     bool in_host);
+                     bool in_host, BaseTLB::Mode mode);

     virtual ~TLB();


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/35245
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7078385fd150144dc5dd4924961e4eaaa7e2446a
Gerrit-Change-Number: 35245
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to