mem: Make cache terminology easier to understand
Review Request #3254 - Created Dec. 9, 2015 and submitted
Information | |
---|---|
Andreas Hansson | |
gem5 | |
default | |
Reviewers | |
Default | |
Changeset 11281:9538423eb53b --------------------------- mem: Make cache terminology easier to understand This patch changes the name of a bunch of packet flags and MSHR member functions and variables to make the coherency protocol easier to understand. In addition the patch adds and updates lots of descriptions, explicitly spelling out assumptions. The following name changes are made: * the packet memInhibit flag is renamed to cacheResponding * the packet sharedAsserted flag is renamed to hasSharers * the packet NeedsExclusive attribute is renamed to NeedsWritable * the packet isSupplyExclusive is renamed responderHadWritable * the MSHR pendingDirty is renamed to pendingModified The cache states, Modified, Owned, Exclusive, Shared are also called out in the cache and MSHR code to make it easier to understand.
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+515 -366) |
Perhaps I'm the one person in the universe that didn't find the old names all that confusing, so I may be the wrong person to review this change. Nevertheless, here I am. There are only two major things that seem off to me:
- Calling setNonWritable() but then checking passWritable() seems awkward to me, both because "non-writable" seems like a clunky synonym for "read only", and because "pass" is a verb where the other attributes are more of a property/predicate. How about setReadOnly/isWritable? I personally think "shared" is reasonable to use, since (as the comment you added on lines 541-545 of packet.hh indicates), the receiver consistently sets the block state to Shared if the shared flag is set. So I'd be happy with a change to setShared/isShared as well, or even (if you want to avoid '!'s) a trio of setShared/isShared/isWritable.
- There are a few places where the comments imply that when a responding cache has an Owned block, the requester always ends up in Modified, but I believe that's only the case when the requester set needsWritable(). I call these places out specifically below.
-
src/mem/cache/base.hh (Diff revision 2) -
should this be pending_writable_resp to be parallel with the pendingWritable MSHR flag? Or perhaps the MSHR flag should be pendingModified? I think it's all the same... by the time we're done with the block, it will be writable and dirty -> modified. Note that in the one case where we request a writable copy and don't write it (on a failed store conditional) we mark it dirty anyway just to keep ourselves sane.
-
src/mem/cache/blk.hh (Diff revision 2) -
The way I think of this is that Exclusive means this cache has the only copy at this level of the hierarchy, i.e., there may be copies in caches above this cache (in various states), but there are no peers that have copies on this branch of the hierarchy, and no caches at or above this level on any other branch have copies either. If there are any other caches below this cache that have copies, those caches are between this cache and memory, and also have the block in Exclusive state... I think that kinda transitively follows from the above definition.
Not sure if you find that useful enough to work into your comment or not...
-
src/mem/cache/cache.hh (Diff revision 2) -
see above
-
src/mem/cache/cache.cc (Diff revision 2) -
see above
-
src/mem/cache/cache.cc (Diff revision 2) -
as below, this only applies if the request had needsWritable() set, correct? which I think is not necessarily the case at this point...
-
src/mem/cache/cache.cc (Diff revision 2) -
the snoop response is always dirty, even if I didn't request a writable copy?
-
src/mem/cache/cache.cc (Diff revision 2) -
maybe 'pending_writable_resp'?
-
src/mem/coherent_xbar.cc (Diff revision 2) -
might as well fix 'remeber' typo while you're here
-
src/mem/mem_checker_monitor.cc (Diff revision 2) -
string might seem vague w/o context, something like
"Forwarded request marked for cache response"
might be clearer -
src/mem/packet.hh (Diff revision 2) -
In the case where the responder had the block in Owned state, the block ends up as writable only if the requester required a writable copy. This comment implies that a requester always ends up with a writable copy whenever it receives a block from a cache that had it in Owned state.
-
src/mem/packet.hh (Diff revision 2) -
"suppress"
-
src/mem/packet.hh (Diff revision 2) -
Firstly
-
src/mem/packet.hh (Diff revision 2) -
is
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+522 -366) |
Just a few comments on your updated comments...
-
src/mem/cache/blk.hh (Diff revisions 2 - 3) -
could add "i.e., only one cache owns the block, or equivalently has the BlkDirty bit set". Makes a lot more sense to me if you think of M & O as ownership states.
-
src/mem/cache/cache.cc (Diff revisions 2 - 3) -
this comment (and the identical one below) seem less helpful because they don't explain why anyone cares... seems like it would be better to say that this is an optimization to avoid unnecessary invalidations, or perhaps better to leave/expand the single more elaborate comment in packet.hh and avoid having redundant comments everywhere this method is called
-
src/mem/cache/cache.cc (Diff revisions 2 - 3) -
again, this phrasing seems off; we're not passing the block as writable, and we're not relying on other caches to do things based on needsWritable... the other caches are simply obeying the obvious meaning of the isInvalidate flag, which means the requester ends up with a writable copy regardless of what we send it.
-
src/mem/packet.hh (Diff revisions 2 - 3) -
I find the description from here on down confusing. The owner is not passing the block as writable, the owner is just passing the block data along with ownership. (How can it "pass" writability when it didn't have it to begin with?) The writability comes from the fact that needsWritable -> isInvalidate, so all other copies are also invalidated as a side effect of the request.
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+544 -369) |
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 5 (+554 -375) |
Thanks!!! This looks great. I really appreciate all your effort and your flexibility.
I'm totally happy with all the code changes; this review is just wordsmithing (and spell checking :) ) on the comments...
-
src/mem/cache/cache.cc (Diff revision 5) -
upstream
-
src/mem/cache/cache.cc (Diff revision 5) -
sharers
-
src/mem/cache/cache.cc (Diff revision 5) -
unnecessary
-
src/mem/cache/cache.cc (Diff revision 5) -
invalidate
-
src/mem/cache/cache.cc (Diff revision 5) -
the scope of the "not" is a little ambiguous... I'd say "and should end up in the Shared state" to be clear
-
src/mem/cache/cache.cc (Diff revision 5) -
for
-
src/mem/cache/mshr.cc (Diff revision 5) -
is "dubious" the right term? It's correct to say that we know we'll end up with a dirty line here. It's just incorrect to assume that, if we're not here, that means we won't get a writable copy, but I think that's irrelevant.
-
src/mem/cache/mshr.cc (Diff revision 5) -
"a writable"
-
src/mem/packet.hh (Diff revision 5) -
I don't believe we ever pass dirty unless the block is becoming writable as well. That is, on a non-needsExclusive request that hits an O (not M) block, cacheResponding() will be set but dirty will not be passed.
In general, it seems redundant to have comments here on the constants as well as on the accessors, which potentially leads to confusion when the comments aren't consistent. It might be better to have just single-phrase descriptions here with pointers to the accessors rather than trying to be descriptive in both places.
-
src/mem/packet.hh (Diff revision 5) -
I think this comment (staring at "Note that...") is a little confusing, esp. in light of the following paragraph. Maybe start with what happens when hasSharers is set, then say that if hasSharers is not set, then the responder is passing the dirty copy, and because the responder either had the block writable to begin with or all other copies have been invalidated, the requester always ends up with a Modified rather than Owned copy.
-
src/mem/packet.hh (Diff revision 5) -
I'd say "on responding to a snooped request"... "providing a snoop response" sounds like you could just be talking about setting the hasSharers() bit.
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 6 (+539 -375) |
THanks again!