ARM single-copy atomicity
Asked Answered
P

1

3

I am currently wading through the ARM architecture manual for the ARMv7 core. In chapter A3.5.3 about atomicity of memory accesses, it states:

If a single-copy atomic load overlaps a single-copy atomic store and for any of the overlapping bytes the load returns the data written by the write inserted into the Coherence order of that byte by the single-copy atomic store then the load must return data from a point in the Coherence order no earlier than the writes inserted into the Coherence order by the single-copy atomic store of all of the overlapping bytes.

As non-native english speaker I admit that I am slightly challenged in understanding this sentence.

Is there a scenario where writes to a memory byte are not inserted in the Coherence Order and thus the above does not apply? If not, am I correct to say that shortening and rephrasing the sentence to the following:

If the load happens to return at least one byte of the the write, then the load must return all overlapping bytes from a point no earlier than where the write inserted them into the Coherence order of all of the overlapping bytes.

still transports the same meaning?

Philippic answered 3/6, 2014 at 8:57 Comment(2)
That is my understanding as well. I feel your pain; reading this makes my head spin. I am not sure this is a good SO question, but it is a good question. Anyways, there are many academic papers where people take paragraphs and paragraphs to make a simple point. Probably an important issue is to keep things aligned. For example, strb to bytes 0,1,2,3 and ldr on the full word should behave similar. I think that is the single-copy atomic bit. A ldr to addr+2 will not be single-copy atomic. Ie, an unaligned read.Toronto
@Vroomfondel, this is a pretty confusing topic and being a native English speaker does NOT make that sentence clear to me either. Additionally, since you and I were both referencing the exact same section of the Technical Reference Manual (A3.5.3) for the same mcu family, I wanted to post my related Q&A here too, as I think it's very relevant to the discussion: #52785113.Pyrology
S
5

I see that wording in the ARMv8 ARM, which really tries to remove any possible ambiguity in a lot of places (even if it does make the memory ordering section virtually unreadable).

In terms of general understanding (as opposed to to actually implementing the specification), a little bit of ambiguity doesn't always hurt, so whilst it fails to make it absolutely clear what a "memory location" means, I think the old v7 manual (DDI0406C.b) is a nicer read in this case:

A read or write operation is single-copy atomic if the following conditions are both true:

  • After any number of write operations to a memory location, the value of the memory location is the value written by one of the write operations. It is impossible for part of the value of the memory location to come from one write operation and another part of the value to come from a different write operation

  • When a read operation and a write operation are made to the same memory location, the value obtained by the read operation is one of:

    • the value of the memory location before the write operation
    • the value of the memory location after the write operation.

    It is never the case that the value of the read operation is partly the value of the memory location before the write operation and partly the value of the memory location after the write operation.

So your understanding is right - the defining point of a single-copy atomic operation is that at any given time you can only ever see either all of it, or none of it.

There is a case in v7 whereby (if I'm interpreting it right) two normally single-copy atomic stores that occur to the same location at the same time but with different sizes break any guarantee of atomicity, so in theory you could observe some unexpected mix of bytes there - this looks to have been removed in v8.

Shawnshawna answered 3/6, 2014 at 22:47 Comment(1)
And when you get to multi-copy atomicity, it helps to bear in mind that it's rather misleadingly named and has virtually nothing whatsoever to do with this sense of "atomicity".Shawnshawna

© 2022 - 2024 — McMap. All rights reserved.