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

(0.48) Remove requirement for consistent memory page size in SCC #20183

Merged
merged 1 commit into from
Sep 18, 2024
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
26 changes: 20 additions & 6 deletions runtime/nls/shrc/j9shr.nls
Original file line number Diff line number Diff line change
Expand Up @@ -2203,12 +2203,7 @@ J9NLS_SHRC_INFO_DESTROYING_FOR_CACHEDIR.system_action=None
J9NLS_SHRC_INFO_DESTROYING_FOR_CACHEDIR.user_response=None
# END NON-TRANSLATABLE

J9NLS_CC_OSPAGE_SIZE_MISMATCH=The page size of the operating system is incompatible with this cache. Attempting to re-create the cache.
# START NON-TRANSLATABLE
J9NLS_CC_OSPAGE_SIZE_MISMATCH.explanation=The cache is divided up on page boundaries. If there is a page size mismatch, the cache is unusable
J9NLS_CC_OSPAGE_SIZE_MISMATCH.system_action=The JVM will try to destroy the incompatible cache and re-create it
J9NLS_CC_OSPAGE_SIZE_MISMATCH.user_response=None
# END NON-TRANSLATABLE
J9NLS_CC_OSPAGE_SIZE_MISMATCH=

J9NLS_SHRC_SHRINIT_HELPTEXT_READONLY=Open the cache with read-only permissions
# START NON-TRANSLATABLE
Expand Down Expand Up @@ -6929,3 +6924,22 @@ J9NLS_SHRC_OSCACHE_MMAP_STARTUP_JITSERVER_LAYER_FILE_DELETE_ERROR.explanation=Th
J9NLS_SHRC_OSCACHE_MMAP_STARTUP_JITSERVER_LAYER_FILE_DELETE_ERROR.system_action=The JVM continues.
J9NLS_SHRC_OSCACHE_MMAP_STARTUP_JITSERVER_LAYER_FILE_DELETE_ERROR.user_response=Contact your service representative.
# END NON-TRANSLATABLE

J9NLS_CC_OSPAGE_SIZE_MISMATCH_V1=The page size (%zu) of the operating system is different from the page size (%zu) of the system on which layer %d cache is created.
# START NON-TRANSLATABLE
J9NLS_CC_OSPAGE_SIZE_MISMATCH_V1.sample_input_1=1024
J9NLS_CC_OSPAGE_SIZE_MISMATCH_V1.sample_input_2=4096
J9NLS_CC_OSPAGE_SIZE_MISMATCH_V1.sample_input_3=0
J9NLS_CC_OSPAGE_SIZE_MISMATCH_V1.explanation=The cache is divided up on page boundaries according to the page size of system on which it was created. If there is a page size mismatch, the data might not be page aligned anymore.
J9NLS_CC_OSPAGE_SIZE_MISMATCH_V1.system_action=The JVM continues, but with memory page protection disabled if data is not page aligned anymore.
J9NLS_CC_OSPAGE_SIZE_MISMATCH_V1.user_response=No action required
# END NON-TRANSLATABLE

J9NLS_SHRC_CM_PRINTSTATS_PAGESIZEE=Memory Page size = %zu (Current OS page size %zu)
# START NON-TRANSLATABLE
J9NLS_SHRC_CM_PRINTSTATS_PAGESIZEE.sample_input_1=4096
J9NLS_SHRC_CM_PRINTSTATS_PAGESIZEE.sample_input_1=4096
J9NLS_SHRC_CM_PRINTSTATS_PAGESIZEE.explanation=NOTAG
J9NLS_SHRC_CM_PRINTSTATS_PAGESIZEE.system_action=
J9NLS_SHRC_CM_PRINTSTATS_PAGESIZEE.user_response=
# END NON-TRANSLATABLE
2 changes: 2 additions & 0 deletions runtime/oti/j9nonbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,7 @@ typedef struct J9SharedClassJavacoreDataDescriptor {
UDATA numStartupHints;
UDATA startupHintBytes;
UDATA nattach;
UDATA currentOSPageSize; /* memory page size of the current running OS */
} J9SharedClassJavacoreDataDescriptor;

typedef struct J9SharedStringFarm {
Expand Down Expand Up @@ -1316,6 +1317,7 @@ typedef struct J9SharedClassCacheDescriptor {
void* metadataStartAddress;
struct J9MemorySegment* metadataMemorySegment;
UDATA cacheSizeBytes;
UDATA osPageSizeInHeader;
void* deployedROMClassStartAddress;
struct J9SharedClassCacheDescriptor* next;
struct J9SharedClassCacheDescriptor* previous;
Expand Down
2 changes: 2 additions & 0 deletions runtime/oti/shcflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@
#define J9SHR_RUNTIMEFLAG_ENABLE_SHAREUNSAFECLASSES J9CONST64(0x8000000000000000)

#define J9SHR_RUNTIMEFLAG2_ENABLE_CACHEORPHAN 1
#define J9SHR_RUNTIMEFLAG2_TEST_DOUBLE_PAGESIZE 2
#define J9SHR_RUNTIMEFLAG2_TEST_HALF_PAGESIZE 4

#define J9SHR_VERBOSEFLAG_ENABLE_VERBOSE_DEFAULT 1
#define J9SHR_VERBOSEFLAG_ENABLE_VERBOSE 2
Expand Down
49 changes: 45 additions & 4 deletions runtime/rasdump/javadump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ private :
void writeSharedClassSection(void);
void writeSharedClassSectionTopLayerStatsHelper(J9SharedClassJavacoreDataDescriptor* javacoreData, bool multiLayerStats);
void writeSharedClassSectionTopLayerStatsSummaryHelper(J9SharedClassJavacoreDataDescriptor* javacoreData);
void writeSharedClassSectionAllLayersStatsHelper(J9SharedClassJavacoreDataDescriptor* javacoreData);
void writeSharedClassSectionAllLayersStatsSummaryHelper(J9SharedClassJavacoreDataDescriptor* javacoreData);
void writeSharedClassSectionEachLayerStatsHelper(J9SharedClassJavacoreDataDescriptor* javacoreData);

#endif
void writeTrailer(void);
Expand Down Expand Up @@ -3394,7 +3395,7 @@ JavaCoreDumpWriter::writeSharedClassSectionTopLayerStatsSummaryHelper(J9SharedCl
}

void
JavaCoreDumpWriter::writeSharedClassSectionAllLayersStatsHelper(J9SharedClassJavacoreDataDescriptor* javacoreData)
JavaCoreDumpWriter::writeSharedClassSectionAllLayersStatsSummaryHelper(J9SharedClassJavacoreDataDescriptor* javacoreData)
{
_OutputStream.writeCharacters(
"2SCLTEXTRCB ROMClass bytes = "
Expand Down Expand Up @@ -3539,6 +3540,44 @@ JavaCoreDumpWriter::writeSharedClassSectionAllLayersStatsHelper(J9SharedClassJav
_OutputStream.writeCharacters("\n");
}

void
JavaCoreDumpWriter::writeSharedClassSectionEachLayerStatsHelper(J9SharedClassJavacoreDataDescriptor* javacoreData)
{
if (NULL == javacoreData) {
return;
}
if (NULL == _VirtualMachine->sharedClassConfig) {
return;
}
J9SharedClassCacheDescriptor *curCache = _VirtualMachine->sharedClassConfig->cacheDescriptorList;
if (NULL == curCache) {
return;
}
UDATA currentOSPageSize = javacoreData->currentOSPageSize;
I_8 layer = javacoreData->topLayer;
bool headerPrinted = false;
do {
if (currentOSPageSize != curCache->osPageSizeInHeader) {
if (!headerPrinted) {
_OutputStream.writeCharacters(
"NULL\n"
"1SCLTEXTCISL Cache Info for a single layer\n"
"NULL\n"
"1SCLTEXTCLYR Cache Layer Page Size in header current OS page size\n"
"NULL\n"
);
headerPrinted = true;
}
_OutputStream.writeCharacters("1SCLTEXTOSPG ");
_OutputStream.writeInteger(layer, "%-15d");
_OutputStream.writeInteger(curCache->osPageSizeInHeader, "%-23zu");
_OutputStream.writeInteger(currentOSPageSize, "%zu\n");
}
layer -= 1;
curCache = curCache->next;
} while ((curCache != _VirtualMachine->sharedClassConfig->cacheDescriptorList) && (NULL != curCache));
}

void
JavaCoreDumpWriter::writeSharedClassSection(void)
{
Expand Down Expand Up @@ -3574,13 +3613,15 @@ JavaCoreDumpWriter::writeSharedClassSection(void)
"1SCLTEXTCSAL Cache Statistics for All Layers\n"
"NULL\n"
);
writeSharedClassSectionAllLayersStatsHelper(&javacoreData);
writeSharedClassSectionAllLayersStatsSummaryHelper(&javacoreData);
} else {
writeSharedClassSectionTopLayerStatsHelper(&javacoreData, multiLayerStats);
writeSharedClassSectionAllLayersStatsHelper(&javacoreData);
writeSharedClassSectionAllLayersStatsSummaryHelper(&javacoreData);
writeSharedClassSectionTopLayerStatsSummaryHelper(&javacoreData);
}

writeSharedClassSectionEachLayerStatsHelper(&javacoreData);

/* Write the section trailer */
_OutputStream.writeCharacters(
"NULL\n"
Expand Down
3 changes: 2 additions & 1 deletion runtime/shared/shrclssup.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ IDATA J9VMDllMain(J9JavaVM* vm, IDATA stage, void* reserved)

parseXXOptions(vm, &runtimeFlags);

vm->sharedCacheAPI->parseResult = parseArgs(vm, optionsBufferPtr, &runtimeFlags, &verboseFlags, &cacheName, &modContext,
vm->sharedCacheAPI->parseResult = parseArgs(vm, optionsBufferPtr, &runtimeFlags, &runtimeFlags2, &verboseFlags, &cacheName, &modContext,
&expireTime, &ctrlDirName, &cacheDirPermStr, &methodSpecs, &printStatsOptions, &storageKeyTesting);
if ((RESULT_PARSE_FAILED == vm->sharedCacheAPI->parseResult)
){
Expand Down Expand Up @@ -391,6 +391,7 @@ IDATA J9VMDllMain(J9JavaVM* vm, IDATA stage, void* reserved)
vm->sharedCacheAPI->verboseFlags = J9SHR_VERBOSEFLAG_ENABLE_VERBOSE_DEFAULT;
}
vm->sharedCacheAPI->runtimeFlags = runtimeFlags;
vm->sharedCacheAPI->runtimeFlags2 = runtimeFlags2;
vm->sharedCacheAPI->cacheDirPerm = J9SH_DIRPERM_ABSENT;
}
}
Expand Down
11 changes: 11 additions & 0 deletions runtime/shared_common/CacheMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ SH_CacheMap::initializeROMSegmentList(J9VMThread* currentThread)
config->cacheDescriptorList->romclassStartAddress = firstROMClassAddress;
config->cacheDescriptorList->metadataStartAddress = cacheDebugAreaStart;
config->cacheDescriptorList->cacheSizeBytes = _ccHead->getCacheMemorySize();
config->cacheDescriptorList->osPageSizeInHeader = _ccHead->getOSPageSizeInHeader();

#if defined(J9VM_THR_PREEMPTIVE)
if (memorySegmentMutex) {
Expand Down Expand Up @@ -5001,6 +5002,15 @@ SH_CacheMap::printCacheStatsTopLayerStatsHelper(J9VMThread* currentThread, UDATA
CACHEMAP_PRINT1(J9NLS_DO_NOT_PRINT_MESSAGE_TAG, J9NLS_SHRC_CM_PRINTSTATS_FEATURE, "default");
}

UDATA osPageSizeInHeader = _sharedClassConfig->cacheDescriptorList->osPageSizeInHeader;
/* OS page size is not shown by default, as in most cases the osPage size is the same in cold and warm runs. */
if (J9_ARE_ALL_BITS_SET(runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_DETAILED_STATS)
|| (osPageSizeInHeader != javacoreData->currentOSPageSize)
) {
j9tty_printf(_portlib, "\t");
CACHEMAP_PRINT2(J9NLS_DO_NOT_PRINT_MESSAGE_TAG, J9NLS_SHRC_CM_PRINTSTATS_PAGESIZEE, osPageSizeInHeader, javacoreData->currentOSPageSize);
}

#if (defined(J9VM_ARCH_X86) || defined(J9VM_ARCH_S390) || defined(J9VM_ARCH_POWER))
if (currentThread->javaVM->jitConfig) {
j9tty_printf(_portlib, "\t");
Expand Down Expand Up @@ -5652,6 +5662,7 @@ SH_CacheMap::appendCacheDescriptorList(J9VMThread* currentThread, J9SharedClassC
cacheDesc->romclassStartAddress = ccToUse->getFirstROMClassAddress();
cacheDesc->metadataStartAddress = (U_8*)ccToUse->getClassDebugDataStartAddress() - sizeof(ShcItemHdr);
cacheDesc->cacheSizeBytes = ccToUse->getCacheMemorySize();
cacheDesc->osPageSizeInHeader = ccToUse->getOSPageSizeInHeader();

cacheDescriptorTail->next = cacheDesc;
cacheDesc->previous = cacheDescriptorTail;
Expand Down
9 changes: 5 additions & 4 deletions runtime/shared_common/ClassDebugDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ClassDebugDataProvider::initialize()
}

bool
ClassDebugDataProvider::Init(J9VMThread* currentThread, J9SharedCacheHeader * ca, AbstractMemoryPermission * permSetter, UDATA verboseFlags, U_64 * runtimeFlags, bool startupForStats)
ClassDebugDataProvider::Init(J9VMThread* currentThread, J9SharedCacheHeader * ca, AbstractMemoryPermission * permSetter, UDATA verboseFlags, U_64 * runtimeFlags, UDATA osPageSize, bool startupForStats)
{
bool retval = true;
Trc_SHR_ClassDebugData_Init_Entry(currentThread, ca);
Expand All @@ -76,6 +76,7 @@ ClassDebugDataProvider::Init(J9VMThread* currentThread, J9SharedCacheHeader * ca
_storedLineNumberTableBytes = 0;
_storedLocalVariableTableBytes = 0;
_runtimeFlags = runtimeFlags;
_osPageSize = osPageSize;

/*Note:
* No need to fire asserts because cache will be marked as corrupt.
Expand Down Expand Up @@ -273,7 +274,7 @@ ClassDebugDataProvider::allocateClassDebugData(J9VMThread* currentThread, U_16 c
goto done;
} else {
if (NULL != permSetter) {
UDATA pageSize = this->_theca->osPageSize;
UDATA pageSize = _osPageSize;

/* Mark the page as read-write where data is to be written */
permSetter->changePartialPageProtection(currentThread, pieces->lineNumberTable, false);
Expand Down Expand Up @@ -306,7 +307,7 @@ ClassDebugDataProvider::allocateClassDebugData(J9VMThread* currentThread, U_16 c
goto done;
} else {
if (NULL != permSetter) {
UDATA pageSize = this->_theca->osPageSize;
UDATA pageSize = _osPageSize;

/* Mark the page as read-write where data is to be written */
permSetter->changePartialPageProtection(currentThread, (void *)((UDATA)pieces->localVariableTable + sizes->localVariableTableSize), false);
Expand Down Expand Up @@ -658,7 +659,7 @@ ClassDebugDataProvider::setPermission(J9VMThread* currentThread, AbstractMemoryP
void * lvtProtectHigh,
bool readOnly)
{
UDATA pageSize = this->_theca->osPageSize;
UDATA pageSize = _osPageSize;
PORT_ACCESS_FROM_JAVAVM(currentThread->javaVM);

Trc_SHR_ClassDebugData_setPermission_Enter(currentThread, permSetter,
Expand Down
3 changes: 2 additions & 1 deletion runtime/shared_common/ClassDebugDataProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ClassDebugDataProvider
{
public:
void initialize();
bool Init(J9VMThread* currentThread, J9SharedCacheHeader * ca, AbstractMemoryPermission * permSetter, UDATA verboseFlags, U_64 * runtimeFlags, bool startupForStats);
bool Init(J9VMThread* currentThread, J9SharedCacheHeader * ca, AbstractMemoryPermission * permSetter, UDATA verboseFlags, U_64 * runtimeFlags, UDATA osPageSize, bool startupForStats);
UDATA getJavacoreData(J9JavaVM *vm, J9SharedClassJavacoreDataDescriptor* descriptor, J9SharedCacheHeader * ca);
IDATA allocateClassDebugData(J9VMThread* currentThread, U_16 classnameLength, const char* classnameData, const J9RomClassRequirements * sizes, J9SharedRomClassPieces * pieces, AbstractMemoryPermission * permSetter);
void rollbackClassDebugData(J9VMThread* currentThread, U_16 classnameLength, const char* classnameData, AbstractMemoryPermission * permSetter);
Expand Down Expand Up @@ -74,6 +74,7 @@ class ClassDebugDataProvider
UDATA failureValue;
UDATA _verboseFlags;
U_64 * _runtimeFlags;
UDATA _osPageSize;

void *operator new(size_t size);
ClassDebugDataProvider();
Expand Down
Loading