Questions about atomicity and ordering of raw nvm write

60 views
Skip to first unread message

王涛

unread,
Nov 9, 2017, 10:50:15 PM11/9/17
to pmem
Hi,
I'm looking forward to efficient, consistent(both atomic and in-order) chunck write on nvm. I have two questions to consult:

1. Is there any basic level atomicity on nvm? I have seen some papers saw nvm has atomic 8 byte writes. Is it true? If it's true, how does the 8-bytes come? It's due to a single 8-bytes store instruction of atomicity, or some otherwise reasons?

2. Is there any write patterns which can guarantee persistence order in practice? I know the main reason of out-of-order persistence is cache eviction. But if I ensure all writes in the same cache line? For example, for this codes:

void *addr = pmem_map_file(...); // addr is page size aligned
int* p = addr;
p[0] = 1;
p[1] = 2;

I'm wondering, if a power fail occurs, the result can be either p[0] = 0, p[1] = 0, or p[0] = 1, p[1] = 2, or p[0] = 1, p[1] = 0, but never be p[0] = 0, p[1] = 2. Is it true?

Thanks very much,
Tao

Andy Rudoff

unread,
Nov 10, 2017, 10:36:10 AM11/10/17
to pmem
Hi Tao,

The word "atomic" is not specific enough.  For visibility atomicity, that is, what another thread can see, the instruction set has a number of atomic operations.  AVX512 includes an atomic 64-byte store.  But for power fail atomicity, that is, the size of a store that cannot be torn by a power failure or similar interruption, the only size that is currently architecturally guaranteed to be failure atomic is 8-bytes or smaller (and aligned).  Under these current constraints, whenever we want something larger than 8-bytes to be failure atomic, we build it in software -- that's what the NVM Libraries do, they provide larger atomics built from the 8-byte failure atomicity.

Very specific "would this work" questions come up now and then, like what you've asked, but the answer is that it may work on some models of the Intel CPU, but that's not the same thing as being architecturally guaranteed.  To make the guarantee, Intel would have to be ready to commit to it across the product line and for future generations.  So we are looking at ways to provide larger failure atomicity in coming CPUs, in a way that we can commit to supporting forever.  But for now, the 8-byte failure atomicity is the only thing that is guaranteed.

-andy

王涛

unread,
Nov 13, 2017, 4:05:37 AM11/13/17
to pmem
OK, thanks for your patience~

在 2017年11月10日星期五 UTC+8下午11:36:10,Andy Rudoff写道:
Reply all
Reply to author
Forward
0 new messages