243
51
fd = open("/mnt/pmem/file", O_CREAT|O_RDWR, 0666);
52
posix_fallocate(fd, 0, sizeof(int));
53
54
data = (int *)mmap(NULL, sizeof(int),
55
PROT_READ | PROT_WRITE,
56
MAP_SHARED_VALIDATE | MAP_SYNC,
57
fd, 0);
58
59
VALGRIND_PMC_REGISTER_PMEM_MAPPING(data,
60
sizeof(int));
61
62
*data = 1234;
63
flush((void *)data, sizeof(int));
64
flush((void *)data, sizeof(int)); // extra flush
65
66
munmap(data, sizeof(int));
67
VALGRIND_PMC_REMOVE_PMEM_MAPPING(data,
68
sizeof(int));
69
return 0;
70 }
We can use pmemcheck to detect redundant flushes using --flush-check=yes option,
as shown in Listing 12-34.
Listing 12-34. Running pmemcheck with Listing 12-33
$ valgrind --tool=pmemcheck --flush-check=yes ./listing_12-33
==104125== pmemcheck-1.0, a simple persistent store checker
==104125== Copyright (c) 2014-2016, Intel Corporation
==104125== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==104125== Command: ./listing_12-33
==104125==
==104125==
==104125== Number of stores not made persistent: 0
==104125==
Chapter 12 Debugging persistent MeMory appliCations
Précédent

- 267/457

Suivant