mem-cache: count pf filtered by demand to the same cache line

Add a stat to count how many prefetch request are filtered in the
prefetch queue becasue a demand is going to the same cache line
Also adding a corresponding debug statement for when it happens

Change-Id: I52475f19bd109c135b7259d08d5f5c0b5fd90ee5
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47203
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
diff --git a/src/mem/cache/prefetch/queued.cc b/src/mem/cache/prefetch/queued.cc
index a2e1952..dec71f2 100644
--- a/src/mem/cache/prefetch/queued.cc
+++ b/src/mem/cache/prefetch/queued.cc
@@ -178,8 +178,13 @@
         while (itr != pfq.end()) {
             if (itr->pfInfo.getAddr() == blk_addr &&
                 itr->pfInfo.isSecure() == is_secure) {
+                DPRINTF(HWPrefetch, "Removing pf candidate addr: %#x "
+                        "(cl: %#x), demand request going to the same addr\n",
+                        itr->pfInfo.getAddr(),
+                        blockAddress(itr->pfInfo.getAddr()));
                 delete itr->pkt;
                 itr = pfq.erase(itr);
+                statsQueued.pfRemovedDemand++;
             } else {
                 ++itr;
             }
@@ -258,6 +263,9 @@
              "number of redundant prefetches already in prefetch queue"),
     ADD_STAT(pfInCache, statistics::units::Count::get(),
              "number of redundant prefetches already in cache/mshr dropped"),
+    ADD_STAT(pfRemovedDemand, statistics::units::Count::get(),
+             "number of prefetches dropped due to a demand for the same "
+             "address"),
     ADD_STAT(pfRemovedFull, statistics::units::Count::get(),
              "number of prefetches dropped due to prefetch queue size"),
     ADD_STAT(pfSpanPage, statistics::units::Count::get(),
diff --git a/src/mem/cache/prefetch/queued.hh b/src/mem/cache/prefetch/queued.hh
index d710bc0..1062630 100644
--- a/src/mem/cache/prefetch/queued.hh
+++ b/src/mem/cache/prefetch/queued.hh
@@ -182,6 +182,7 @@
         statistics::Scalar pfIdentified;
         statistics::Scalar pfBufferHit;
         statistics::Scalar pfInCache;
+        statistics::Scalar pfRemovedDemand;
         statistics::Scalar pfRemovedFull;
         statistics::Scalar pfSpanPage;
     } statsQueued;