@@ -1003,36 +1003,43 @@ bool ZPartition::prime(ZWorkers* workers, size_t size) {
10031003 return true ;
10041004 }
10051005
1006+ ZArray<ZVirtualMemory> vmems;
1007+
10061008 // Claim virtual memory
1007- const ZVirtualMemory vmem = claim_virtual (size);
1009+ const size_t claimed_size = claim_virtual (size, &vmems);
1010+
1011+ // The partition must have size available in virtual memory when priming.
1012+ assert (claimed_size == size, " must succeed %zx == %zx" , claimed_size, size);
10081013
10091014 // Increase capacity
1010- increase_capacity (size );
1015+ increase_capacity (claimed_size );
10111016
1012- // Claim the backing physical memory
1013- claim_physical (vmem);
1017+ for (ZVirtualMemory vmem : vmems) {
1018+ // Claim the backing physical memory
1019+ claim_physical (vmem);
10141020
1015- // Commit the claimed physical memory
1016- const size_t committed = commit_physical (vmem);
1021+ // Commit the claimed physical memory
1022+ const size_t committed = commit_physical (vmem);
10171023
1018- if (committed != vmem.size ()) {
1019- // This is a failure state. We do not cleanup the maybe partially committed memory.
1020- return false ;
1021- }
1024+ if (committed != vmem.size ()) {
1025+ // This is a failure state. We do not cleanup the maybe partially committed memory.
1026+ return false ;
1027+ }
10221028
1023- map_virtual (vmem);
1029+ map_virtual (vmem);
10241030
1025- check_numa_mismatch (vmem, _numa_id);
1031+ check_numa_mismatch (vmem, _numa_id);
10261032
1027- if (AlwaysPreTouch) {
1028- // Pre-touch memory
1029- ZPreTouchTask task (vmem.start (), vmem.end ());
1030- workers->run_all (&task);
1031- }
1033+ if (AlwaysPreTouch) {
1034+ // Pre-touch memory
1035+ ZPreTouchTask task (vmem.start (), vmem.end ());
1036+ workers->run_all (&task);
1037+ }
10321038
1033- // We don't have to take a lock here as no other threads will access the cache
1034- // until we're finished
1035- _cache.insert (vmem);
1039+ // We don't have to take a lock here as no other threads will access the cache
1040+ // until we're finished
1041+ _cache.insert (vmem);
1042+ }
10361043
10371044 return true ;
10381045}
0 commit comments