I'm not sure I understand your example code (does memset even pay attention to bytes above 0xff in the second arg?). But I think I can still answer your question.
Regardless of what causes the 8-byte aligned value to get sent to memory, whether it is eviction due to other system activity, or a single cache flush instruction, or a range being flushed, the x86 hardware will not tear it due to power failure. A bunch of stores to pmem without flushes and fences between them may become persistent in any order, perhaps all of them persistent before you get around to calling flush, perhaps none of them, are any combination. But the 8-byte chunks sent to memory won't be torn.Hopefully that answered your question.
On Oct 30, 2020, at 6:52 PM, Christian Schwarz <m...@cschwarz.com> wrote:[Caution: Email from External Sender. Do not click or open links or attachments unless you know this sender.]
--
You received this message because you are subscribed to the Google Groups "pmem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pmem+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pmem/e6744be7-494a-44a4-924a-625dd7033078n%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "pmem" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pmem/6_5daOuEI00/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pmem+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pmem/7f8e1ec5-344d-4ce7-a20d-a585f6b46950n%40googlegroups.com.
- “The pmem_persist() function force any changes in the range [addr, addr+len) to be stored durably in persistent memory.”
- “Any unwritten stores in the given range will be written, but some stores may have already been written by virtue of normal cache eviction/replacement policies.”
So, if any crash happen within your variant-1’s for loop, it could be possible that some data in *pmem is persisted (cache evicted by virtue of normal cache eviction/replacement policies). And that would be an inconsistent state. But, it is guaranteed that after your pmem_persist() call, all the data within this range is persisted.
My question is, during the flush, can only a part of the cache line be written to the PM if a crash occurs? (during flush, before the drain)Excuse me if the question makes no sense in case that I have understood something wrong.
Hello Andy,thanks for your immediate response.My second question mostly has to do with the process followed in order to be sure that data becomes persistent.To be more specific:The pmem_memcpy_persist function is a pmem_memcpy which copies the data,followed by pmem_persist (pmem_flush & pmem_drain) to flush data and make sure that they reach the persistent domain.Without the call of pmem_persist, we cannot be sure that our data is durable.
In a simple scenario, we modify a single cache line (64 bytes).The pmem_memcpy function is completed successfully.Then, the pmem_flush is called.My question is, during the flush, can only a part of the cache line be written to the PM if a crash occurs? (during flush, before the drain)Excuse me if the question makes no sense in case that I have understood something wrong.
@andy Would the following sentence be an appropriate addition to the pmem_mem*() man pages?> pmem_mem*(dst, ...) guarantees that, if dst is 8 byte aligned, the individual 8 byte chunks of dst will be updated powerfail atomically.Or even:> pmem_mem*(dst, ...) guarantees that those segments of dst that are 8 byte sized and 8 byte aligned will be updated powerfail atomically.
Also, I have to admit, I don't see the need for the distinction you've mentioned about 8-byte chunks of a larger update. To me, the statement that 8-byte aligned stores are not torn is the architectural guarantee.