Question

Does it make any sense in flushing the CPU cache manually, if it is implemented as a write-through cache?

Était-ce utile?

La solution

When a word is written at a write-through (WT) cache by a store instruction, it is also sent to the following level of the memory hierarchy (see cache entry at wikipedia). Hence, cache blocks at the WT cache are clean, that is, are coherent with their copies at the next level, and write-backs would not be necessary.

WT invalidations could be required in case of Direct Memory Acceses (DMA) that make cache contents stale, but, as far as I know, these are not manually operations, but OS or hardware driven.

Related to manually flushing, for example, according to the Intel Architecture Software Developer’s Manual (Volume 2, Instruction Set Reference):

WBINVD — Write Back and Invalidate Cache This instruction writes back all modified cache lines in the processor’s internal cache to main memory and invalidates (flushes) the internal caches.

So I think that, in case of a WT cache, this instruction just invalidates all the cache lines.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top