diff --git a/runtime/test/xmem_test.cpp b/runtime/test/xmem_test.cpp index 991388c7f5..e19537cf28 100644 --- a/runtime/test/xmem_test.cpp +++ b/runtime/test/xmem_test.cpp @@ -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; @@ -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(reads.load()), + static_cast(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()); diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index 27af09aec3..3a96d64e35 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -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);