Skip to content
Merged
3 changes: 0 additions & 3 deletions src/coreclr/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ nativeStringResourceTable_mscorrc
#PAL_free
#PAL_GetLogicalCpuCountFromOS
#PAL_GetTotalCpuCount
#PAL_GetNumaProcessorNode
#PAL_GetUnwindInfoSize
#PAL_get_stdout
#PAL_get_stderr
Expand Down Expand Up @@ -125,7 +124,6 @@ nativeStringResourceTable_mscorrc
#GetFullPathNameW
#GetLastError
#GetModuleFileNameW
#GetNumaHighestNodeNumber
#GetProcAddress
#GetStdHandle
#GetSystemInfo
Expand Down Expand Up @@ -167,7 +165,6 @@ nativeStringResourceTable_mscorrc
#SwitchToThread
#TerminateProcess
#VirtualAlloc
#VirtualAllocExNuma
#VirtualFree
#VirtualProtect
#VirtualQuery
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})

if (CLR_CMAKE_HOST_UNIX)
set(LIB_UNWINDER unwinder_wks)
set(GC_PAL gc_unix)
endif (CLR_CMAKE_HOST_UNIX)

# IMPORTANT! Please do not rearrange the order of the libraries. The linker on Linux is
Expand All @@ -108,6 +109,7 @@ set(CORECLR_LIBRARIES
System.Globalization.Native-Static
interop
coreclrminipal
${GC_PAL}
)

if(CLR_CMAKE_TARGET_WIN32)
Expand Down
8 changes: 3 additions & 5 deletions src/coreclr/gc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ set(GC_SOURCES
handletablecache.cpp)

if(CLR_CMAKE_HOST_UNIX)
add_subdirectory(unix)
include(unix/configure.cmake)
set (GC_SOURCES
${GC_SOURCES}
unix/gcenv.unix.cpp
unix/events.cpp
unix/cgroup.cpp)
${GC_SOURCES})
else()
set (GC_SOURCES
${GC_SOURCES}
Expand Down Expand Up @@ -101,7 +99,7 @@ if(CLR_CMAKE_HOST_WIN32)
kernel32.lib
advapi32.lib)
else()
set (GC_LINK_LIBRARIES)
set (GC_LINK_LIBRARIES gc_unix)
endif(CLR_CMAKE_HOST_WIN32)

list(APPEND GC_SOURCES ${GC_HEADERS})
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/gc/env/gcenv.os.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ class GCToOSInterface
// available_page_file - The maximum amount of memory the current process can commit, in bytes.
// Remarks:
// Any parameter can be null.
static void GetMemoryStatus(uint64_t restricted_limit, uint32_t* memory_load, uint64_t* available_physical, uint64_t* available_page_file);
// explicit (unsigned long long) is used to conform to both Linux and MacOS
static void GetMemoryStatus(unsigned long long restricted_limit, uint32_t* memory_load, unsigned long long* available_physical, unsigned long long* available_page_file);

// Get size of an OS memory page
static size_t GetPageSize();
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25888,7 +25888,7 @@ void gc_heap::get_memory_info (uint32_t* memory_load,
uint64_t* available_physical,
uint64_t* available_page_file)
{
GCToOSInterface::GetMemoryStatus(is_restricted_physical_mem ? total_physical_mem : 0, memory_load, available_physical, available_page_file);
GCToOSInterface::GetMemoryStatus(is_restricted_physical_mem ? total_physical_mem : 0, memory_load, (unsigned long long*) available_physical, (unsigned long long*) available_page_file);
}

//returns TRUE is an overflow happened.
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/gc/unix/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Module Name:

extern bool ReadMemoryValueFromFile(const char* filename, uint64_t* val);

namespace
{
class CGroup
{
// the cgroup version number or 0 to indicate cgroups are not found or not enabled
Expand Down Expand Up @@ -453,6 +455,7 @@ class CGroup
return foundInactiveFileValue;
}
};
}

int CGroup::s_cgroup_version = 0;
char *CGroup::s_memory_cgroup_path = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,7 @@ uint64_t GetAvailablePageFile()
// that is in use (0 indicates no memory use and 100 indicates full memory use).
// available_physical - The amount of physical memory currently available, in bytes.
// available_page_file - The maximum amount of memory the current process can commit, in bytes.
void GCToOSInterface::GetMemoryStatus(uint64_t restricted_limit, uint32_t* memory_load, uint64_t* available_physical, uint64_t* available_page_file)
void GCToOSInterface::GetMemoryStatus(unsigned long long restricted_limit, uint32_t* memory_load, unsigned long long* available_physical, unsigned long long* available_page_file)
{
uint64_t available = 0;
uint32_t load = 0;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ set(SOURCES
misc/sysinfo.cpp
misc/time.cpp
misc/utils.cpp
numa/numa.cpp
objmgr/palobjbase.cpp
objmgr/shmobject.cpp
objmgr/shmobjectmanager.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pal/src/include/pal/palinternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ typedef enum _TimeConversionConstants
}

bool
ReadMemoryValueFromFile(const char* filename, uint64_t* val);
PAL_ReadMemoryValueFromFile(const char* filename, uint64_t* val);

#ifdef __APPLE__
bool
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/pal/src/init/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,6 @@ Initialize(
goto CLEANUP15;
}

if (FALSE == NUMASupportInitialize())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assume its fine to remove the Numa initialization from the pal, since its now being handled with the gc_unix pal.

{
ERROR("Unable to initialize NUMA support\n");
palError = ERROR_PALINIT_NUMA;
goto CLEANUP15;
}

TRACE("First-time PAL initialization complete.\n");
init_count++;

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pal/src/misc/cgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ class CGroup

static bool ReadMemoryValueFromFile(const char* filename, uint64_t* val)
{
return ::ReadMemoryValueFromFile(filename, val);
return ::PAL_ReadMemoryValueFromFile(filename, val);
}

static bool GetCGroup1CpuLimit(UINT *val)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ PAL_HasGetCurrentProcessorNumber()
}

bool
ReadMemoryValueFromFile(const char* filename, uint64_t* val)
PAL_ReadMemoryValueFromFile(const char* filename, uint64_t* val)
{
bool result = false;
char *line = nullptr;
Expand Down Expand Up @@ -585,11 +585,11 @@ PAL_GetLogicalProcessorCacheSizeFromOS()
{
path_to_size_file[index] = (char)(48 + i);

if (ReadMemoryValueFromFile(path_to_size_file, &size))
if (PAL_ReadMemoryValueFromFile(path_to_size_file, &size))
{
path_to_level_file[index] = (char)(48 + i);

if (ReadMemoryValueFromFile(path_to_level_file, &level))
if (PAL_ReadMemoryValueFromFile(path_to_level_file, &level))
{
UPDATE_CACHE_SIZE_AND_LEVEL(size, level)
}
Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/utilcode/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
return pResult;
}

#ifdef HOST_WINDOWS

//******************************************************************************
// NumaNodeInfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete the NumaNodeInfo class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah guess there is more cleanup required here, will do as part of a separate PR.

Copy link
Member

@jkotas jkotas Oct 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you are keeping the VM version of the current PAL for Windows under ifdefs. Is there a problem with using the GC PAL on Windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there shouldnt be an issue with moving windows too, just needs a some more wrangling. Also need to check with @Maoni0 that all numa stuff is handled appropriately in gcenv.windows

//******************************************************************************
Expand All @@ -524,7 +526,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
return ::VirtualAllocExNuma(hProc, lpAddr, dwSize, allocType, prot, node);
}

#ifdef HOST_WINDOWS
/*static*/ BOOL NumaNodeInfo::GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, PUSHORT node_no)
{
return ::GetNumaProcessorNodeEx(proc_no, node_no);
Expand Down Expand Up @@ -566,6 +567,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
#endif // HOST_WINDOWS
#endif

#ifdef HOST_WINDOWS
/*static*/ BOOL NumaNodeInfo::m_enableGCNumaAware = FALSE;
/*static*/ uint16_t NumaNodeInfo::m_nNodes = 0;
/*static*/ BOOL NumaNodeInfo::InitNumaNodeInfoAPI()
Expand Down Expand Up @@ -599,7 +601,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
m_enableGCNumaAware = InitNumaNodeInfoAPI();
}

#ifdef HOST_WINDOWS

//******************************************************************************
// CPUGroupInfo
Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ set(VM_SOURCES_WKS
gccover.cpp
gcenv.ee.static.cpp
gcenv.ee.common.cpp
gcenv.os.cpp
gchelpers.cpp
genanalysis.cpp
genmeth.cpp
Expand Down Expand Up @@ -504,6 +503,13 @@ if (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32)
)
endif (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32)

if (CLR_CMAKE_TARGET_WIN32)
set ( GC_SOURCES_WKS
${GC_SOURCES_WKS}
gcenv.os.cpp
)
endif (CLR_CMAKE_TARGET_WIN32)

set(GC_HEADERS_WKS
${GC_HEADERS_DAC_AND_WKS_COMMON}
../gc/gceventstatus.h
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,13 @@ void EEStartupHelper()

#ifdef HOST_WINDOWS
InitializeCrashDump();
#endif // HOST_WINDOWS


// Initialize Numa and CPU group information
// Need to do this as early as possible. Used by creating object handle
// table inside Ref_Initialization() before GC is initialized.
NumaNodeInfo::InitNumaNodeInfo();
#endif // HOST_WINDOWS
#ifndef TARGET_UNIX
CPUGroupInfo::EnsureInitialized();
#endif // !TARGET_UNIX
Expand Down