-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
src: further simplify large pages code #32576
src: further simplify large pages code #32576
Conversation
* Clean up and co-locate explanation for what the code does to the top of the file. * Remove extraneous headers. * Remove the need for `OnScopeLeave` replacing it with a pair of labels `fail:` and `done:`. Re: nodejs#32570 Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
return -1; | ||
status = -1; | ||
done: | ||
if (nmem != nullptr && nmem != MAP_FAILED && munmap(nmem, size) == -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.
nit: maybe possible to avoid code repetition here what do you think ?
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.
Oh, right, with a (nmem != nullptr && ... ) || (tmem != nullptr && ... )
. @jasnell had suggested that previously.
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.
Well, actually, you wanna munmap
them both, even if the first one fails. So, you may PrintSystemError()
because the first munmap failed, because the second munmap failed, twice because they both failed, or not at all.
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.
AFAICT to avoid this code repetition we have to go all the way to #32570 which I feel is a bit too much.
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 could do __attribute__((cleanup("DeleteMmapPointer")))
for nmem
and tmem
but I'm not sure how portable that is and we would have two levels of indirection because we'd have to store nmem
along with size
in some structure which would be passed to the deleter. Same for tmem
.
Again, it seems like too much complication for avoiding a single repetition.
I’d prefer #32570 here. |
of the file.
OnScopeLeave
replacing it with a pair of labelsfail:
anddone:
.Re: #32570
Signed-off-by: @gabrielschulhof
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesThis is an alternative to #32570.