-
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 all 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 |
|---|---|---|
|
|
@@ -384,6 +384,24 @@ void InitializeCurrentProcessCpuCount() | |
| g_RhNumberOfProcessors = count; | ||
| } | ||
|
|
||
| static uint32_t g_RhPageSize; | ||
|
|
||
| void InitializeOsPageSize() | ||
| { | ||
| g_RhPageSize = (uint32_t)sysconf(_SC_PAGE_SIZE); | ||
|
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. Perhaps better: #ifdef OS_PAGE_SIZE
g_RhPageSize = (uint32_t)OS_PAGE_SIZE;
#else
g_RhPageSize = (uint32_t)sysconf(_SC_PAGE_SIZE);
#endif, delete nit: Os -> OS (two-letter abbreviation rule)
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.
I think we need one that inlines, and one that does not. (and one calls another, if needed) |
||
|
|
||
| #if defined(HOST_AMD64) | ||
| ASSERT(g_RhPageSize == 0x1000); | ||
| #elif defined(HOST_APPLE) | ||
| ASSERT(g_RhPageSize == 0x4000); | ||
| #endif | ||
| } | ||
|
|
||
| REDHAWK_PALEXPORT uint32_t REDHAWK_PALAPI PalGetOsPageSize() | ||
| { | ||
| return g_RhPageSize; | ||
| } | ||
|
|
||
| #if defined(TARGET_LINUX) || defined(TARGET_ANDROID) | ||
| static pthread_key_t key; | ||
| #endif | ||
|
|
@@ -412,6 +430,8 @@ REDHAWK_PALEXPORT bool REDHAWK_PALAPI PalInit() | |
|
|
||
| InitializeCurrentProcessCpuCount(); | ||
|
|
||
| InitializeOsPageSize(); | ||
|
|
||
| #if defined(TARGET_LINUX) || defined(TARGET_ANDROID) | ||
| if (pthread_key_create(&key, RuntimeThreadShutdown) != 0) | ||
| { | ||
|
|
@@ -872,13 +892,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; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with
#define THUNKS_MAP_SIZE (max(0x8000, OS_PAGE_SIZE))would it assert?It would still be interesting to run this on an actual system with 64K pages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I got it backwards.