Skip to content
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: adjust THP sysfs config token retrieval and file closure #37187

Merged
merged 1 commit into from
Feb 17, 2021
Merged

src: adjust THP sysfs config token retrieval and file closure #37187

merged 1 commit into from
Feb 17, 2021

Conversation

jayaddison
Copy link
Contributor

This change is a refactor that builds upon and extends #37065. The pull request title might not be ideal; I'm open to other suggestions.

It includes the modifications described in #37065 (comment):

  • A std::ifstream object's close member function will automatically be called when the object is destroyed; this may enable some conditional-clause rewrites
  • Since we are only reading a fixed number of tokens, we could sequentially read these using a single variable

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Feb 2, 2021
@jayaddison
Copy link
Contributor Author

PS: Apologies for not properly handling column width limits in git commit messages (again, despite mentioning that I would). It seemed preferable to retain existing commit history since this branch had already been mentioned in a previous comment.

@RaisinTen
Copy link
Contributor

@jayaddison could you please get rid of the merge commit? It tends to break our tooling. :/

@jayaddison
Copy link
Contributor Author

Thanks @RaisinTen. Given that a fast-forward merge from the master branch doesn't appear to be an option from the original proposed changes in this pull request, I think I'll incorporate your changes, which look good, then rebase and force-push as long as all's well after continuous integration.

@jayaddison
Copy link
Contributor Author

@RaisinTen Are you able to convert this into a 'Draft' pull request until I apply a few of the suggestions here? (I don't appear to have permissions, and I'd like to avoid unnecessarily running CI jobs while applying a few changes)

@aduh95 aduh95 marked this pull request as draft February 3, 2021 09:55
@jayaddison
Copy link
Contributor Author

Thanks, @aduh95!

@jayaddison jayaddison marked this pull request as ready for review February 3, 2021 12:03
@jayaddison
Copy link
Contributor Author

Closing and re-opening the pull request momentarily in order to run the full continuous integration suite.

@jayaddison jayaddison closed this Feb 3, 2021
@jayaddison jayaddison reopened this Feb 3, 2021
@nodejs-github-bot
Copy link
Collaborator

@RaisinTen RaisinTen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 3, 2021
@RaisinTen RaisinTen added the review wanted PRs that need reviews. label Feb 5, 2021
@RaisinTen
Copy link
Contributor

Still LGTM.

@nodejs-github-bot
Copy link
Collaborator

@jayaddison
Copy link
Contributor Author

Thanks @RaisinTen - there's at least one more change that I'm considering adding, which is whether to move the constant comparison values (false, [always], [madvise]) to the left-hand side of the comparison operators. Especially in the case of the function call, this really shouldn't be necessary, but I worry a little that this could be extremely frequently run code, so if there are small changes that can reduce risk, those may be worthwhile.

The part of this code that still leaves me with some concern in this area is the use of the (very overloaded) >> operator.

@RaisinTen
Copy link
Contributor

Sure, go ahead! :)
What do you intend to use in place of the >> operator?

@RaisinTen RaisinTen removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 6, 2021
@jayaddison
Copy link
Contributor Author

I don't yet have a replacement in mind; the operator looks correct and safe in the current context, but any operator that has a non-trivial number of different behaviours based on surrounding datatypes seems worth being wary of.

The surrounding code could change in future for a variety of reasons, and in the absence of unit test coverage, finding ways to make it more likely that the code would fail to compile if it became incorrect would be useful.

The tradeoff is that changing the code itself has to be done carefully to ensure that it remains correct, and that requires equally careful review and attention. That is a counter-balancing effect that makes me slightly reluctant to make any significant modifications.

@jayaddison
Copy link
Contributor Author

I'll pause on any further changes here now, pending continued review.

@nodejs-github-bot
Copy link
Collaborator

@RaisinTen RaisinTen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 7, 2021
@jayaddison
Copy link
Contributor Author

This may be over-analysis, but on second thoughts, I don't think that moving the constant expression to the left at

if (false == config_stream.good()) {
is a worthwhile tradeoff against the readability of the code.

The . member access operator has higher precedence than the logical not operator (ref) so it should be clear to readers familiar with C++ that no operator overloading is applied to the boolean result of good.

tl;dr - if (!config_stream.good()) seems better than if (false == config_stream.good()), and I'll apply that change in a moment

@RaisinTen
Copy link
Contributor

I agree, it looks clearer to me too.

@nodejs-github-bot
Copy link
Collaborator

@nodejs nodejs deleted a comment from 0501814314 Feb 9, 2021
@nodejs-github-bot
Copy link
Collaborator

@aduh95
Copy link
Contributor

aduh95 commented Feb 15, 2021

Forced-push to remove the merge commits. I wasn't sure what commit message to use, can you confirm the one I've picked is OK?

@nodejs-github-bot
Copy link
Collaborator

@jayaddison
Copy link
Contributor Author

Thanks @aduh95 - yep, that commit message looks good to me 👍

@nodejs-github-bot
Copy link
Collaborator

@jayaddison
Copy link
Contributor Author

@aduh95 Actually, perhaps it's a little pedantic, but maybe it's better to use the word 'adjust' rather than 'refactor' in the commit message since there is a small behaviour change here. I'm just thinking of any users who might be reading through a changelog/commit log. I'll apply that commit message update and re-force-push momentarily.

@jayaddison jayaddison changed the title src: refactor THP sysfs config token retrieval and file closure src: adjust THP sysfs config token retrieval and file closure Feb 16, 2021
@nodejs-github-bot
Copy link
Collaborator

@aduh95
Copy link
Contributor

aduh95 commented Feb 16, 2021

@jayaddison alright, thanks! FYI, Node.js collaborators can amend the commit message when landing, so we can avoid having to re-spawn a CI job and land the PR quicker. Anyways, CI is running, this can land once it's green.

@jayaddison
Copy link
Contributor Author

@aduh95 Ok, thanks; still learning the ropes a bit here!

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@aduh95
Copy link
Contributor

aduh95 commented Feb 17, 2021

Landed in 9b32762

@aduh95 aduh95 merged commit 9b32762 into nodejs:master Feb 17, 2021
@jayaddison
Copy link
Contributor Author

Thanks @aduh95!

@jayaddison jayaddison deleted the transparent-hugepage-read-further-adjustments branch February 17, 2021 09:50
targos pushed a commit that referenced this pull request Feb 28, 2021
targos pushed a commit that referenced this pull request May 1, 2021
@danielleadams danielleadams mentioned this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. review wanted PRs that need reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants