Skip to contentSkip to conversation

selftests/vm: fix "add thp collapse file and tmpfs testing" for tmpfs

PATCH New Zach O'Keefe 1 participant 1 message Sep 13, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/vm: fix "add thp collapse file and tmpfs testing" for tmpfs

In write_settings() and save_settings() we properly only read/write /sys/block/<device>/queue/read_ahead_kb if the test file is not backed by tmpfs. However, in get_finfo(), we unconditionally attempt to resolve the major/minor device pair and search for device interface, which we fail to do when the device is the null device (major 0), as is the case when stat(2)'ing a tmpfs-backed file.

Only resolve path to queue/read_ahead_kb when dealing with non-tmpfs files.

Fixes 64b9fb1fa904 ("selftests/vm: add thp collapse file and tmpfs testing")
---
 tools/testing/selftests/vm/khugepaged.c | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/vm/khugepaged.c +2 -0
index 702f64b3aa08..ad46fdb57d78 100644
@@ -453,6 +453,8 @@ static void get_finfo(const char *dir)
 		exit(EXIT_FAILURE);
 	}
 	finfo.type = fs.f_type == TMPFS_MAGIC ? VMA_SHMEM : VMA_FILE;
+	if (finfo.type == VMA_SHMEM)
+		return;
 
 	/* Find owning device's queue/read_ahead_kb control */
 	if (snprintf(path, sizeof(path), "/sys/dev/block/%d:%d/uevent",
Signature · 1 line
2.37.2.789.g6183377224-goog