Questions tagged [mesi]

The MESI protocol (known also as Illinois protocol) is a cache coherence and memory coherence protocol.

The MESI protocol (known also as Illinois protocol) is a cache coherence and memory coherence protocol. It or an extension like MESIF or MOESI is used nearly universally in multi-core CPUs and SMP systems.

http://en.wikipedia.org/wiki/MESI_protocol

MESI requires a core to take exclusive ownership of a cache line before writing to it, preventing multiple cores from storing conflicting values, or even from reading stale values.

(Cache itself is not the source of memory reordering: that's usually store buffers within individual cores. And on weakly-ordered ISAs, out-of-order execution of loads. See Does a memory barrier ensure that the cache coherence has been completed? no, cache is always coherent. A memory barrier waits for the store buffer to drain. It's a common misconception that stores make cache non-coherent and then barriers flush it manually.)

Relevant Q&As:

  • Can num++ be atomic for 'int num'? explains how atomic RMW operations are typically implemented in modern x86, by holding a cache line in Modified state between the load and store, not responding to Invalidate or RFOs until after the atomic transaction.
61 questions
2
votes
1 answer

Is mesi cache coherence protocol applicable for single processor with 2 logical cores?

I am using Intel Atom Processor (Genuine Intel (R) CPU). I have done cat/proc/cpuinfo. It is showing two processors but for physical and core id, it is showing 0. I did grep "^core id" /proc/cpuinfo | sort -u | wc -l to find no of cpu cores. It is…
1
vote
1 answer

optimal to flush low-contention atomic from caches?

If I have some atomic variable which is accessed relatively infrequently (low contention) is accessed uniformly at random by threads/cores (i.e. if thread A writes to the variable, with high likelihood it is not A which next accesses the…
ajp
  • 1,723
  • 14
  • 22
1
vote
1 answer

How is message queue implemented in cache coherence protocol?

In Paul McKenny's famous paper "Memory Barriers: A Hardware View for Software Hackers" 3.3 Store Buffers and Memory Barriers To see the second complication, a violation of global memory ordering, consider the following code sequences with variables…
Weipeng
  • 1,494
  • 14
  • 11
1
vote
0 answers

Shortcomings of cache coherence alternative

I am trying to understand why cache coherence protocols are designed the way they are. The goal of the cache coherence is to serialize reads/writes to a particular memory location across all cores. Suppose, writes to memory location A is serialized…
driewguy
  • 35
  • 3
1
vote
0 answers

Cache coherence state machine

Let's say we have a multi core machine. Core 1 tries to write to variable X, it doesn't have that variables cache line in its L1d cache so it broadcasts a RFO . In the mean time, it writes the store into the store buffer in core 1 as it didn’t get…
PYA
  • 8,096
  • 3
  • 21
  • 38
1
vote
2 answers

MESI protocol - what keeps cache line in exclusive mode during atomic operations

I am reading a bit about the MESI protocol for cache coherance. I have read that atomic operations in x86-64 such as XCHG acqure the cache line in exclusive mode. But according to the protocol, the cache line can transition to share or invalid state…
Thanuja Dilhan
  • 137
  • 2
  • 10
1
vote
1 answer

Is synchronization faster on the same physical CPU core?

I have a question. If a thread modifies a variable, will the thread on the same physical core (a different hyperthread core) see the modification earlier than other cores? Or it has to wait until all the other cores see it? I've been trying to pin…
1
vote
0 answers

How is coherence implemented in multi-level caches?

I have understood how the cache coherence FSM works for single private L1 cache and a common LLC/memory. But couldn't find good resources where they discuss about cache coherence when there are 2 private caches - L1 and L2 and a common memory. I…
1
vote
1 answer

Advantage of the Exclusive state in MESI?

I understand that with MSI, if we have a piece of memory in shared state, even if no one else uses it, we would have to broadcast that we are moving to modified. This is a problem that MESI fixes. However, when we do use MESI, when moving from…
Maoepr3n
  • 13
  • 3
1
vote
1 answer

x86 MESI invalidate cache line latency issue

I have the following processes , I try to make ProcessB very low latency so I use tight loop all the time and isolate cpu core 2 . global var in shared memory : int bDOIT ; typedef struct XYZ_ { int field1 ; int field2 ; ..... int…
barfatchen
  • 1,630
  • 2
  • 24
  • 48
1
vote
1 answer

MESI protocol. Write with cache miss, but cache line copy exists on another CPU. Why needs fetch from main memory?

According to this diagram in case of write cache miss with copy in another CPU cache (for example Shared/Exclusive state). The steps are: 1. Snooping cores (with cache line copy) sets state to Invalid. 2. Current cache stores fresh main memory…
Alex
  • 43
  • 4
1
vote
1 answer

Why can't be provided a direct access from one processor to the cache of another processor?

In NUMA architecture (Non-uniform memory access) each processor has it's own first level cache, so there's a protocol (MESI) for processor communication. But why can't each processor be connected to other's caches directly? I read that "The…
user1289
  • 1,251
  • 2
  • 13
  • 25
1
vote
1 answer

Write buffer reaction on MESI-induced messages

Suppose we have the following situation: 2 CPU wtih write buffers and MESI is used as the cache coherence protocol. And we have one shared cache line between the CPUs: CPU1 cache: |I|I|S|I|I| CPU2 cache: |I|I|S|I|I| Now CPU1 decides to modify the…
ixSci
  • 13,100
  • 5
  • 45
  • 79
1
vote
1 answer

MESI-protocol and the LRU-strategy

I have read quite some literature about the MESI-protocol and its application for keeping caches consistent but there are two details I can't quite figure out: When using the MESI-protocol for keeping multiple caches synchronized and applying a…
vin
  • 13
  • 3
1
vote
1 answer

MESI protocol in cache conherence

I have a question on MESI protocol. (1)Consider the following code fragment that runs on a uniprocessor system that Implements the MESI cache coherence protocol: I1: load $s1, [A] I2: load $s2, [B] I3: add $s1, $s2, $s3 I4: store $s3, [C] I5:…