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
8261401: Add sanity check for UseSHM large pages similar to the one used with hugetlb large pages #2488
8261401: Add sanity check for UseSHM large pages similar to the one used with hugetlb large pages #2488
Changes from 5 commits
c092a28
a1b34aa
1ae85f9
376b223
bf6cbce
6a2606b
681dc92
a9d8c0f
8354e74
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3564,6 +3564,28 @@ bool os::Linux::hugetlbfs_sanity_check(bool warn, size_t page_size) { | |||||||||
return result; | ||||||||||
} | ||||||||||
|
||||||||||
bool os::Linux::shm_hugetlbfs_sanity_check(bool warn, size_t page_size) { | ||||||||||
// Try to create a large shared memory segment. | ||||||||||
int shmid = shmget(IPC_PRIVATE, page_size, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W); | ||||||||||
if (shmid == -1) { | ||||||||||
// Possible reasons for shmget failure: | ||||||||||
// 1. shmmax is too small for the request. | ||||||||||
// > check shmmax value: cat /proc/sys/kernel/shmmax | ||||||||||
// > increase shmmax value: echo "0xffffffff" > /proc/sys/kernel/shmmax | ||||||||||
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'd avoid using a 32 bit constant on potentially 64 bit systems. According to that same man page, the limit on 64 bits is 127 TB which is more than the suggested 4 GB :) The man page talks about 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. The comment is a copy of the old one where we actually use
Suggested change
Might be good enough. I will also update the original comment. |
||||||||||
// 2. not enough large page memory. | ||||||||||
// > check available large pages: cat /proc/meminfo | ||||||||||
// > increase amount of large pages: | ||||||||||
// echo new_value > /proc/sys/vm/nr_hugepages | ||||||||||
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. This is just my opinion, but I would prefer to refer to some generic documentation about these options (and use the "new" locations in 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 agree, the documentation I usually refer to is: Since our SHM-support currently only handles the default large page size I think we should suggest to use:
Suggested change
|
||||||||||
if (warn) { | ||||||||||
warning("Large pages using UseSHM are not configured on this system."); | ||||||||||
} | ||||||||||
return false; | ||||||||||
} | ||||||||||
// Managed to create a segment, now delete it. | ||||||||||
shmctl(shmid, IPC_RMID, NULL); | ||||||||||
return true; | ||||||||||
} | ||||||||||
|
||||||||||
// From the coredump_filter documentation: | ||||||||||
// | ||||||||||
// - (bit 0) anonymous private memory | ||||||||||
|
@@ -3748,7 +3770,16 @@ bool os::Linux::setup_large_page_type(size_t page_size) { | |||||||||
UseHugeTLBFS = false; | ||||||||||
} | ||||||||||
|
||||||||||
return UseSHM; | ||||||||||
if (UseSHM) { | ||||||||||
bool warn_on_failure = !FLAG_IS_DEFAULT(UseSHM); | ||||||||||
if (shm_hugetlbfs_sanity_check(warn_on_failure, page_size)) { | ||||||||||
return true; | ||||||||||
} | ||||||||||
UseSHM = false; | ||||||||||
} | ||||||||||
|
||||||||||
log_warning(pagesize)("UseLargePages disabled, no large pages configured and available on the system."); | ||||||||||
kstefanj marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
return false; | ||||||||||
} | ||||||||||
|
||||||||||
void os::large_page_init() { | ||||||||||
|
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 think the flags should contain the
SHM_HUGE_*
flags (considering large pages) similar to hugetlbfs for proper checking to avoid the failure like in JDK-8261636 reported just recently for the same reason.According to the man pages] such flags exist.
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 would agree if the later usage of
shmget()
would make use of those flags but it don't. We might want o add a CR for enabling use of other page sizes than the default large page size for SHM as well. But there is also discussions about trying to remove this SHM support.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 am good with creating a CR for that. We can always close it later.