@@ -1313,82 +1313,6 @@ static bool vmo_clone_removes_write_test() {
1313
1313
END_TEST;
1314
1314
}
1315
1315
1316
- static bool vmo_zero_scan_test () {
1317
- BEGIN_TEST;
1318
-
1319
- AutoVmScannerDisable scanner_disable;
1320
-
1321
- auto mem = testing::UserMemory::Create (PAGE_SIZE);
1322
- ASSERT_NONNULL (mem);
1323
-
1324
- const auto & user_aspace = mem->aspace ();
1325
- ASSERT_NONNULL (user_aspace);
1326
- ASSERT_TRUE (user_aspace->is_user ());
1327
-
1328
- // Initially uncommitted, which should not count as having zero pages.
1329
- EXPECT_EQ (0u , mem->vmo ()->ScanForZeroPages (false ));
1330
-
1331
- // Validate that this mapping reads as zeros
1332
- EXPECT_EQ (ZX_OK, user_aspace->SoftFault (mem->base (), 0u ));
1333
- EXPECT_EQ (0 , mem->get <int32_t >());
1334
-
1335
- // Reading from the page should not have committed anything, zero or otherwise.
1336
- EXPECT_EQ (0u , mem->vmo ()->ScanForZeroPages (false ));
1337
-
1338
- // IF we write to the page, this should make it committed.
1339
- EXPECT_EQ (ZX_OK, user_aspace->SoftFault (mem->base (), VMM_PF_FLAG_WRITE));
1340
- mem->put <int32_t >(0 );
1341
- EXPECT_EQ (1u , mem->vmo ()->ScanForZeroPages (false ));
1342
-
1343
- // Check that changing the contents effects the zero page count.
1344
- EXPECT_EQ (ZX_OK, user_aspace->SoftFault (mem->base (), VMM_PF_FLAG_WRITE));
1345
- mem->put <int32_t >(42 );
1346
- EXPECT_EQ (0u , mem->vmo ()->ScanForZeroPages (false ));
1347
- EXPECT_EQ (ZX_OK, user_aspace->SoftFault (mem->base (), VMM_PF_FLAG_WRITE));
1348
- mem->put <int32_t >(0 );
1349
- EXPECT_EQ (1u , mem->vmo ()->ScanForZeroPages (false ));
1350
-
1351
- // Scanning should drop permissions in the hardware page table from write to read-only.
1352
- paddr_t paddr_readable;
1353
- uint mmu_flags;
1354
- EXPECT_EQ (ZX_OK, user_aspace->SoftFault (mem->base (), VMM_PF_FLAG_WRITE));
1355
- mem->put <int32_t >(0 );
1356
- zx_status_t status = user_aspace->arch_aspace ().Query (mem->base (), &paddr_readable, &mmu_flags);
1357
- EXPECT_EQ (ZX_OK, status);
1358
- EXPECT_TRUE (mmu_flags & ARCH_MMU_FLAG_PERM_WRITE);
1359
- mem->vmo ()->ScanForZeroPages (false );
1360
- status = user_aspace->arch_aspace ().Query (mem->base (), &paddr_readable, &mmu_flags);
1361
- EXPECT_EQ (ZX_OK, status);
1362
- EXPECT_FALSE (mmu_flags & ARCH_MMU_FLAG_PERM_WRITE);
1363
-
1364
- // Pinning the page should prevent it from being counted.
1365
- EXPECT_EQ (1u , mem->vmo ()->ScanForZeroPages (false ));
1366
- EXPECT_EQ (ZX_OK, mem->vmo ()->CommitRangePinned (0 , PAGE_SIZE, false ));
1367
- EXPECT_EQ (0u , mem->vmo ()->ScanForZeroPages (false ));
1368
- mem->vmo ()->Unpin (0 , PAGE_SIZE);
1369
- EXPECT_EQ (1u , mem->vmo ()->ScanForZeroPages (false ));
1370
-
1371
- // Creating a kernel mapping should prevent any counting from occurring.
1372
- VmAspace* kernel_aspace = VmAspace::kernel_aspace ();
1373
- void * ptr;
1374
- status = kernel_aspace->MapObjectInternal (mem->vmo (), " test" , 0 , PAGE_SIZE, &ptr, 0 ,
1375
- VmAspace::VMM_FLAG_COMMIT, kArchRwFlags );
1376
- EXPECT_EQ (ZX_OK, status);
1377
- EXPECT_EQ (0u , mem->vmo ()->ScanForZeroPages (false ));
1378
- kernel_aspace->FreeRegion (reinterpret_cast <vaddr_t >(ptr));
1379
- EXPECT_EQ (1u , mem->vmo ()->ScanForZeroPages (false ));
1380
-
1381
- // Actually evict the page now and check that the attribution count goes down and the eviction
1382
- // event count goes up.
1383
- EXPECT_EQ (1u , mem->vmo ()->AttributedPages ().uncompressed );
1384
- EXPECT_EQ (0u , mem->vmo ()->EvictionEventCount ());
1385
- EXPECT_EQ (1u , mem->vmo ()->ScanForZeroPages (true ));
1386
- EXPECT_EQ (0u , mem->vmo ()->AttributedPages ().uncompressed );
1387
- EXPECT_EQ (1u , mem->vmo ()->EvictionEventCount ());
1388
-
1389
- END_TEST;
1390
- }
1391
-
1392
1316
static bool vmo_move_pages_on_access_test () {
1393
1317
BEGIN_TEST;
1394
1318
@@ -2388,18 +2312,6 @@ static bool vmo_attribution_dedup_test() {
2388
2312
EXPECT_EQ (true , verify_object_page_attribution (vmo.get (), expected_gen_count,
2389
2313
AttributionCounts{2u , 0u }));
2390
2314
2391
- // Scan for zero pages, returning only the count (without triggering any reclamation). This should
2392
- // *not* change the generation count.
2393
- ASSERT_EQ (2u , vmo->ScanForZeroPages (false ));
2394
- EXPECT_EQ (true , verify_object_page_attribution (vmo.get (), expected_gen_count,
2395
- AttributionCounts{2u , 0u }));
2396
-
2397
- // Scan for zero pages and reclaim them. This should change the generation count.
2398
- ASSERT_EQ (2u , vmo->ScanForZeroPages (true ));
2399
- ++expected_gen_count;
2400
- EXPECT_EQ (true ,
2401
- verify_object_page_attribution (vmo.get (), expected_gen_count, AttributionCounts{}));
2402
-
2403
2315
END_TEST;
2404
2316
}
2405
2317
@@ -3710,19 +3622,6 @@ static bool vmo_dedup_dirty_test() {
3710
3622
// No committed pages remaining.
3711
3623
EXPECT_EQ (0u , vmo->AttributedPages ().uncompressed );
3712
3624
3713
- // Commit the page again.
3714
- vmo->CommitRange (0 , PAGE_SIZE);
3715
- page = vmo->DebugGetPage (0 );
3716
-
3717
- // The page is still clean.
3718
- EXPECT_TRUE (pmm_page_queues ()->DebugPageIsReclaim (page));
3719
-
3720
- // Zero scan should be able to dedup a clean page.
3721
- EXPECT_TRUE (vmo->ScanForZeroPages (true ));
3722
-
3723
- // No committed pages remaining.
3724
- EXPECT_EQ (0u , vmo->AttributedPages ().uncompressed );
3725
-
3726
3625
// Write to the page making it dirty.
3727
3626
uint8_t data = 0xff ;
3728
3627
status = vmo->Write (&data, 0 , sizeof (data));
@@ -3734,7 +3633,6 @@ static bool vmo_dedup_dirty_test() {
3734
3633
3735
3634
// We should not be able to dedup the page.
3736
3635
EXPECT_FALSE (vmo->DebugGetCowPages ()->DedupZeroPage (page, 0 ));
3737
- EXPECT_FALSE (vmo->ScanForZeroPages (true ));
3738
3636
EXPECT_EQ (1u , vmo->AttributedPages ().uncompressed );
3739
3637
3740
3638
END_TEST;
@@ -3766,7 +3664,6 @@ VM_UNITTEST(vmo_lookup_test)
3766
3664
VM_UNITTEST (vmo_lookup_slice_test)
3767
3665
VM_UNITTEST (vmo_lookup_clone_test)
3768
3666
VM_UNITTEST (vmo_clone_removes_write_test)
3769
- VM_UNITTEST (vmo_zero_scan_test)
3770
3667
VM_UNITTEST (vmo_move_pages_on_access_test)
3771
3668
VM_UNITTEST (vmo_eviction_hints_test)
3772
3669
VM_UNITTEST (vmo_always_need_evicts_loaned_test)
0 commit comments