You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Android] Runtime/BCL native libs need support for devices with 16k memory pages (arm64 and x64) #103360
Android is moving towards supporting devices with 16k memory page size, for the x64 and arm64 architectures. This affects all the native components of the application. In our case it means the MonoVM runtime, the BCL support libraries and .NET for Android native runtime and libraries.
Google plan to make support for 16k devices a requirement for Google Play application submissions next year.
All the native libraries must be rebuilt with flags enabling 16k alignment of data and code
Code review of native (and maybe some managed?) code needs to be done in order to make sure we don't assume 4k page size anywhere. This includes MonoVM runtime/JIT/interpreter code.
Code review of native (and maybe some managed?) code needs to be done in order to make sure we don't assume 4k page size anywhere
coreclr should work on variable page sizes. macOS ARM64 uses 16kB pages, we have tested Linux arm64 with 64kB pages in the past too. I am not sure about the x64 though, there might be some stuff expecting 4kB page size for this architecture.
My main concern with just shipping the 16k-aligned binaries is embedded device developers - if we don't ship 4k-aligned binaries, they would be forced to use the larger binaries (with bigger memory consumption), which on embedded devices with little memory may have a lot of importance.
I understand that there is a bit higher address space consumption (the padding takes address space). This does not matter - address space consumption that we talk about here costs close to nothing.
I do not see why this have to cause measurable increase in physical memory consumption. ELF loader and Linux kernel should map the pages where the sections overlap to same physical memory page(s).
I understand that there is a bit higher address space consumption (the padding takes address space). This does not matter - address space consumption that we talk about here costs close to nothing.
It depends on the library. However, the consumption will be real, since what is "wasted" is the space between the end of a section and the beginning of the next one. The preceding section "spills over" into its last page, so the page is actually mapped and using real memory. The difference between the used space and the page size alignment is the wasted memory. Granted, it's not that much for most devices in most cases, but for embedded devices it may be important.
I do not see why this have to cause measurable increase in physical memory consumption. ELF loader and Linux kernel should map the pages where the sections overlap to same physical memory page(s).
I'm not sure they will do that, because then the alignment requirement wouldn't be satisfied for the beginning of one of the sections.
Anyway, after some discussion with @jonpryor, I think you and @steveisok are right - we don't need to ship 4k and 16k binaries right now. If anyone needs them, they will let us know and we can cross the bridge if/when that happens.
So for NET9 release the thing that we'd need is to build the runtime with 16k alignment. I can open a PR later this week which will implement that, unless somebody beats me to it.
Activity
dotnet-policy-service commentedon Jun 12, 2024
Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.
steveisok commentedon Jun 12, 2024
/cc @vitek-karas
janvorli commentedon Jun 12, 2024
coreclr should work on variable page sizes. macOS ARM64 uses 16kB pages, we have tested Linux arm64 with 64kB pages in the past too. I am not sure about the x64 though, there might be some stuff expecting 4kB page size for this architecture.
janvorli commentedon Jun 12, 2024
Ah, sorry, this issue is mono specific, right?
steveisok commentedon Jun 13, 2024
Yeah, but it's also important to understand how coreclr would behave.
grendello commentedon Jun 13, 2024
@janvorli CoreCLR is used to build apps that run on Android too, so as @steveisok said, it's important to make sure it works too.
janvorli commentedon Jun 13, 2024
Ok, I am glad the details I have added above are useful then.
8 remaining items
grendello commentedon Jul 2, 2024
My main concern with just shipping the 16k-aligned binaries is embedded device developers - if we don't ship 4k-aligned binaries, they would be forced to use the larger binaries (with bigger memory consumption), which on embedded devices with little memory may have a lot of importance.
jkotas commentedon Jul 2, 2024
How much is the increase in memory consumption?
I understand that there is a bit higher address space consumption (the padding takes address space). This does not matter - address space consumption that we talk about here costs close to nothing.
I do not see why this have to cause measurable increase in physical memory consumption. ELF loader and Linux kernel should map the pages where the sections overlap to same physical memory page(s).
grendello commentedon Jul 2, 2024
It depends on the library. However, the consumption will be real, since what is "wasted" is the space between the end of a section and the beginning of the next one. The preceding section "spills over" into its last page, so the page is actually mapped and using real memory. The difference between the used space and the page size alignment is the wasted memory. Granted, it's not that much for most devices in most cases, but for embedded devices it may be important.
I'm not sure they will do that, because then the alignment requirement wouldn't be satisfied for the beginning of one of the sections.
Anyway, after some discussion with @jonpryor, I think you and @steveisok are right - we don't need to ship 4k and 16k binaries right now. If anyone needs them, they will let us know and we can cross the bridge if/when that happens.
So for NET9 release the thing that we'd need is to build the runtime with 16k alignment. I can open a PR later this week which will implement that, unless somebody beats me to it.
janvorli commentedon Jul 8, 2024
Unless that extra virtual memory range is accessed, it should not increase the resident set and thus it should only consume virtual address space.
[Android] Link native shared libraries with 16k page alignment
grendello commentedon Jul 8, 2024
PR is up #104577
[Android] Link native shared libraries with 16k page alignment
[Android] Link native shared libraries with 16k page alignment
[Android] Link native shared libraries with 16k page alignment
[Android] Link native shared libraries with 16k page alignment
[Android] Link native shared libraries with 16k page alignment
[Android] Link native shared libraries with 16k page alignment (dotne…