-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Read exactly two tokens from Linux transparent huge pages sysfs config #37065
Conversation
…ing while loop There was an unexpected and hard-to-spot issue here: the /sys/kernel/mm/transparent_hugepage/enabled file contains three entries, and the std::ifstream reader was reading two values on each loop iteration, resulting in incorrect behaviour.
This comment has been minimized.
This comment has been minimized.
Thanks for fixing this! 🎉 Note to whoever lands thisThe commit message needs to be amended to include:
and be wrapped at 72 columns. |
Thanks @RaisinTen, and my mistake regarding the commit message linewrapping, I'll note that for next time. I was considering adding a small amount of test coverage here; it's been a while since I've coded much C++ so it could take a little while, but that offer stands if it'd be useful. I'd also vaguely considered refactoring this to support an arbitrary number of tokens in the hugepages flag file (by checking for presence of any of a -- possibly |
I'm curious to know how you would approach testing this. For reference, here is an already existing test file to test
I tried to edit the file locally by following this guide:
So, I don't think using a |
It looks tricky to test this logic while providing fixtures that simulate the contents of I noticed that there is existing use of the
Ok, agreed - using a set may be over-engineering the problem. |
… their length or ordering
Would be interesting to have that test. 👍 |
Co-authored-by: Darshan Sen <[email protected]>
…stem huge tables configuration on Linux-based systems
…o determine huge tables enabled state based on the contents of a configuration stream
…led in the configuration stream
For reference (it doesn't look like this should affect the changes suggested here) - the logic to produce the contents of the |
The most recent commits (excluding lint fixes) extract two separate functions to, respectively, read the Linux huge tables configuration, and determine whether huge tables are configured as enabled. I've now learned that although One possibility might be to change the linkage of the I'll puzzle over this for a little while and any guidance would be appreciated. |
Despite some further investigation, I'm currently uncertain about how to proceed, given questions around how to make the (non-public) |
Thanks for trying to test this out. I'm not sure about testing this either if there is no way to mock the file. If the code isn't testable, I think it would be better to stick to your initial commit as a fix for the issue you brought up as it solves its purpose and is more concise and also readable. Additionally, I would consider adding a comment mentioning the link to the logic behind producing the kernel config file that you mentioned as I didn't come across any better explanation of the file format. I'm adding a cc @gabrielschulhof would you please take a look at this fix when you're free? |
Thanks @RaisinTen; I agree with all of your analysis there. For the purposes of not hiding history, I'll walk back to the initial change by reverting the subsequent commits, and then I'll add an explanatory comment. |
…ion" This reverts commit 434e8b8.
This comment has been minimized.
This comment has been minimized.
As an aside: reading this Percona article about the performance impact of transparent huge pages has led me to look further back to the Linux v2.6.38 series kernel where it looks like the feature was introduced (ref). It would be good to take time and aim for maximal version compatibility in any changes applied here. |
(initially it does appear that the file format has remained stable since introduction, but there could be debug options or other good reasons why the format changed in the interim) |
… relevant function is declared on
There are one or two further simplifications possible here:
|
The edits described in my previous comment are available to read as code here. After checking that the changes in this pull request are valid, we could discuss whether the extra edits are worth including. |
@RaisinTen Please could you re-add the |
LGTM! |
There was an unexpected and hard-to-spot issue here: the /sys/kernel/mm/transparent_hugepage/enabled file contains three entries, and the std::ifstream reader was reading two values on each loop iteration, resulting in incorrect behaviour. Fixes: #37064 PR-URL: #37065 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in a0c0875 🎉 |
There was an unexpected and hard-to-spot issue here: the /sys/kernel/mm/transparent_hugepage/enabled file contains three entries, and the std::ifstream reader was reading two values on each loop iteration, resulting in incorrect behaviour. Fixes: #37064 PR-URL: #37065 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
There was an unexpected and hard-to-spot issue here: the /sys/kernel/mm/transparent_hugepage/enabled file contains three entries, and the std::ifstream reader was reading two values on each loop iteration, resulting in incorrect behaviour. Fixes: #37064 PR-URL: #37065 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
There was an unexpected and hard-to-spot issue here: the
/sys/kernel/mm/transparent_hugepage/enabled
file contains three entries, and the std::ifstream reader was reading two values on each loop iteration, resulting in incorrect behaviour.Resolves #37064
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.