Skip to content

Commit 843fbf7

Browse files
committed
WIP
1 parent 106f348 commit 843fbf7

5 files changed

Lines changed: 22 additions & 8 deletions

File tree

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,9 @@ void ZPartition::free_memory_alloc_failed(ZMemoryAllocation* allocation) {
11021102
}
11031103

11041104
void ZPartition::threads_do(ThreadClosure* tc) const {
1105-
tc->do_thread(const_cast<ZUncommitter*>(&_uncommitter));
1105+
if (ZUncommitter::is_enabled()) {
1106+
tc->do_thread(const_cast<ZUncommitter*>(&_uncommitter));
1107+
}
11061108
}
11071109

11081110
void ZPartition::print_on(outputStream* st) const {
@@ -1210,7 +1212,7 @@ ZPageAllocator::ZPageAllocator(size_t min_capacity,
12101212
size_t max_capacity)
12111213
: _lock(),
12121214
_virtual(max_capacity),
1213-
_physical(max_capacity),
1215+
_physical(min_capacity, max_capacity),
12141216
_min_capacity(min_capacity),
12151217
_max_capacity(max_capacity),
12161218
_used(0),
@@ -1243,9 +1245,6 @@ ZPageAllocator::ZPageAllocator(size_t min_capacity,
12431245
// Warn if system limits could stop us from reaching max capacity
12441246
_physical.warn_commit_limits(max_capacity);
12451247

1246-
// Check if uncommit should and can be enabled
1247-
_physical.try_enable_uncommit(min_capacity, max_capacity);
1248-
12491248
// Successfully initialized
12501249
_initialized = true;
12511250
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "utilities/globalDefinitions.hpp"
4646
#include "utilities/powerOfTwo.hpp"
4747

48-
ZPhysicalMemoryManager::ZPhysicalMemoryManager(size_t max_capacity)
48+
ZPhysicalMemoryManager::ZPhysicalMemoryManager(size_t min_capacity, size_t max_capacity)
4949
: _backing(max_capacity),
5050
_physical_mappings(ZAddressOffsetMax) {
5151
assert(is_aligned(max_capacity, ZGranuleSize), "must be granule aligned");
@@ -77,6 +77,8 @@ ZPhysicalMemoryManager::ZPhysicalMemoryManager(size_t max_capacity)
7777
next_index += num_segments;
7878
}
7979

80+
try_enable_uncommit(min_capacity, max_capacity);
81+
8082
assert(untype(next_index) == ZBackingIndexMax, "must insert all capacity");
8183
}
8284

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ class ZPhysicalMemoryManager {
4848
void copy_to_stash(ZArraySlice<zbacking_index> stash, const ZVirtualMemory& vmem) const;
4949
void copy_from_stash(const ZArraySlice<const zbacking_index> stash, const ZVirtualMemory& vmem);
5050

51+
void try_enable_uncommit(size_t min_capacity, size_t max_capacity);
52+
5153
public:
52-
ZPhysicalMemoryManager(size_t max_capacity);
54+
ZPhysicalMemoryManager(size_t min_capacity, size_t max_capacity);
5355

5456
bool is_initialized() const;
5557

5658
void warn_commit_limits(size_t max_capacity) const;
57-
void try_enable_uncommit(size_t min_capacity, size_t max_capacity);
5859

5960
void alloc(const ZVirtualMemory& vmem, uint32_t numa_id);
6061
void free(const ZVirtualMemory& vmem, uint32_t numa_id);

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040

4141
static const ZStatCounter ZCounterUncommit("Memory", "Uncommit", ZStatUnitBytesPerSecond);
4242

43+
bool ZUncommitter::is_enabled() {
44+
return ZUncommit;
45+
}
46+
4347
ZUncommitter::ZUncommitter(uint32_t id, ZPartition* partition)
4448
: _id(id),
4549
_partition(partition),
@@ -51,6 +55,12 @@ ZUncommitter::ZUncommitter(uint32_t id, ZPartition* partition)
5155
_cycle_start(0.0),
5256
_to_uncommit(0),
5357
_uncommitted(0) {
58+
if (!is_enabled()) {
59+
// Disabled, do not start.
60+
_stop = true;
61+
return;
62+
}
63+
5464
set_name("ZUncommitter#%u", id);
5565
create_and_start();
5666
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class ZUncommitter : public ZThread {
7070
virtual void terminate();
7171

7272
public:
73+
static bool is_enabled();
74+
7375
ZUncommitter(uint32_t id, ZPartition* partition);
7476

7577
void cancel_uncommit_cycle();

0 commit comments

Comments
 (0)