@@ -628,30 +628,11 @@ bool ZPhysicalMemoryBacking::commit_inner(zoffset offset, size_t length) const {
628628 return true ;
629629}
630630
631- static int offset_to_node (zoffset offset) {
632- const GrowableArray<int >* mapping = os::Linux::numa_nindex_to_node ();
633- const size_t nindex = (untype (offset) >> ZGranuleSizeShift) % mapping->length ();
634- return mapping->at ((int )nindex);
635- }
636-
637- size_t ZPhysicalMemoryBacking::commit_numa_interleaved (zoffset offset, size_t length) const {
638- size_t committed = 0 ;
639-
640- // Commit one granule at a time, so that each granule
641- // can be allocated from a different preferred node.
642- while (committed < length) {
643- const zoffset granule_offset = offset + committed;
644-
645- // Setup NUMA policy to allocate memory from a preferred node
646- os::Linux::numa_set_preferred (offset_to_node (granule_offset));
631+ size_t ZPhysicalMemoryBacking::commit_numa_preferred (zoffset offset, size_t length, int nid) const {
632+ // Setup NUMA policy to allocate memory from a preferred node
633+ os::Linux::numa_set_preferred (nid);
647634
648- if (!commit_inner (granule_offset, ZGranuleSize)) {
649- // Failed
650- break ;
651- }
652-
653- committed += ZGranuleSize;
654- }
635+ size_t committed = commit_default (offset, length);
655636
656637 // Restore NUMA policy
657638 os::Linux::numa_set_preferred (-1 );
@@ -687,11 +668,11 @@ size_t ZPhysicalMemoryBacking::commit_default(zoffset offset, size_t length) con
687668 }
688669}
689670
690- size_t ZPhysicalMemoryBacking::commit (zoffset offset, size_t length) const {
691- if (ZNUMA::is_enabled () && ! ZLargePages::is_explicit () ) {
692- // To get granule-level NUMA interleaving when using non-large pages,
693- // we must explicitly interleave the memory at commit/fallocate time .
694- return commit_numa_interleaved (offset, length);
671+ size_t ZPhysicalMemoryBacking::commit (zoffset offset, size_t length, int nid ) const {
672+ if (ZNUMA::is_enabled ()) {
673+ // We want to prefer allocating on a specific NUMA node. nid = -1 means allocate
674+ // on the local node .
675+ return commit_numa_preferred (offset, length, nid );
695676 }
696677
697678 return commit_default (offset, length);
0 commit comments