Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions runtime/test/xmem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,9 @@ void test_split_under_reader(const PhysicalApi& api) {
++reads;
}
});
// On a loaded host (ctest -j) the 2,046 splits can finish before the reader is first scheduled: reads stayed 0
// and the check below failed, with nothing wrong in xmem. Split only once the reader is reading.
while (reads.load() == 0) Sleep(0);
bool unmapped = true;
for (uint64_t k = 0; k < kPages - 1; ++k) {
if (k == 1023) continue;
Expand All @@ -1675,6 +1678,8 @@ void test_split_under_reader(const PhysicalApi& api) {
reader.join();
check(unmapped, "2,046 pages unmap one at a time, each splitting the view a reader is in");
check(reads.load() > 0 && wrong.load() == 0, "the reader of the views' last pages never faults or misreads");
std::printf("split reader: %llu reads, %llu misread\n", static_cast<unsigned long long>(reads.load()),
static_cast<unsigned long long>(wrong.load()));
// The last split was of [2046, 2048): a fault there is retried, one on another mapped page is not.
api.map(window, kPages, nullptr);
api.free_pages(kPages, pages.data());
Expand Down
3 changes: 3 additions & 0 deletions runtime/test/xs_proxy_mock_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4480,6 +4480,9 @@ int check_list_values_more() {
VirtualFree(read_only, 0, MEM_RELEASE);
const HANDLE reader = CreateThread(nullptr, 0, &tear_reader, nullptr, 0, nullptr);
EXPECT(reader);
// On a loaded host (ctest -j) the 200,000 stores can finish before the reader is first scheduled: reads stayed 0
// and the check below failed with no torn write. Store only once the reader is reading.
while (reader && g_tear.reads.load() == 0) Sleep(0);
for (int i = 0; i < 200000; ++i) leonida::kernel_writes::store(&g_tear.cell, (i & 1) ? ~0ull : 0, 8);
g_tear.stop = true;
WaitForSingleObject(reader, INFINITE);
Expand Down