-
Notifications
You must be signed in to change notification settings - Fork 21
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
issue: 3884801 Check for resident hugepages to avoid SIGBUS #204
base: vNext
Are you sure you want to change the base?
Conversation
cfce2e8
to
51c2340
Compare
b04003d
to
437bb39
Compare
In a containerized environment mmap() beyond the hugepages limit can be successful, but a further memory access triggers SIGBUS and terminates the process. Check that all the allocated hugepages are resident with mincore() to avoid the SIGBUS issue. Cost of the feature depends on the allocation size and hugepage size: - 32GB with 2MB pages takes 4400 us - 32GB with 1GB pages takes 11 us - 32MB with 2MB pages takes 5-6 us We expect a big memory preallocation at the start (2GB by default) and rare 32MB allocations during warmup period. Therefore, this feature can add several additional 5us latency spikes during warmup period. Signed-off-by: Dmytro Podgornyi <[email protected]>
437bb39
to
eedc045
Compare
The parameter disables the check for resident hugepages. The check can be expensive and, on the other hand, can be irrelevant based on the system configuration. Therefore, disabling it reduces the initialization time which can be crucial in some scenarios. The name for the parameter is chosen to extend the idea of reducing initialization time in the future. Signed-off-by: Dmytro Podgornyi <[email protected]>
for (size_t i = 0; rc == 0 && i < pages_nr; ++i) { | ||
unsigned char vec; | ||
rc = mincore(page_ptr, 1, &vec); | ||
resident_nr += rc == 0 ? (vec & 1U) : 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.
Do we really need to count or we can just fail on the first bad hugepage ptr?
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.
we can stop, however, this is expected to be very unlikely case, so no point in this optimization and I'd suggest choosing the more readable variant (not necessarily current variant)
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 that stopping on the first one may create simpler impl, maybe even without many different dbg_logs.
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.
Also we can loop while ptr < end_ptr ... and avoid many different vars and stuff
Description
In a containerized environment mmap() beyond the hugepages limit can be successful, but a further memory access triggers SIGBUS and terminates the process. Check that all the allocated hugepages are resident with mincore() to avoid the SIGBUS issue.
Cost of the feature depends on the allocation size and hugepage size:
We expect a big memory preallocation at the start (2GB by default) and
rare 32MB allocations during warmup period. Therefore, this feature can
add several additional 5us latency spikes during warmup period.
What
Check for resident hugepages after allocation.
Why ?
Avoid SIGBUS in containerized environments.
Change type
What kind of change does this PR introduce?
Check list