]> www.infradead.org Git - users/hch/fsqual.git/commitdiff
Add check for data in page cache
authorAvi Kivity <avi@scylladb.com>
Tue, 1 Mar 2016 17:47:04 +0000 (19:47 +0200)
committerAvi Kivity <avi@scylladb.com>
Tue, 1 Mar 2016 17:47:04 +0000 (19:47 +0200)
fsqual.cc

index e51d90b23a41891d6292ba810a4532b332584a32..acf9913e4c8c623413c56e5f3a795630c326503a 100644 (file)
--- a/fsqual.cc
+++ b/fsqual.cc
@@ -6,6 +6,7 @@
 #include <libaio.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <sys/mman.h>
 #include <fcntl.h>
 #include <iostream>
 #include <unistd.h>
@@ -14,6 +15,7 @@
 #include <functional>
 #include <vector>
 #include <algorithm>
+#include <stdint.h>
 
 template <typename Counter, typename Func>
 typename std::result_of<Func()>::type
@@ -67,6 +69,12 @@ void test_concurrent_append(io_context_t ioctx, int fd, unsigned iodepth) {
     auto verdict = rate < 0.1 ? "GOOD" : "BAD";
     std::cout << "context switch per appending io (iodepth " << iodepth << "): " << rate
           << " (" << verdict << ")\n";
+    auto ptr = mmap(nullptr, nr * 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+    auto incore = std::vector<uint8_t>(nr);
+    mincore(ptr, nr * 4096, incore.data());
+    if (std::any_of(incore.begin(), incore.end(), [] (uint8_t m) { return m & 1; })) {
+        std::cout << "Seen data in page cache (BAD)\n";
+    }
 }
 
 void test_append(io_context_t ioctx, int fd) {