3

I came across following question, while reading the slides of a lecture about cache coherency protocols: Which MESI states are relevant, if cache with write-through policy is used?

The answer was also given: I (Invalid) and S (Shared Unmodified).

I understand that the state M (Modified Exclusive) is not relevant, since cache with write-through policy propagates the changes to main memory anyway.

The state E (Exclusive Unmodified) is not relevant, since it's only issued when exclusive read misses with replacement occur (and is kept with further read hits).

Can someone explain the given answer?

mike
  • 4,929
  • 4
  • 40
  • 80

1 Answers1

2

As you mentioned, M state is pretty obviously useless since you never keep modified data in your cache.

As for Exclusive state: keep in mind that in some sense it's "stronger" than shared state, since in WB caches, it guarantees that a write to that line doesn't need to obtain ownership and invalidate other copies first, and instead can write directly to that line without having to go out of the local cache. In other words, the transition from E to M is simple, while S to M is more complicated and requires invalidating all other copied first.

On the other hand, in a WT cache you already have the guarantee that no one else is holding a modifies version of the line, and more importantly - you don't have the benefit of doing the simple transition in your local cache (since you have to write the data outside anyway), so there's really no need for an exclusive state - you gain no benefit from having it. In fact, you may actually lose from it, because having an E state forces you to send snoops on any other core reading the same line (E -> S transition),

Of course, when writing something outside, you'll still need to invalidate all other copies, but you don't need the distinction between E and S to tell you if they exist, usually there's a snoop filter or some other list to tell you which cores to snoop.

Leeor
  • 19,260
  • 5
  • 56
  • 87
  • Thx for the answer. The exclusive states are dropped, but even if the cache writes through the changes directly, in order to read properly, i.e. decide when to read from cache or from main memory, the distinction between invalid and valid cache lines still has to be made - this leaves **I** and **S** as only relevant states. – mike Aug 01 '15 at 13:17
  • I am not entirely convinced that the exclusive state is useless in a write-through cache. Being able to commit writes immediately could have some advantages. Also writes to (exclusive) cache hits (remote invalidations would not be required) are probably more common than read misses where a remote node has the data in exclusive state. Furthermore, such a read miss might well want to request the data from that cache anyway for bandwidth or latency reasons. Memory consistency would seem to further complicate the tradeoffs (exclusive writes could be buffered aggressively [b/w & latency]). –  Jan 25 '16 at 20:22