mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
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: https://github.com/nodejs/node/issues/37064 PR-URL: https://github.com/nodejs/node/pull/37065 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
11d3e71f80
commit
00309eea27
1 file changed
+3
-1
@@ -260,6 +260,8 @@ struct text_region FindNodeTextRegion() {
|
||||
bool IsTransparentHugePagesEnabled() {
|
||||
std::ifstream ifs;
|
||||
|
||||
// File format reference:
|
||||
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/huge_memory.c?id=13391c60da3308ed9980de0168f74cce6c62ac1d#n163
|
||||
ifs.open("/sys/kernel/mm/transparent_hugepage/enabled");
|
||||
if (!ifs) {
|
||||
PrintWarning("could not open /sys/kernel/mm/transparent_hugepage/enabled");
|
||||
@@ -268,7 +270,7 @@ bool IsTransparentHugePagesEnabled() {
|
||||
|
||||
std::string always, madvise;
|
||||
if (ifs.is_open()) {
|
||||
while (ifs >> always >> madvise) {}
|
||||
ifs >> always >> madvise;
|
||||
}
|
||||
ifs.close();
|
||||
|
||||
|
||||
Reference in new issue
Block a user