Skip to content

Commit 889a4b8

Browse files
committed
Initial NUMA implementation
1 parent f2bc19c commit 889a4b8

24 files changed

+719
-393
lines changed

src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ bool ZPhysicalMemoryBacking::commit_inner(zoffset offset, size_t length) const {
117117
return true;
118118
}
119119

120-
size_t ZPhysicalMemoryBacking::commit(zoffset offset, size_t length) const {
120+
size_t ZPhysicalMemoryBacking::commit(zoffset offset, size_t length, int nid) const {
121+
// nid is unused as NUMA is not supported on bsd.
122+
121123
// Try to commit the whole region
122124
if (commit_inner(offset, length)) {
123125
// Success

src/hotspot/os/bsd/gc/z/zPhysicalMemoryBacking_bsd.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ZPhysicalMemoryBacking {
4040

4141
void warn_commit_limits(size_t max_capacity) const;
4242

43-
size_t commit(zoffset offset, size_t length) const;
43+
size_t commit(zoffset offset, size_t length, int nid) const;
4444
size_t uncommit(zoffset offset, size_t length) const;
4545

4646
void map(zaddress_unsafe addr, size_t size, zoffset offset) const;

src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.cpp

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

src/hotspot/os/linux/gc/z/zPhysicalMemoryBacking_linux.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ZPhysicalMemoryBacking {
5959
ZErrno fallocate(bool punch_hole, zoffset offset, size_t length) const;
6060

6161
bool commit_inner(zoffset offset, size_t length) const;
62-
size_t commit_numa_interleaved(zoffset offset, size_t length) const;
62+
size_t commit_numa_preferred(zoffset offset, size_t length, int nid) const;
6363
size_t commit_default(zoffset offset, size_t length) const;
6464

6565
public:
@@ -69,7 +69,7 @@ class ZPhysicalMemoryBacking {
6969

7070
void warn_commit_limits(size_t max_capacity) const;
7171

72-
size_t commit(zoffset offset, size_t length) const;
72+
size_t commit(zoffset offset, size_t length, int nid) const;
7373
size_t uncommit(zoffset offset, size_t length) const;
7474

7575
void map(zaddress_unsafe addr, size_t size, zoffset offset) const;

src/hotspot/os/windows/gc/z/zPhysicalMemoryBacking_windows.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ void ZPhysicalMemoryBacking::warn_commit_limits(size_t max_capacity) const {
223223
// Does nothing
224224
}
225225

226-
size_t ZPhysicalMemoryBacking::commit(zoffset offset, size_t length) {
226+
size_t ZPhysicalMemoryBacking::commit(zoffset offset, size_t length, int nid) {
227+
// nid does nothing as NUMA is not supported on bsd.
228+
227229
log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)",
228230
untype(offset) / M, untype(to_zoffset_end(offset, length)) / M, length / M);
229231

src/hotspot/os/windows/gc/z/zPhysicalMemoryBacking_windows.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ZPhysicalMemoryBacking {
4242

4343
void warn_commit_limits(size_t max_capacity) const;
4444

45-
size_t commit(zoffset offset, size_t length);
45+
size_t commit(zoffset offset, size_t length, int nid);
4646
size_t uncommit(zoffset offset, size_t length);
4747

4848
void map(zaddress_unsafe addr, size_t size, zoffset offset) const;

src/hotspot/share/gc/z/vmStructs_z.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ typedef ZAttachedArray<ZForwarding, ZForwardingEntry> ZAttachedArrayForForwardin
8585
volatile_nonstatic_field(ZPage, _seqnum, uint32_t) \
8686
volatile_nonstatic_field(ZPage, _top, zoffset_end) \
8787
\
88-
nonstatic_field(ZPageAllocator, _max_capacity, const size_t) \
89-
volatile_nonstatic_field(ZPageAllocator, _capacity, size_t) \
90-
volatile_nonstatic_field(ZPageAllocator, _used, size_t) \
91-
\
9288
nonstatic_field(ZPageTable, _map, ZGranuleMapForPageTable) \
9389
\
9490
nonstatic_field(ZGranuleMapForPageTable, _map, ZPage** const) \

src/hotspot/share/gc/z/zGeneration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ void ZGenerationYoung::flip_promote(ZPage* from_page, ZPage* to_page) {
927927
_page_table->replace(from_page, to_page);
928928

929929
// Update statistics
930-
_page_allocator->promote_used(from_page->size());
930+
_page_allocator->promote_used(from_page, to_page);
931931
increase_freed(from_page->size());
932932
increase_promoted(from_page->live_bytes());
933933
}
@@ -936,7 +936,7 @@ void ZGenerationYoung::in_place_relocate_promote(ZPage* from_page, ZPage* to_pag
936936
_page_table->replace(from_page, to_page);
937937

938938
// Update statistics
939-
_page_allocator->promote_used(from_page->size());
939+
_page_allocator->promote_used(from_page, to_page);
940940
}
941941

942942
void ZGenerationYoung::register_flip_promoted(const ZArray<ZPage*>& pages) {

src/hotspot/share/gc/z/zMappedCache.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,7 @@ size_t ZMappedCache::remove_from_min(ZArray<ZVirtualMemory>* mappings, size_t ma
399399
}
400400
return remove_mappings(mappings, size);
401401
}
402+
403+
size_t ZMappedCache::size() const {
404+
return _size;
405+
}

src/hotspot/share/gc/z/zMappedCache.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class ZMappedCache {
6464
public:
6565
ZMappedCache();
6666

67+
6768
void insert_mapping(const ZVirtualMemory& vmem);
6869

6970
size_t remove_mappings(ZArray<ZVirtualMemory>* mappings, size_t size);
@@ -73,6 +74,8 @@ class ZMappedCache {
7374
size_t min() const;
7475
size_t reset_min();
7576
size_t remove_from_min(ZArray<ZVirtualMemory>* mappings, size_t max_size);
77+
78+
size_t size() const;
7679
};
7780

7881
#endif // SHARE_GC_Z_ZMAPPEDCACHE_HPP

0 commit comments

Comments
 (0)