-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[NativeAOT] Support variable page size on Linux Arm64 #88710
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
Changes from 5 commits
8aee074
cae77f8
f5b5928
af0ffbe
495f851
4357ab0
f92b118
437df5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,8 @@ | |
|
|
||
| static_assert((THUNK_SIZE % 4) == 0, "Thunk stubs size not aligned correctly. This will cause runtime failures."); | ||
|
|
||
| #define THUNKS_MAP_SIZE 0x8000 // 32 K | ||
| // 32 K or OS page | ||
| #define THUNKS_MAP_SIZE (max(0x8000, OS_PAGE_SIZE)) | ||
|
|
||
| #ifdef TARGET_ARM | ||
| //***************************************************************************** | ||
|
|
@@ -56,7 +57,7 @@ void EncodeThumb2Mov32(uint16_t * pCode, uint32_t value, uint8_t rDestination) | |
|
|
||
| COOP_PINVOKE_HELPER(int, RhpGetNumThunkBlocksPerMapping, ()) | ||
| { | ||
| static_assert((THUNKS_MAP_SIZE % OS_PAGE_SIZE) == 0, "Thunks map size should be in multiples of pages"); | ||
| ASSERT_MSG((THUNKS_MAP_SIZE % OS_PAGE_SIZE) == 0, "Thunks map size should be in multiples of pages"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC, 64kB is a common page size on Linux Arm64. It is going to assert there. Ask @janvorli if you need help getting Linux arm64 machine configured like that for testing.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with It would still be interesting to run this on an actual system with 64K pages.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. I got it backwards. |
||
|
|
||
| return THUNKS_MAP_SIZE / OS_PAGE_SIZE; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,3 +113,14 @@ FORCEINLINE void PalSetLastError(int32_t error) | |
| { | ||
| errno = error; | ||
| } | ||
|
|
||
| FORCEINLINE int32_t PalOsPageSize() | ||
| { | ||
| #ifdef HOST_APPLE | ||
| return 0x4000; | ||
|
||
| #elif defined(HOST_AMD64) | ||
| return 0x1000; | ||
| #else | ||
| return PalGetOsPageSize(); | ||
| #endif | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -872,13 +872,12 @@ REDHAWK_PALEXPORT void PalFlushInstructionCache(_In_ void* pAddress, size_t size | |
| // | ||
| // As a workaround, we call __builtin___clear_cache on each page separately. | ||
|
|
||
| const size_t pageSize = getpagesize(); | ||
| uint8_t* begin = (uint8_t*)pAddress; | ||
| uint8_t* end = begin + size; | ||
|
|
||
| while (begin < end) | ||
| { | ||
| uint8_t* endOrNextPageBegin = ALIGN_UP(begin + 1, pageSize); | ||
| uint8_t* endOrNextPageBegin = ALIGN_UP(begin + 1, OS_PAGE_SIZE); | ||
| if (endOrNextPageBegin > end) | ||
| endOrNextPageBegin = end; | ||
|
|
||
|
|
@@ -1153,6 +1152,23 @@ REDHAWK_PALEXPORT int32_t PalGetProcessCpuCount() | |
| return g_RhNumberOfProcessors; | ||
| } | ||
|
|
||
| REDHAWK_PALEXPORT uint32_t REDHAWK_PALAPI PalGetOsPageSize() | ||
| { | ||
| static int saved_pagesize = 0; | ||
|
|
||
| if (saved_pagesize) | ||
| return saved_pagesize; | ||
|
|
||
| // Prefer sysconf () as it's signal safe. | ||
|
||
| #if defined (HAVE_SYSCONF) && defined (_SC_PAGESIZE) | ||
| saved_pagesize = sysconf(_SC_PAGESIZE); | ||
| #else | ||
| saved_pagesize = getpagesize(); | ||
|
||
| #endif | ||
|
|
||
| return saved_pagesize; | ||
| } | ||
|
|
||
| __thread void* pStackHighOut = NULL; | ||
| __thread void* pStackLowOut = NULL; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.