242
pmemcheck reports that we have overwritten stores. We can fix this problem by either
inserting a flushing instruction between both writes, if we forgot to flush, or by moving
one of the stores to volatile data if that store corresponds to short-lived data.
At the time of publication, Persistence Inspector does not support checking for
overwritten stores. As you have seen, Persistence Inspector does not consider a missing
flush an issue unless there is a write dependency. In addition, it does not consider this a
performance problem because writing to the same variable in a short time span is likely
to hit the CPU caches anyway, rendering the latency differences between DRAM and
persistent memory irrelevant.
Unnecessary Flushes
Flushing should be done carefully. Detecting unnecessary flushes, such as redundant
ones, can help improve code performance. The code in Listing 12-33 shows a redundant
call to the flush() function on line 64.
Listing 12-33. Example of redundant flushing of a persistent memory variable
33 #include
34 #include
35 #include
36 #include
37 #include
38 #include
39
40 void flush(const void *addr, size_t len) {
41
uintptr_t flush_align = 64, uptr;
42
for (uptr = (uintptr_t)addr & ~(flush_align - 1);
43
uptr < (uintptr_t)addr + len;
44
uptr += flush_align)
45
_mm_clflush((char *)uptr);
46 }
47
48 int main(int argc, char *argv[]) {
49
int fd, *data;
50
Chapter 12 Debugging persistent MeMory appliCations
Précédent

- 266/457

Suivant