1/* 2 * Copyright (c) 2013 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 108 unchanged lines hidden (view full) --- 117 pfSquashed 118 .name(name() + ".prefetcher.num_hwpf_squashed_from_miss") 119 .desc("number of hwpf that got squashed due to a miss " 120 "aborting calculation time") 121 ; 122} 123 124inline bool |
125BasePrefetcher::inCache(Addr addr, bool is_secure) |
126{ |
127 if (cache->inCache(addr, is_secure)) { |
128 pfCacheHit++; 129 return true; 130 } 131 return false; 132} 133 134inline bool |
135BasePrefetcher::inMissQueue(Addr addr, bool is_secure) |
136{ |
137 if (cache->inMissQueue(addr, is_secure)) { |
138 pfMSHRHit++; 139 return true; 140 } 141 return false; 142} 143 144PacketPtr 145BasePrefetcher::getPacket() --- 6 unchanged lines hidden (view full) --- 152 } 153 154 PacketPtr pkt = pf.begin()->pkt; 155 while (!pf.empty()) { 156 pkt = pf.begin()->pkt; 157 pf.pop_front(); 158 159 Addr blk_addr = pkt->getAddr() & ~(Addr)(blkSize-1); |
160 bool is_secure = pkt->isSecure(); |
161 |
162 if (!inCache(blk_addr, is_secure) && !inMissQueue(blk_addr, is_secure)) |
163 // we found a prefetch, return it 164 break; 165 |
166 DPRINTF(HWPrefetch, "addr 0x%x (%s) in cache, skipping\n", 167 pkt->getAddr(), is_secure ? "s" : "ns"); |
168 delete pkt->req; 169 delete pkt; 170 171 if (pf.empty()) { 172 cache->deassertMemSideBusRequest(BaseCache::Request_PF); 173 return NULL; // None left, all were in cache 174 } 175 } 176 177 pfIssued++; 178 assert(pkt != NULL); |
179 DPRINTF(HWPrefetch, "returning 0x%x (%s)\n", pkt->getAddr(), 180 pkt->isSecure() ? "s" : "ns"); |
181 return pkt; 182} 183 184 185Tick 186BasePrefetcher::notify(PacketPtr &pkt, Tick tick) 187{ 188 if (!pkt->req->isUncacheable() && !(pkt->req->isInstFetch() && onlyData)) { 189 // Calculate the blk address 190 Addr blk_addr = pkt->getAddr() & ~(Addr)(blkSize-1); |
191 bool is_secure = pkt->isSecure(); |
192 193 // Check if miss is in pfq, if so remove it |
194 std::list<DeferredPacket>::iterator iter = inPrefetch(blk_addr, 195 is_secure); |
196 if (iter != pf.end()) { 197 DPRINTF(HWPrefetch, "Saw a miss to a queued prefetch addr: " |
198 "0x%x (%s), removing it\n", blk_addr, 199 is_secure ? "s" : "ns"); |
200 pfRemovedMSHR++; 201 delete iter->pkt->req; 202 delete iter->pkt; 203 iter = pf.erase(iter); 204 if (pf.empty()) 205 cache->deassertMemSideBusRequest(BaseCache::Request_PF); 206 } 207 --- 32 unchanged lines hidden (view full) --- 240 241 pfIdentified++; 242 243 DPRINTF(HWPrefetch, "Found a pf candidate addr: 0x%x, " 244 "inserting into prefetch queue with delay %d time %d\n", 245 addr, *delayIter, time); 246 247 // Check if it is already in the pf buffer |
248 if (inPrefetch(addr, is_secure) != pf.end()) { |
249 pfBufferHit++; 250 DPRINTF(HWPrefetch, "Prefetch addr already in pf buffer\n"); 251 continue; 252 } 253 254 // create a prefetch memreq 255 Request *prefetchReq = new Request(*addrIter, blkSize, 0, masterId); |
256 if (is_secure) 257 prefetchReq->setFlags(Request::SECURE); |
258 prefetchReq->taskId(ContextSwitchTaskId::Prefetcher); 259 PacketPtr prefetch = 260 new Packet(prefetchReq, MemCmd::HardPFReq); 261 prefetch->allocate(); 262 prefetch->req->setThreadContext(pkt->req->contextId(), 263 pkt->req->threadId()); 264 265 // We just remove the head if we are full --- 11 unchanged lines hidden (view full) --- 277 prefetch)); 278 } 279 } 280 281 return pf.empty() ? 0 : pf.front().tick; 282} 283 284std::list<BasePrefetcher::DeferredPacket>::iterator |
285BasePrefetcher::inPrefetch(Addr address, bool is_secure) |
286{ 287 // Guaranteed to only be one match, we always check before inserting 288 std::list<DeferredPacket>::iterator iter; 289 for (iter = pf.begin(); iter != pf.end(); iter++) { |
290 if (((*iter).pkt->getAddr() & ~(Addr)(blkSize-1)) == address && 291 (*iter).pkt->isSecure() == is_secure) { |
292 return iter; 293 } 294 } 295 return pf.end(); 296} 297 298bool 299BasePrefetcher::samePage(Addr a, Addr b) 300{ 301 return roundDown(a, TheISA::VMPageSize) == roundDown(b, TheISA::VMPageSize); 302} 303 304 |