gem5  v22.1.0.0
mshr.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2015-2019 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
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2002-2005 The Regents of The University of Michigan
15  * Copyright (c) 2010 Advanced Micro Devices, Inc.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
47 #include "mem/cache/mshr.hh"
48 
49 #include <cassert>
50 #include <string>
51 
52 #include "base/logging.hh"
53 #include "base/trace.hh"
54 #include "base/types.hh"
55 #include "debug/MSHR.hh"
56 #include "mem/cache/base.hh"
57 #include "mem/request.hh"
58 
59 namespace gem5
60 {
61 
62 MSHR::MSHR(const std::string &name)
63  : QueueEntry(name),
64  downstreamPending(false),
65  pendingModified(false),
66  postInvalidate(false), postDowngrade(false),
67  wasWholeLineWrite(false), isForward(false),
68  targets(name + ".targets"),
69  deferredTargets(name + ".deferredTargets")
70 {
71 }
72 
74  : Named(name),
75  needsWritable(false), hasUpgrade(false),
76  allocOnFill(false), hasFromCache(false)
77 {}
78 
79 
80 void
82  bool alloc_on_fill)
83 {
84  if (source != Target::FromSnoop) {
85  if (pkt->needsWritable()) {
86  needsWritable = true;
87  }
88 
89  // StoreCondReq is effectively an upgrade if it's in an MSHR
90  // since it would have been failed already if we didn't have a
91  // read-only copy
92  if (pkt->isUpgrade() || pkt->cmd == MemCmd::StoreCondReq) {
93  hasUpgrade = true;
94  }
95 
96  // potentially re-evaluate whether we should allocate on a fill or
97  // not
98  allocOnFill = allocOnFill || alloc_on_fill;
99 
100  if (source != Target::FromPrefetcher) {
101  hasFromCache = hasFromCache || pkt->fromCache();
102 
103  updateWriteFlags(pkt);
104  }
105  }
106 }
107 
108 void
110 {
111  resetFlags();
112  for (auto& t: *this) {
113  updateFlags(t.pkt, t.source, t.allocOnFill);
114  }
115 }
116 
117 void
119 {
120  if (isWholeLineWrite()) {
121  // if we have already seen writes for the full block
122  // stop here, this might be a full line write followed
123  // by other compatible requests (e.g., reads)
124  return;
125  }
126 
127  if (canMergeWrites) {
128  if (!pkt->isWrite()) {
129  // We won't allow further merging if this hasn't
130  // been a write
131  canMergeWrites = false;
132  return;
133  }
134 
135  // Avoid merging requests with special flags (e.g.,
136  // strictly ordered)
137  const Request::FlagsType no_merge_flags =
141  const auto &req_flags = pkt->req->getFlags();
142  bool compat_write = !req_flags.isSet(no_merge_flags);
143 
144  // if this is the first write, it might be a whole
145  // line write and even if we can't merge any
146  // subsequent write requests, we still need to service
147  // it as a whole line write (e.g., SECURE whole line
148  // write)
149  bool first_write = empty();
150  if (first_write || compat_write) {
151  auto offset = pkt->getOffset(blkSize);
152  auto begin = writesBitmap.begin() + offset;
153  std::fill(begin, begin + pkt->getSize(), true);
154  }
155 
156  // We won't allow further merging if this has been a
157  // special write
158  canMergeWrites &= compat_write;
159  }
160 }
161 
162 inline void
164  Counter order, Target::Source source, bool markPending,
165  bool alloc_on_fill)
166 {
167  updateFlags(pkt, source, alloc_on_fill);
168  if (markPending) {
169  // Iterate over the SenderState stack and see if we find
170  // an MSHR entry. If we do, set the downstreamPending
171  // flag. Otherwise, do nothing.
172  MSHR *mshr = pkt->findNextSenderState<MSHR>();
173  if (mshr != nullptr) {
174  assert(!mshr->downstreamPending);
175  mshr->downstreamPending = true;
176  } else {
177  // No need to clear downstreamPending later
178  markPending = false;
179  }
180  }
181 
182  emplace_back(pkt, readyTime, order, source, markPending, alloc_on_fill);
183 
184  DPRINTF(MSHR, "New target allocated: %s\n", pkt->print());
185 }
186 
187 
188 static void
190 {
191  // remember if the current packet has data allocated
192  bool has_data = pkt->hasData() || pkt->hasRespData();
193 
194  if (pkt->cmd == MemCmd::UpgradeReq) {
195  pkt->cmd = MemCmd::ReadExReq;
196  DPRINTF(MSHR, "Replacing UpgradeReq with ReadExReq\n");
197  } else if (pkt->cmd == MemCmd::SCUpgradeReq) {
199  DPRINTF(MSHR, "Replacing SCUpgradeReq with SCUpgradeFailReq\n");
200  } else if (pkt->cmd == MemCmd::StoreCondReq) {
202  DPRINTF(MSHR, "Replacing StoreCondReq with StoreCondFailReq\n");
203  }
204 
205  if (!has_data) {
206  // there is no sensible way of setting the data field if the
207  // new command actually would carry data
208  assert(!pkt->hasData());
209 
210  if (pkt->hasRespData()) {
211  // we went from a packet that had no data (neither request,
212  // nor response), to one that does, and therefore we need to
213  // actually allocate space for the data payload
214  pkt->allocate();
215  }
216  }
217 }
218 
219 
220 void
222 {
223  if (!hasUpgrade)
224  return;
225 
226  for (auto& t : *this) {
227  replaceUpgrade(t.pkt);
228  }
229 
230  hasUpgrade = false;
231 }
232 
233 
234 void
235 MSHR::TargetList::clearDownstreamPending(MSHR::TargetList::iterator begin,
236  MSHR::TargetList::iterator end)
237 {
238  for (auto t = begin; t != end; t++) {
239  if (t->markedPending) {
240  // Iterate over the SenderState stack and see if we find
241  // an MSHR entry. If we find one, clear the
242  // downstreamPending flag by calling
243  // clearDownstreamPending(). This recursively clears the
244  // downstreamPending flag in all caches this packet has
245  // passed through.
246  MSHR *mshr = t->pkt->findNextSenderState<MSHR>();
247  if (mshr != nullptr) {
248  mshr->clearDownstreamPending();
249  }
250  t->markedPending = false;
251  }
252  }
253 }
254 
255 void
257 {
258  clearDownstreamPending(begin(), end());
259 }
260 
261 
262 bool
264 {
265  for (auto& t : *this) {
266  if (pkt->trySatisfyFunctional(t.pkt)) {
267  return true;
268  }
269  }
270 
271  return false;
272 }
273 
274 
275 void
276 MSHR::TargetList::print(std::ostream &os, int verbosity,
277  const std::string &prefix) const
278 {
279  for (auto& t : *this) {
280  const char *s;
281  switch (t.source) {
282  case Target::FromCPU:
283  s = "FromCPU";
284  break;
285  case Target::FromSnoop:
286  s = "FromSnoop";
287  break;
289  s = "FromPrefetcher";
290  break;
291  default:
292  s = "";
293  break;
294  }
295  ccprintf(os, "%s%s: ", prefix, s);
296  t.pkt->print(os, verbosity, "");
297  ccprintf(os, "\n");
298  }
299 }
300 
301 
302 void
303 MSHR::allocate(Addr blk_addr, unsigned blk_size, PacketPtr target,
304  Tick when_ready, Counter _order, bool alloc_on_fill)
305 {
306  blkAddr = blk_addr;
307  blkSize = blk_size;
308  isSecure = target->isSecure();
309  readyTime = when_ready;
310  order = _order;
311  assert(target);
312  isForward = false;
313  wasWholeLineWrite = false;
314  _isUncacheable = target->req->isUncacheable();
315  inService = false;
316  downstreamPending = false;
317 
320 
321  // Don't know of a case where we would allocate a new MSHR for a
322  // snoop (mem-side request), so set source according to request here
323  Target::Source source = (target->cmd == MemCmd::HardPFReq) ?
325  targets.add(target, when_ready, _order, source, true, alloc_on_fill);
326 
327  // All targets must refer to the same block
328  assert(target->matchBlockAddr(targets.front().pkt, blkSize));
329 }
330 
331 
332 void
334 {
335  assert(downstreamPending);
336  downstreamPending = false;
337  // recursively clear flag on any MSHRs we will be forwarding
338  // responses to
340 }
341 
342 void
343 MSHR::markInService(bool pending_modified_resp)
344 {
345  assert(!inService);
346 
347  inService = true;
348  pendingModified = targets.needsWritable || pending_modified_resp;
349  postInvalidate = postDowngrade = false;
350 
351  if (!downstreamPending) {
352  // let upstream caches know that the request has made it to a
353  // level where it's going to get a response
355  }
356  // if the line is not considered a whole-line write when sent
357  // downstream, make sure it is also not considered a whole-line
358  // write when receiving the response, and vice versa
360 }
361 
362 
363 void
365 {
366  assert(targets.empty());
368  assert(deferredTargets.isReset());
369  inService = false;
370 }
371 
372 /*
373  * Adds a target to an MSHR
374  */
375 void
377  bool alloc_on_fill)
378 {
379  // assume we'd never issue a prefetch when we've got an
380  // outstanding miss
381  assert(pkt->cmd != MemCmd::HardPFReq);
382 
383  // if there's a request already in service for this MSHR, we will
384  // have to defer the new target until after the response if any of
385  // the following are true:
386  // - there are other targets already deferred
387  // - there's a pending invalidate to be applied after the response
388  // comes back (but before this target is processed)
389  // - the MSHR's first (and only) non-deferred target is a cache
390  // maintenance packet
391  // - the new target is a cache maintenance packet (this is probably
392  // overly conservative but certainly safe)
393  // - this target requires a writable block and either we're not
394  // getting a writable block back or we have already snooped
395  // another read request that will downgrade our writable block
396  // to non-writable (Shared or Owned)
397  PacketPtr tgt_pkt = targets.front().pkt;
398  if (pkt->req->isCacheMaintenance() ||
399  tgt_pkt->req->isCacheMaintenance() ||
400  !deferredTargets.empty() ||
401  (inService &&
402  (hasPostInvalidate() ||
403  (pkt->needsWritable() &&
404  (!isPendingModified() || hasPostDowngrade() || isForward))))) {
405  // need to put on deferred list
406  if (inService && hasPostInvalidate())
407  replaceUpgrade(pkt);
408  deferredTargets.add(pkt, whenReady, _order, Target::FromCPU, true,
409  alloc_on_fill);
410  } else {
411  // No request outstanding, or still OK to append to
412  // outstanding request: append to regular target list. Only
413  // mark pending if current request hasn't been issued yet
414  // (isn't in service).
415  targets.add(pkt, whenReady, _order, Target::FromCPU, !inService,
416  alloc_on_fill);
417  }
418 
419  DPRINTF(MSHR, "After target allocation: %s", print());
420 }
421 
422 bool
424 {
425  DPRINTF(MSHR, "%s for %s\n", __func__, pkt->print());
426 
427  // when we snoop packets the needsWritable and isInvalidate flags
428  // should always be the same, however, this assumes that we never
429  // snoop writes as they are currently not marked as invalidations
430  panic_if((pkt->needsWritable() != pkt->isInvalidate()) &&
431  !pkt->req->isCacheMaintenance(),
432  "%s got snoop %s where needsWritable, "
433  "does not match isInvalidate", name(), pkt->print());
434 
435  if (!inService || (pkt->isExpressSnoop() && downstreamPending)) {
436  // Request has not been issued yet, or it's been issued
437  // locally but is buffered unissued at some downstream cache
438  // which is forwarding us this snoop. Either way, the packet
439  // we're snooping logically precedes this MSHR's request, so
440  // the snoop has no impact on the MSHR, but must be processed
441  // in the standard way by the cache. The only exception is
442  // that if we're an L2+ cache buffering an UpgradeReq from a
443  // higher-level cache, and the snoop is invalidating, then our
444  // buffered upgrades must be converted to read exclusives,
445  // since the upper-level cache no longer has a valid copy.
446  // That is, even though the upper-level cache got out on its
447  // local bus first, some other invalidating transaction
448  // reached the global bus before the upgrade did.
449  if (pkt->needsWritable() || pkt->req->isCacheInvalidate()) {
452  }
453 
454  return false;
455  }
456 
457  // From here on down, the request issued by this MSHR logically
458  // precedes the request we're snooping.
459  if (pkt->needsWritable() || pkt->req->isCacheInvalidate()) {
460  // snooped request still precedes the re-request we'll have to
461  // issue for deferred targets, if any...
463  }
464 
465  PacketPtr tgt_pkt = targets.front().pkt;
466  if (hasPostInvalidate() || tgt_pkt->req->isCacheInvalidate()) {
467  // a prior snoop has already appended an invalidation or a
468  // cache invalidation operation is in progress, so logically
469  // we don't have the block anymore; no need for further
470  // snooping.
471  return true;
472  }
473 
474  // Start by determining if we will eventually respond or not,
475  // matching the conditions checked in Cache::handleSnoop
476  const bool will_respond = isPendingModified() && pkt->needsResponse() &&
477  !pkt->isClean();
478  if (isPendingModified() || pkt->isInvalidate()) {
479  // We need to save and replay the packet in two cases:
480  // 1. We're awaiting a writable copy (Modified or Exclusive),
481  // so this MSHR is the orgering point, and we need to respond
482  // after we receive data.
483  // 2. It's an invalidation (e.g., UpgradeReq), and we need
484  // to forward the snoop up the hierarchy after the current
485  // transaction completes.
486 
487  // The packet we are snooping may be deleted by the time we
488  // actually process the target, and we consequently need to
489  // save a copy here. Clear flags and also allocate new data as
490  // the original packet data storage may have been deleted by
491  // the time we get to process this packet. In the cases where
492  // we are not responding after handling the snoop we also need
493  // to create a copy of the request to be on the safe side. In
494  // the latter case the cache is responsible for deleting both
495  // the packet and the request as part of handling the deferred
496  // snoop.
497  PacketPtr cp_pkt = will_respond ? new Packet(pkt, true, true) :
498  new Packet(std::make_shared<Request>(*pkt->req), pkt->cmd,
499  blkSize, pkt->id);
500 
501  if (will_respond) {
502  // we are the ordering point, and will consequently
503  // respond, and depending on whether the packet
504  // needsWritable or not we either pass a Shared line or a
505  // Modified line
506  pkt->setCacheResponding();
507 
508  // inform the cache hierarchy that this cache had the line
509  // in the Modified state, even if the response is passed
510  // as Shared (and thus non-writable)
512 
513  // in the case of an uncacheable request there is no need
514  // to set the responderHadWritable flag, but since the
515  // recipient does not care there is no harm in doing so
516  } else if (isPendingModified() && pkt->isClean()) {
517  // this cache doesn't respond to the clean request, a
518  // destination xbar will respond to this request, but to
519  // do so it needs to know if it should wait for the
520  // WriteCleanReq
521  pkt->setSatisfied();
522  }
523 
524  targets.add(cp_pkt, curTick(), _order, Target::FromSnoop,
526 
527  if (pkt->needsWritable() || pkt->isInvalidate()) {
528  // This transaction will take away our pending copy
529  postInvalidate = true;
530  }
531  }
532 
533  if (!pkt->needsWritable() && !pkt->req->isUncacheable()) {
534  // This transaction will get a read-shared copy, downgrading
535  // our copy if we had a writable one
536  postDowngrade = true;
537  // make sure that any downstream cache does not respond with a
538  // writable (and dirty) copy even if it has one, unless it was
539  // explicitly asked for one
540  pkt->setHasSharers();
541  }
542 
543  return will_respond;
544 }
545 
548 {
549  TargetList ready_targets;
550  ready_targets.init(blkAddr, blkSize);
551  // If the downstream MSHR got an invalidation request then we only
552  // service the first of the FromCPU targets and any other
553  // non-FromCPU target. This way the remaining FromCPU targets
554  // issue a new request and get a fresh copy of the block and we
555  // avoid memory consistency violations.
556  if (pkt->cmd == MemCmd::ReadRespWithInvalidate) {
557  auto it = targets.begin();
558  assert((it->source == Target::FromCPU) ||
559  (it->source == Target::FromPrefetcher));
560  ready_targets.push_back(*it);
561  // Leave the Locked RMW Read until the corresponding Locked Write
562  // request comes in
563  if (it->pkt->cmd != MemCmd::LockedRMWReadReq) {
564  it = targets.erase(it);
565  while (it != targets.end()) {
566  if (it->source == Target::FromCPU) {
567  it++;
568  } else {
569  assert(it->source == Target::FromSnoop);
570  ready_targets.push_back(*it);
571  it = targets.erase(it);
572  }
573  }
574  }
575  ready_targets.populateFlags();
576  } else {
577  auto it = targets.begin();
578  while (it != targets.end()) {
579  ready_targets.push_back(*it);
580  if (it->pkt->cmd == MemCmd::LockedRMWReadReq) {
581  // Leave the Locked RMW Read until the corresponding Locked
582  // Write comes in. Also don't service any later targets as the
583  // line is now "locked".
584  break;
585  }
586  it = targets.erase(it);
587  }
588  ready_targets.populateFlags();
589  }
591 
592  return ready_targets;
593 }
594 
595 bool
597 {
598  if (targets.empty() && deferredTargets.empty()) {
599  // nothing to promote
600  return false;
601  }
602 
603  // the deferred targets can be generally promoted unless they
604  // contain a cache maintenance request
605 
606  // find the first target that is a cache maintenance request
607  auto it = std::find_if(deferredTargets.begin(), deferredTargets.end(),
608  [](MSHR::Target &t) {
609  return t.pkt->req->isCacheMaintenance();
610  });
611  if (it == deferredTargets.begin()) {
612  // if the first deferred target is a cache maintenance packet
613  // then we can promote provided the targets list is empty and
614  // we can service it on its own
615  if (targets.empty()) {
616  targets.splice(targets.end(), deferredTargets, it);
617  }
618  } else {
619  // if a cache maintenance operation exists, we promote all the
620  // deferred targets that precede it, or all deferred targets
621  // otherwise
622  targets.splice(targets.end(), deferredTargets,
623  deferredTargets.begin(), it);
624  }
625 
628  order = targets.front().order;
629  readyTime = std::max(curTick(), targets.front().readyTime);
630 
631  return true;
632 }
633 
634 void
635 MSHR::promoteIf(const std::function<bool (Target &)>& pred)
636 {
637  // if any of the deferred targets were upper-level cache
638  // requests marked downstreamPending, need to clear that
639  assert(!downstreamPending); // not pending here anymore
640 
641  // find the first target does not satisfy the condition
642  auto last_it = std::find_if_not(deferredTargets.begin(),
643  deferredTargets.end(),
644  pred);
645 
646  // for the prefix of the deferredTargets [begin(), last_it) clear
647  // the downstreamPending flag and move them to the target list
649  last_it);
650  targets.splice(targets.end(), deferredTargets,
651  deferredTargets.begin(), last_it);
652  // We need to update the flags for the target lists after the
653  // modifications
655 }
656 
657 void
659 {
660  if (!deferredTargets.empty() && !hasPostInvalidate()) {
661  // We got a non invalidating response, and we have the block
662  // but we have deferred targets which are waiting and they do
663  // not need writable. This can happen if the original request
664  // was for a cache clean operation and we had a copy of the
665  // block. Since we serviced the cache clean operation and we
666  // have the block, there's no need to defer the targets, so
667  // move them up to the regular target list.
668 
669  auto pred = [](Target &t) {
670  assert(t.source == Target::FromCPU);
671  return !t.pkt->req->isCacheInvalidate() &&
672  !t.pkt->needsWritable();
673  };
674  promoteIf(pred);
675  }
676 }
677 
678 void
680 {
681  if (deferredTargets.empty()) {
682  return;
683  }
684  PacketPtr def_tgt_pkt = deferredTargets.front().pkt;
687  !def_tgt_pkt->req->isCacheInvalidate()) {
688  // We got a writable response, but we have deferred targets
689  // which are waiting to request a writable copy (not because
690  // of a pending invalidate). This can happen if the original
691  // request was for a read-only block, but we got a writable
692  // response anyway. Since we got the writable copy there's no
693  // need to defer the targets, so move them up to the regular
694  // target list.
695  assert(!targets.needsWritable);
696  targets.needsWritable = true;
697 
698  auto pred = [](Target &t) {
699  assert(t.source == Target::FromCPU);
700  return !t.pkt->req->isCacheInvalidate();
701  };
702 
703  promoteIf(pred);
704  }
705 }
706 
707 
708 bool
710 {
711  // For printing, we treat the MSHR as a whole as single entity.
712  // For other requests, we iterate over the individual targets
713  // since that's where the actual data lies.
714  if (pkt->isPrint()) {
715  pkt->trySatisfyFunctional(this, blkAddr, isSecure, blkSize, nullptr);
716  return false;
717  } else {
718  return (targets.trySatisfyFunctional(pkt) ||
720  }
721 }
722 
723 bool
725 {
726  return cache.sendMSHRQueuePacket(this);
727 }
728 
729 void
730 MSHR::print(std::ostream &os, int verbosity, const std::string &prefix) const
731 {
732  ccprintf(os, "%s[%#llx:%#llx](%s) %s %s %s state: %s %s %s %s %s %s\n",
733  prefix, blkAddr, blkAddr + blkSize - 1,
734  isSecure ? "s" : "ns",
735  isForward ? "Forward" : "",
736  allocOnFill() ? "AllocOnFill" : "",
737  needsWritable() ? "Wrtbl" : "",
738  _isUncacheable ? "Unc" : "",
739  inService ? "InSvc" : "",
740  downstreamPending ? "DwnPend" : "",
741  postInvalidate ? "PostInv" : "",
742  postDowngrade ? "PostDowngr" : "",
743  hasFromCache() ? "HasFromCache" : "");
744 
745  if (!targets.empty()) {
746  ccprintf(os, "%s Targets:\n", prefix);
747  targets.print(os, verbosity, prefix + " ");
748  }
749  if (!deferredTargets.empty()) {
750  ccprintf(os, "%s Deferred Targets:\n", prefix);
751  deferredTargets.print(os, verbosity, prefix + " ");
752  }
753 }
754 
755 std::string
756 MSHR::print() const
757 {
758  std::ostringstream str;
759  print(str);
760  return str.str();
761 }
762 
763 bool
764 MSHR::matchBlockAddr(const Addr addr, const bool is_secure) const
765 {
766  assert(hasTargets());
767  return (blkAddr == addr) && (isSecure == is_secure);
768 }
769 
770 bool
772 {
773  assert(hasTargets());
774  return pkt->matchBlockAddr(blkAddr, isSecure, blkSize);
775 }
776 
777 bool
778 MSHR::conflictAddr(const QueueEntry* entry) const
779 {
780  assert(hasTargets());
781  return entry->matchBlockAddr(blkAddr, isSecure);
782 }
783 
784 void
786 {
787  assert(!targets.empty() && targets.front().pkt == pkt);
788  RequestPtr r = std::make_shared<Request>(*(pkt->req));
789  targets.front().pkt = new Packet(r, MemCmd::LockedRMWReadReq);
790 }
791 
792 bool
794 {
795  if (!targets.empty() &&
796  targets.front().pkt->cmd == MemCmd::LockedRMWReadReq) {
797  return true;
798  }
799  return false;
800 }
801 
802 
803 } // namespace gem5
#define DPRINTF(x,...)
Definition: trace.hh:186
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
A basic cache interface.
Definition: base.hh:96
virtual bool sendMSHRQueuePacket(MSHR *mshr)
Take an MSHR, turn it into a suitable downstream packet, and send it out.
Definition: base.cc:1865
void updateFlags(PacketPtr pkt, Target::Source source, bool alloc_on_fill)
Use the provided packet and the source to update the flags of this TargetList.
Definition: mshr.cc:81
void replaceUpgrades()
Convert upgrades to the equivalent request if the cache line they refer to would have been invalid (U...
Definition: mshr.cc:221
void populateFlags()
Goes through the list of targets and uses them to populate the flags of this TargetList.
Definition: mshr.cc:109
bool trySatisfyFunctional(PacketPtr pkt)
Definition: mshr.cc:263
bool isReset() const
Tests if the flags of this TargetList have their default values.
Definition: mshr.hh:243
void add(PacketPtr pkt, Tick readyTime, Counter order, Target::Source source, bool markPending, bool alloc_on_fill)
Add the specified packet in the TargetList.
Definition: mshr.cc:163
void print(std::ostream &os, int verbosity, const std::string &prefix) const
Definition: mshr.cc:276
void updateWriteFlags(PacketPtr pkt)
Add the specified packet in the TargetList.
Definition: mshr.cc:118
TargetList(const std::string &name=".unnamedTargetList")
Definition: mshr.cc:73
void init(Addr blk_addr, Addr blk_size)
Reset state.
Definition: mshr.hh:202
void clearDownstreamPending()
Definition: mshr.cc:256
Miss Status and handling Register.
Definition: mshr.hh:75
bool postInvalidate
Did we snoop an invalidate while waiting for data?
Definition: mshr.hh:116
TargetList targets
List of all requests that match the address.
Definition: mshr.hh:394
void clearDownstreamPending()
Definition: mshr.cc:333
bool wasWholeLineWrite
Track if we sent this as a whole line write or not.
Definition: mshr.hh:124
void updateLockedRMWReadTarget(PacketPtr pkt)
Replaces the matching packet in the Targets list with a dummy packet to ensure the MSHR remains alloc...
Definition: mshr.cc:785
std::string print() const
A no-args wrapper of print(std::ostream...) meant to be invoked from DPRINTFs avoiding string overhea...
Definition: mshr.cc:756
MSHR(const std::string &name)
A simple constructor.
Definition: mshr.cc:62
void promoteIf(const std::function< bool(Target &)> &pred)
Promotes deferred targets that satisfy a predicate.
Definition: mshr.cc:635
void markInService(bool pending_modified_resp)
Definition: mshr.cc:343
bool downstreamPending
Flag set by downstream caches.
Definition: mshr.hh:87
TargetList extractServiceableTargets(PacketPtr pkt)
Extracts the subset of the targets that can be serviced given a received response.
Definition: mshr.cc:547
bool isPendingModified() const
Definition: mshr.hh:326
bool postDowngrade
Did we snoop a read while waiting for data?
Definition: mshr.hh:119
bool conflictAddr(const QueueEntry *entry) const override
Check if given entry's packets conflict with this' entries packets.
Definition: mshr.cc:778
void promoteReadable()
Promotes deferred targets that do not require writable.
Definition: mshr.cc:658
bool pendingModified
Here we use one flag to track both if:
Definition: mshr.hh:113
void allocate(Addr blk_addr, unsigned blk_size, PacketPtr pkt, Tick when_ready, Counter _order, bool alloc_on_fill)
Allocate a miss to this MSHR.
Definition: mshr.cc:303
TargetList deferredTargets
Definition: mshr.hh:396
bool sendPacket(BaseCache &cache) override
Send this queue entry as a downstream packet, with the exact behaviour depending on the specific entr...
Definition: mshr.cc:724
bool trySatisfyFunctional(PacketPtr pkt)
Definition: mshr.cc:709
bool hasPostDowngrade() const
Definition: mshr.hh:334
bool matchBlockAddr(const Addr addr, const bool is_secure) const override
Check if entry corresponds to the one being looked for.
Definition: mshr.cc:764
bool handleSnoop(PacketPtr target, Counter order)
Definition: mshr.cc:423
bool needsWritable() const
The pending* and post* flags are only valid if inService is true.
Definition: mshr.hh:319
bool isForward
True if the entry is just a simple forward from an upper level.
Definition: mshr.hh:127
bool hasLockedRMWReadTarget()
Determine if there are any LockedRMWReads in the Targets list.
Definition: mshr.cc:793
bool hasFromCache() const
Determine if there are non-deferred requests from other caches.
Definition: mshr.hh:349
bool promoteDeferredTargets()
Definition: mshr.cc:596
bool isWholeLineWrite() const
Check if this MSHR contains only compatible writes, and if they span the entire cache line.
Definition: mshr.hh:406
void allocateTarget(PacketPtr target, Tick when, Counter order, bool alloc_on_fill)
Add a request to the list of targets.
Definition: mshr.cc:376
void promoteWritable()
Promotes deferred targets that do not require writable.
Definition: mshr.cc:679
bool hasPostInvalidate() const
Definition: mshr.hh:330
void deallocate()
Mark this MSHR as free.
Definition: mshr.cc:364
bool allocOnFill() const
Definition: mshr.hh:340
bool hasTargets() const
Returns true if there are targets left.
Definition: mshr.hh:467
@ ReadRespWithInvalidate
Definition: packet.hh:88
@ StoreCondFailReq
Definition: packet.hh:113
@ LockedRMWReadReq
Definition: packet.hh:115
@ SCUpgradeReq
Definition: packet.hh:103
@ SCUpgradeFailReq
Definition: packet.hh:105
@ StoreCondReq
Definition: packet.hh:112
Interface for things with names.
Definition: named.hh:39
virtual std::string name() const
Definition: named.hh:47
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
bool isUpgrade() const
Definition: packet.hh:595
bool isSecure() const
Definition: packet.hh:834
const PacketId id
Definition: packet.hh:373
bool needsWritable() const
Definition: packet.hh:598
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
Definition: packet.cc:368
bool needsResponse() const
Definition: packet.hh:607
void setResponderHadWritable()
On responding to a snoop request (which only happens for Modified or Owned lines),...
Definition: packet.hh:711
Addr getOffset(unsigned int blk_size) const
Definition: packet.hh:824
T * findNextSenderState() const
Go through the sender state stack and return the first instance that is of type T (as determined by a...
Definition: packet.hh:574
bool hasData() const
Definition: packet.hh:613
bool hasRespData() const
Definition: packet.hh:614
bool fromCache() const
Definition: packet.hh:611
bool isWrite() const
Definition: packet.hh:593
bool trySatisfyFunctional(PacketPtr other)
Check a functional request against a memory value stored in another packet (i.e.
Definition: packet.hh:1386
RequestPtr req
A pointer to the original request.
Definition: packet.hh:376
bool isPrint() const
Definition: packet.hh:622
unsigned getSize() const
Definition: packet.hh:815
void setCacheResponding()
Snoop flags.
Definition: packet.hh:651
bool isClean() const
Definition: packet.hh:610
bool isExpressSnoop() const
Definition: packet.hh:700
void setHasSharers()
On fills, the hasSharers flag is used by the caches in combination with the cacheResponding flag,...
Definition: packet.hh:683
bool matchBlockAddr(const Addr addr, const bool is_secure, const int blk_size) const
Check if packet corresponds to a given block-aligned address and address space.
Definition: packet.cc:389
void setSatisfied()
Set when a request hits in a cache and the cache is not going to respond.
Definition: packet.hh:747
MemCmd cmd
The command field of the packet.
Definition: packet.hh:371
bool isInvalidate() const
Definition: packet.hh:608
void allocate()
Allocate memory for the packet.
Definition: packet.hh:1354
A queue entry base class, to be used by both the MSHRs and write-queue entries.
Definition: queue_entry.hh:63
bool _isUncacheable
True if the entry is uncacheable.
Definition: queue_entry.hh:77
unsigned blkSize
Block size of the cache.
Definition: queue_entry.hh:119
virtual bool matchBlockAddr(const Addr addr, const bool is_secure) const =0
Check if entry corresponds to the one being looked for.
Addr blkAddr
Block aligned address.
Definition: queue_entry.hh:116
Counter order
Order number assigned to disambiguate writes and misses.
Definition: queue_entry.hh:113
bool inService
True if the entry has been sent downstream.
Definition: queue_entry.hh:110
bool isSecure
True if the entry targets the secure memory space.
Definition: queue_entry.hh:122
Tick readyTime
Tick when ready to issue.
Definition: queue_entry.hh:74
uint64_t FlagsType
Definition: request.hh:100
@ SECURE
The request targets the secure memory space.
Definition: request.hh:186
@ LOCKED_RMW
This request will lock or unlock the accessed memory.
Definition: request.hh:154
@ STRICT_ORDER
The request is required to be strictly ordered by CPU models and is non-speculative.
Definition: request.hh:135
@ UNCACHEABLE
The request is to an uncacheable address.
Definition: request.hh:125
@ PRIVILEGED
This request is made in privileged mode.
Definition: request.hh:137
@ MEM_SWAP
This request is for a memory swap.
Definition: request.hh:158
@ LLSC
The request is a Load locked/store conditional.
Definition: request.hh:156
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:204
Declares a basic cache interface BaseCache.
Miss Status and Handling Register (MSHR) declaration.
Bitfield< 23, 0 > offset
Definition: types.hh:144
Bitfield< 5 > r
Definition: pagetable.hh:60
Bitfield< 1 > s
Definition: pagetable.hh:64
Bitfield< 51 > t
Definition: pagetable.hh:56
Bitfield< 17 > os
Definition: misc.hh:810
Bitfield< 3 > addr
Definition: types.hh:84
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition: mem.hh:109
double Counter
All counters are of 64-bit values.
Definition: types.hh:47
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
uint64_t Tick
Tick count type.
Definition: types.hh:58
static void replaceUpgrade(PacketPtr pkt)
Definition: mshr.cc:189
void ccprintf(cp::Print &print)
Definition: cprintf.hh:130
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
const std::string & name()
Definition: trace.cc:49

Generated on Wed Dec 21 2022 10:22:36 for gem5 by doxygen 1.9.1