From 147bfb472474713f2ab0718ae8b8f43a7048a8e6 Mon Sep 17 00:00:00 2001 From: Tobi Ajila Date: Tue, 19 Mar 2024 15:07:02 -0400 Subject: [PATCH] Add support for 32bit allocator flags Introduce a mechanism to set flags for the 32bit allocator. Use the new mechanism to toggle the vmem mode to tmp file backed vmem. Signed-off-by: Tobi Ajila --- include_core/omrport.h | 4 ++++ port/common/omrmem32helpers.c | 6 ++++++ port/common/omrportcontrol.c | 7 +++++++ port/unix_include/omrportpg.h | 3 +++ port/zos390/omrportpg.h | 2 ++ 5 files changed, 22 insertions(+) diff --git a/include_core/omrport.h b/include_core/omrport.h index a314b4b0e36..2064c31eb03 100644 --- a/include_core/omrport.h +++ b/include_core/omrport.h @@ -885,6 +885,10 @@ typedef struct J9ProcessorInfos { #define OMRPORT_CTLDATA_VMEM_PERFORM_FULL_MEMORY_SEARCH "VMEM_PERFORM_FULL_SEARCH" #define OMRPORT_CTLDATA_VMEM_HUGE_PAGES_MMAP_ENABLED "VMEM_HUGE_PAGES_MMAP_ENABLED" #define OMRPORT_CTLDATA_CRIU_SUPPORT_FLAGS "CRIU_SUPPORT_FLAGS" +#define OMRPORT_CTLDATA_MEM_32BIT "MEM_32BIT_FLAGS" + +/* OMRPORT_CTLDATA_MEM_32BIT Flags */ +#define OMRPORT_MEM_32BIT_FLAGS_TMP_FILE_BACKED_VMEM 0x1 /* CRIU support is enabled, a checkpoint could be taken * if current VM is not from a final restoration. diff --git a/port/common/omrmem32helpers.c b/port/common/omrmem32helpers.c index 692f2be1f38..4dcad2be154 100644 --- a/port/common/omrmem32helpers.c +++ b/port/common/omrmem32helpers.c @@ -570,6 +570,12 @@ allocateVmemRegion32(struct OMRPortLibrary *portLibrary, uintptr_t byteAmount, J pageSize = 0x1000; } +#if defined(LINUX) + if (OMR_ARE_ALL_BITS_SET(PPG_mem32BitFlags, OMRPORT_MEM_32BIT_FLAGS_TMP_FILE_BACKED_VMEM)) { + vmemMode |= OMRPORT_VMEM_MEMORY_MODE_SHARE_TMP_FILE_OPEN | OMRPORT_VMEM_MEMORY_MODE_SHARE_FILE_OPEN; + } +#endif /* defined(LINUX) */ + /* iterate through the available regions */ for (i = 0; i < sizeof(regions) / sizeof(regions[0]); i++) { J9PortVmemParams params; diff --git a/port/common/omrportcontrol.c b/port/common/omrportcontrol.c index f2a09da2d6b..019df95162b 100644 --- a/port/common/omrportcontrol.c +++ b/port/common/omrportcontrol.c @@ -326,5 +326,12 @@ omrport_control(struct OMRPortLibrary *portLibrary, const char *key, uintptr_t v } #endif /* defined(PPG_criuSupportFlags) */ +#if defined(PPG_mem32BitFlags) + if (0 == strcmp(OMRPORT_CTLDATA_MEM_32BIT, key)) { + PPG_mem32BitFlags = value; + return 0; + } +#endif /* defined(PPG_mem32BitFlags) */ + return 1; } diff --git a/port/unix_include/omrportpg.h b/port/unix_include/omrportpg.h index a842ad26ca0..18225de16ad 100644 --- a/port/unix_include/omrportpg.h +++ b/port/unix_include/omrportpg.h @@ -115,6 +115,7 @@ typedef struct OMRPortPlatformGlobals { int pageProtectionPossible; #endif uintptr_t criuSupportFlags; + uintptr_t mem32BitFlags; } OMRPortPlatformGlobals; @@ -178,5 +179,7 @@ typedef struct OMRPortPlatformGlobals { #define PPG_criuSupportFlags (portLibrary->portGlobals->platformGlobals.criuSupportFlags) +#define PPG_mem32BitFlags (portLibrary->portGlobals->platformGlobals.mem32BitFlags) + #endif /* omrportpg_h */ diff --git a/port/zos390/omrportpg.h b/port/zos390/omrportpg.h index 876f365e9ab..6c3f9255ce2 100644 --- a/port/zos390/omrportpg.h +++ b/port/zos390/omrportpg.h @@ -111,4 +111,6 @@ typedef struct OMRPortPlatformGlobals { #define PPG_criuSupportFlags (portLibrary->portGlobals->platformGlobals.criuSupportFlags) +#define PPG_mem32BitFlags (portLibrary->portGlobals->platformGlobals.mem32BitFlags) + #endif /* omrportpg_h */