Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISC-V][GC] Use 128gb for regions_range on RISCV64 #84797

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45747,8 +45747,8 @@ HRESULT GCHeap::Initialize()
}
else
{
// If no hard_limit is configured the reservation size is max of 256gb or 2x physical limit
gc_heap::regions_range = max(((size_t)256 * 1024 * 1024 * 1024), (size_t)(2 * gc_heap::total_physical_mem));
// If no hard_limit is configured the reservation size is min of 1/2 GetVirtualMemoryLimit() or max of 256Gb or 2x physical limit.
gc_heap::regions_range = min(GCToOSInterface::GetVirtualMemoryLimit()/2, max((size_t)256 * 1024 * 1024 * 1024, (size_t)(2 * gc_heap::total_physical_mem)));
t-mustafin marked this conversation as resolved.
Show resolved Hide resolved
t-mustafin marked this conversation as resolved.
Show resolved Hide resolved
}
gc_heap::regions_range = align_on_page(gc_heap::regions_range);
}
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,12 +1080,18 @@ const AffinitySet* GCToOSInterface::SetGCThreadsAffinitySet(uintptr_t configAffi
size_t GCToOSInterface::GetVirtualMemoryLimit()
{
#ifdef HOST_64BIT
#ifndef TARGET_RISCV64
// There is no API to get the total virtual address space size on
// Unix, so we use a constant value representing 128TB, which is
// the approximate size of total user virtual address space on
// the currently supported Unix systems.
static const uint64_t _128TB = (1ull << 47);
return _128TB;
#else // TARGET_RISCV64
// For RISC-V Linux Kernel SV39 virtual memory limit is 256gb.
static const uint64_t _256GB = (1ull << 38);
return _256GB;
#endif // TARGET_RISCV64
#else
return (size_t)-1;
#endif
Expand Down
9 changes: 7 additions & 2 deletions src/coreclr/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,17 @@ GlobalMemoryStatusEx(
#endif // __APPLE__
}

#ifndef TARGET_RISCV64
// There is no API to get the total virtual address space size on
// Unix, so we use a constant value representing 128TB, which is
// the approximate size of total user virtual address space on
// the currently supported Unix systems.
static const UINT64 _128TB = (1ull << 47);
lpBuffer->ullTotalVirtual = _128TB;
static const UINT64 VMSize = (1ull << 47);
#else // TARGET_RISCV64
// For RISC-V Linux Kernel SV39 virtual memory limit is 256gb.
static const UINT64 VMSize = (1ull << 38);
#endif // TARGET_RISCV64
lpBuffer->ullTotalVirtual = VMSize;
lpBuffer->ullAvailVirtual = lpBuffer->ullAvailPhys;

LOGEXIT("GlobalMemoryStatusEx returns %d\n", fRetVal);
Expand Down