@@ -463,7 +463,13 @@ bool ZPageAllocator::prime_cache(ZWorkers* workers, size_t size) {
463463 return false ;
464464 }
465465
466- map_virtual_to_physical (vmem);
466+ map_virtual_to_physical (vmem, numa_id);
467+
468+ // Memory should have ended up on the desired NUMA id, if that's not the case, print error.
469+ int actual = ZNUMA::memory_id (untype (ZOffset::address (vmem.start ())));
470+ if (actual != numa_id) {
471+ log_debug (gc, heap)(" NUMA Mismatch (priming): desired %d, actual %d" , numa_id, actual);
472+ }
467473
468474 if (AlwaysPreTouch) {
469475 // Pre-touch memory
@@ -638,9 +644,9 @@ void ZPageAllocator::uncommit_physical(const ZMemoryRange& vmem) {
638644 _physical.uncommit (_physical_mappings.get_addr (vmem.start ()), vmem.size ());
639645}
640646
641- void ZPageAllocator::map_virtual_to_physical (const ZMemoryRange& vmem) {
647+ void ZPageAllocator::map_virtual_to_physical (const ZMemoryRange& vmem, int numa_id ) {
642648 // Map virtual memory to physical memory
643- _physical.map (vmem.start (), _physical_mappings.get_addr (vmem.start ()), vmem.size ());
649+ _physical.map (vmem.start (), _physical_mappings.get_addr (vmem.start ()), vmem.size (), numa_id );
644650}
645651
646652void ZPageAllocator::unmap_virtual (const ZMemoryRange& vmem) {
@@ -677,9 +683,10 @@ void ZPageAllocator::remap_and_defragment_mapping(const ZMemoryRange& vmem, ZArr
677683
678684 // The entries array may contain entires from other defragmentations as well,
679685 // so we only operate on the last ranges that we have just inserted
686+ int numa_id = _virtual.get_numa_id (vmem);
680687 for (int idx = entries->length () - num_ranges; idx < entries->length (); idx++) {
681688 ZMemoryRange v = entries->at (idx);
682- map_virtual_to_physical (v);
689+ map_virtual_to_physical (v, numa_id );
683690 pretouch_memory (v.start (), v.size ());
684691 }
685692}
@@ -897,7 +904,7 @@ bool ZPageAllocator::claim_virtual_memory(ZPageAllocation* allocation) {
897904 if (allocation->harvested () > 0 ) {
898905 ZArrayIterator<ZMemoryRange> iter (allocation->claimed_mappings ());
899906 for (ZMemoryRange vmem; iter.next (&vmem);) {
900- map_virtual_to_physical (vmem);
907+ map_virtual_to_physical (vmem, allocation-> numa_id () );
901908 }
902909 }
903910
@@ -921,9 +928,15 @@ bool ZPageAllocator::commit_and_map_memory(ZPageAllocation* allocation, const ZM
921928 }
922929
923930 sort_segments_physical (committed_vmem);
924- map_virtual_to_physical (committed_vmem);
931+ map_virtual_to_physical (committed_vmem, allocation-> numa_id () );
925932 allocation->claimed_mappings ()->append (committed_vmem);
926933
934+ // Memory should have ended up on the desired NUMA id, if that's not the case, print error.
935+ int actual = ZNUMA::memory_id (untype (ZOffset::address (vmem.start ())));
936+ if (actual != allocation->numa_id ()) {
937+ log_debug (gc, heap)(" NUMA Mismatch (allocation): desired %d, actual %d" , allocation->numa_id (), actual);
938+ }
939+
927940 if (committed_vmem.size () != vmem.size ()) {
928941 log_trace (gc, page)(" Split memory [" PTR_FORMAT " , " PTR_FORMAT " , " PTR_FORMAT " ]" ,
929942 untype (committed_vmem.start ()),
@@ -935,7 +948,6 @@ bool ZPageAllocator::commit_and_map_memory(ZPageAllocation* allocation, const ZM
935948 return true ;
936949}
937950
938-
939951ZPage* ZPageAllocator::alloc_page_inner (ZPageAllocation* allocation) {
940952retry:
941953 // Claim physical memory by taking it from the mapped cache or by increasing
0 commit comments