-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8334371: [AIX] Beginning with AIX 7.3 TL1 mmap() supports 64K memory pages #19771
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
Conversation
|
👋 Welcome back jkern! A progress list of the required criteria for merging this PR into |
|
@JoKern65 This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 204 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
tstuefe
left a comment
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.
At long last. Cool.
Once 7.3 is the minimum requirement, you can shake lose a lot of code here, all that old SystemV shm coding.
Small remarks, otherwise okay
src/hotspot/os/aix/os_aix.cpp
Outdated
|
|
||
| // Can we use mmap with 64K pages? (Should be available with AIX7.3 TL1) | ||
| { | ||
| void* p = mmap(NULL, 1000000, PROT_READ | PROT_WRITE, MAP_ANON_64K | MAP_ANONYMOUS | MAP_SHARED, -1, 0); |
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.
Weird size. Why 1mio decimal? Why not 64K?
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.
OK, I will use 64*K
src/hotspot/os/aix/os_aix.cpp
Outdated
| // Can we use mmap with 64K pages? (Should be available with AIX7.3 TL1) | ||
| { | ||
| void* p = mmap(NULL, 1000000, PROT_READ | PROT_WRITE, MAP_ANON_64K | MAP_ANONYMOUS | MAP_SHARED, -1, 0); | ||
| guarantee0(p != (void*) -1); // Should always work. |
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.
I probably introduced those guarantee's myself many years ago, but we actually used guarantee very rarely, only for things that absolutely have to work, or the world explodes.
Here, there are a number of reasons why an mmap could fail, and you probably don't want to crash the VM with an guarantee at a customer site. I'd use assert.
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.
And what about the other guarantees in the same function after shmget() or shmat()?
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.
Yes, these are my faults. When I did them originally, I did not know better ( ~20 years ago). In new code, lets prefer assert. Up to you if you want to take the opportunity and clean up old code.
| # ifndef MAP_ANON_64K | ||
| # define MAP_ANON_64K 0x400 | ||
| # endif | ||
| #endif |
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.
Could you move the AIX-specific files out to something like test_os_aix.cpp, please? (same directory, just use ifdef AIX in the whole file). Its nicer, and precedence is there with the Cgroup tests of linux.
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.
I hope I did it like you meant. Please verify.
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.
Mostly good
| #include "memory/allocation.hpp" | ||
| #include "memory/resourceArea.hpp" | ||
| #include "nmt/memTracker.hpp" | ||
| #include "runtime/frame.inline.hpp" | ||
| #include "runtime/globals.hpp" | ||
| #include "runtime/os.inline.hpp" | ||
| #include "runtime/thread.hpp" | ||
| #include "runtime/threads.hpp" | ||
| #include "utilities/align.hpp" | ||
| #include "utilities/globalDefinitions.hpp" | ||
| #include "utilities/macros.hpp" | ||
| #include "utilities/ostream.hpp" | ||
| #include "unittest.hpp" |
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.
| #include "memory/allocation.hpp" | |
| #include "memory/resourceArea.hpp" | |
| #include "nmt/memTracker.hpp" | |
| #include "runtime/frame.inline.hpp" | |
| #include "runtime/globals.hpp" | |
| #include "runtime/os.inline.hpp" | |
| #include "runtime/thread.hpp" | |
| #include "runtime/threads.hpp" | |
| #include "utilities/align.hpp" | |
| #include "utilities/globalDefinitions.hpp" | |
| #include "utilities/macros.hpp" | |
| #include "utilities/ostream.hpp" | |
| #include "unittest.hpp" | |
| #include "runtime/os.inline.hpp" | |
| #include "utilities/debug.hpp" | |
| #include "utilities/globalDefinitions.hpp" | |
| #include "unittest.hpp" |
I would guess that is all includes you really need here
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.
Yes you're right, I had tested this out beforehand, but was reluctant and not sure if I change something not obvious with this. My test was without utilities/debug.hpp
| ::shmdt(p); | ||
| } | ||
| } | ||
| ::shmdt(p); |
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.
Are these just unrelated cleanups? All of this affects shmget etc, I am not sure what this has to do with large-page mmap.
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.
Forget my question, I now understand the (small) difference
| g_multipage_support.can_use_64K_mmap_pages = (64*K == os::Aix::query_pagesize(p)); | ||
| munmap(p, 64*K); | ||
| } | ||
| } |
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.
Why MAP_SHARED?
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.
Sorry Thomas, I oversaw your question.
I followed the the code of reserve_mmaped_memory(), where MAP_SHARED is used with the following comment:
// Note: MAP_SHARED (instead of MAP_PRIVATE) needed to be able to
// later use msync(MS_INVALIDATE) (see os::uncommit_memory).
int flags = MAP_ANONYMOUS | MAP_SHARED;
I would like to have set the same flags for this test as used later on in real life.
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.
Okay.
src/hotspot/os/aix/os_aix.cpp
Outdated
| // 4k yes 64k (treat 4k stacks as 64k) different loader than java and standard settings | ||
| // LDR_CNTRL can_use_64K_pages_dynamically(mmap or shm) what we do remarks | ||
| // 4K no 4K old systems (aix 5.2) or new systems with AME activated | ||
| // 4k yes 64k (treat 4k stacks as 64k) different loader than java and standardsettings |
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.
standard settings (blank)
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.
In case this was not clear: I meant the typo. So, "s/standardsettings/standard settings" :)
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.
Upps.
| // sys/mman.h defines MAP_ANON_64K beginning with AIX7.3 TL1 | ||
| #ifndef MAP_ANON_64K | ||
| #define MAP_ANON_64K 0x400 | ||
| #endif |
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.
| // sys/mman.h defines MAP_ANON_64K beginning with AIX7.3 TL1 | |
| #ifndef MAP_ANON_64K | |
| #define MAP_ANON_64K 0x400 | |
| #endif | |
| // sys/mman.h defines MAP_ANON_64K beginning with AIX7.3 TL1 | |
| #ifndef MAP_ANON_64K | |
| #define MAP_ANON_64K 0x400 | |
| #else | |
| STATIC_ASSERT(MAP_ANON_64K == 0x400); | |
| #endif |
That adds a test, for when you do have the MAP_ANON_64K constant, that your assumption about its value (0x400) is correct. Needs utilities/debug.hpp, but you should include that anyway.
src/hotspot/os/aix/os_aix.cpp
Outdated
| size_t textpsize; // default text page size (LDR_CNTRL STACKPSIZE) | ||
| bool can_use_64K_pages; // True if we can alloc 64K pages dynamically with Sys V shm. | ||
| bool can_use_16M_pages; // True if we can alloc 16M pages dynamically with Sys V shm. | ||
| bool can_use_64K_mmap_pages;// True if we can alloc 64K pages dynamically with mmap. |
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.
nit: blank after semicolon
| if (real_pagesize != pagesize) { | ||
| log_warning(pagesize)("real page size (" SIZE_FORMAT_X ") differs.", real_pagesize); | ||
| assert(shmid != -1, "shmget failed"); | ||
| if (shmid != -1) { |
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.
Ah, I see what you do here, you now want to handle shmid == -1 for the release build, because I wanted you to change guarantee->assert? Okay. That is very thorough.
| ::shmdt(p); | ||
| } | ||
| } | ||
| ::shmdt(p); |
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.
Forget my question, I now understand the (small) difference
tstuefe
left a comment
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.
Okay
TheRealMDoerr
left a comment
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.
LGTM. Only a few minor nits. Are you planning to change
jdk/src/hotspot/share/runtime/os.cpp
Line 1924 in 747e1e4
| AIX_ONLY(os::vm_page_size() == 4*K ? 4*K : 256*M) |
src/hotspot/os/aix/os_aix.cpp
Outdated
| #include "services/attachListener.hpp" | ||
| #include "services/runtimeService.hpp" | ||
| #include "signals_posix.hpp" | ||
| #include "utilities/debug.hpp" |
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.
Should be sorted alphabetically.
src/hotspot/os/aix/os_aix.cpp
Outdated
| #include <sys/mman.h> | ||
| // sys/mman.h defines MAP_ANON_64K beginning with AIX7.3 TL1 | ||
| #ifndef MAP_ANON_64K | ||
| #define MAP_ANON_64K 0x400 |
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.
Extra whitespace.
| #include <sys/mman.h> | ||
| // sys/mman.h defines MAP_ANON_64K beginning with AIX7.3 TL1 | ||
| #ifndef MAP_ANON_64K | ||
| #define MAP_ANON_64K 0x400 |
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.
Extra whitespace.
src/hotspot/share/runtime/os.cpp
Outdated
| // The logic here is dual to the one in pd_reserve_memory in os_aix.cpp | ||
| const size_t system_allocation_granularity = | ||
| AIX_ONLY(os::vm_page_size() == 4*K ? 4*K : 256*M) | ||
| AIX_ONLY(os::vm_page_size() == 4*K ? 4*K : os::Aix::supports_64K_mmap_pages() ? 64*K : 256*M) |
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.
Please add braces or rewrite it. Does
AIX_ONLY( (!os::Aix::supports_64K_mmap_pages() && os::vm_page_size() == 64*K) ? 256*M : ) os::vm_allocation_granularity() work?
TheRealMDoerr
left a comment
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.
Thanks! LGTM. Maybe @tstuefe can take a look at the latest changes, too.
tstuefe
left a comment
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.
Very good.
|
/integrate |
|
Going to push as commit ced9906.
Your commit was automatically rebased without conflicts. |
Beginning with AIX 7.3 TL1 mmap() supports 64K memory pages. As an enhancement, during the initialization of the VM the availability of this new feature is examined. If the 64K pages are supported the VM will use mmap() with 64K pages instead of shmget()/shmat() with 64K pages due to the bad 256M alignment of shmget()/shmat().
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19771/head:pull/19771$ git checkout pull/19771Update a local copy of the PR:
$ git checkout pull/19771$ git pull https://git.openjdk.org/jdk.git pull/19771/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19771View PR using the GUI difftool:
$ git pr show -t 19771Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19771.diff
Webrev
Link to Webrev Comment