Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9946c11

Browse filesBrowse files
jayaddisondanielleadams
authored andcommitted
src: read exactly two tokens from Linux THP sysfs config
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 <raisinten@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 67c9a8e commit 9946c11
Copy full SHA for 9946c11

File tree

Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Collapse file

‎src/large_pages/node_large_page.cc‎

Copy file name to clipboardExpand all lines: src/large_pages/node_large_page.cc
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ struct text_region FindNodeTextRegion() {
260260
bool IsTransparentHugePagesEnabled() {
261261
std::ifstream ifs;
262262

263+
// File format reference:
264+
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/huge_memory.c?id=13391c60da3308ed9980de0168f74cce6c62ac1d#n163
263265
ifs.open("/sys/kernel/mm/transparent_hugepage/enabled");
264266
if (!ifs) {
265267
PrintWarning("could not open /sys/kernel/mm/transparent_hugepage/enabled");
@@ -268,7 +270,7 @@ bool IsTransparentHugePagesEnabled() {
268270

269271
std::string always, madvise;
270272
if (ifs.is_open()) {
271-
while (ifs >> always >> madvise) {}
273+
ifs >> always >> madvise;
272274
}
273275
ifs.close();
274276

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.