eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.27k stars 721 forks source link

SCC: Page size support in container environments #19968

Open tajila opened 1 month ago

tajila commented 1 month ago

Currently in container environments J9 creates a read only SCC. Each SCC records the page size of the environment that it was originally built in. On JVM startup during SCC initialization the recorded page size in the SCC is checked to see if it matches the current executing environment, if it does not then an SCC failure is emitted. In container environments if the JVM is started with -Xshareclasses:nonfatal then the JVM will startup without the SCC, otherwise the JVM fails to start. This issue limits the portability of container images as the page sizes much match.

In some cases a change in page size can be allowed. For example if the SCC is build in an environment with a higher page size, it should be allowed to be run in an environment with a smaller page size (so long as its a multiple).

Goal: Introduce a new options :strictPageSize and :nonStrictPageSize that allows for flexibility in page sizes. In container environments :nonStrictPageSize should be default.

tajila commented 1 month ago

@hangshao0 Feel free to correct anything that you feel is inaccurate. Also, feel free to change the option names. I think there should be a way to enable/disable the new behaviour for debugging purposes.

tajila commented 1 month ago

FYI @pshipton

hangshao0 commented 1 month ago

Actually we can do better. https://github.com/eclipse-openj9/openj9/pull/19972 removes the requirement of consistent page size in SCC. The page level operations in SCC are msync and mprotec. msync is only used on z/OS, I won't worry about it. There is no need to do mprotect if the SCC is readonly. If the data is not page aligned, we cannot do mprotect anymore, and it should be turned off.