Skip to content

Commit 9aa1af9

Browse files
Patrick Wangakpm00
authored andcommitted
selftests: vm: check numa_available() before operating "merge_across_nodes" in ksm_tests
Patch series "selftests: vm: a few fixup patches". This series contains three fixup patches for vm selftests. They are independent. Please see the patches. This patch (of 3): Currently, ksm_tests operates "merge_across_nodes" with NUMA either enabled or disabled. In a system with NUMA disabled, these operations will fail and output a misleading report given "merge_across_nodes" does not exist in sysfs: ---------------------------- running ./ksm_tests -M -p 10 ---------------------------- f /sys/kernel/mm/ksm/merge_across_nodes fopen: No such file or directory Cannot save default tunables [FAIL] ---------------------- So check numa_available() before those operations to skip them if NUMA is disabled. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Patrick Wang <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 3d3921e commit 9aa1af9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tools/testing/selftests/vm/ksm_tests.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ static bool assert_ksm_pages_count(long dupl_page_count)
221221
static int ksm_save_def(struct ksm_sysfs *ksm_sysfs)
222222
{
223223
if (ksm_read_sysfs(KSM_FP("max_page_sharing"), &ksm_sysfs->max_page_sharing) ||
224-
ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes) ||
224+
numa_available() ? 0 :
225+
ksm_read_sysfs(KSM_FP("merge_across_nodes"), &ksm_sysfs->merge_across_nodes) ||
225226
ksm_read_sysfs(KSM_FP("sleep_millisecs"), &ksm_sysfs->sleep_millisecs) ||
226227
ksm_read_sysfs(KSM_FP("pages_to_scan"), &ksm_sysfs->pages_to_scan) ||
227228
ksm_read_sysfs(KSM_FP("run"), &ksm_sysfs->run) ||
@@ -236,7 +237,8 @@ static int ksm_save_def(struct ksm_sysfs *ksm_sysfs)
236237
static int ksm_restore(struct ksm_sysfs *ksm_sysfs)
237238
{
238239
if (ksm_write_sysfs(KSM_FP("max_page_sharing"), ksm_sysfs->max_page_sharing) ||
239-
ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes) ||
240+
numa_available() ? 0 :
241+
ksm_write_sysfs(KSM_FP("merge_across_nodes"), ksm_sysfs->merge_across_nodes) ||
240242
ksm_write_sysfs(KSM_FP("pages_to_scan"), ksm_sysfs->pages_to_scan) ||
241243
ksm_write_sysfs(KSM_FP("run"), ksm_sysfs->run) ||
242244
ksm_write_sysfs(KSM_FP("sleep_millisecs"), ksm_sysfs->sleep_millisecs) ||
@@ -720,7 +722,8 @@ int main(int argc, char *argv[])
720722

721723
if (ksm_write_sysfs(KSM_FP("run"), 2) ||
722724
ksm_write_sysfs(KSM_FP("sleep_millisecs"), 0) ||
723-
ksm_write_sysfs(KSM_FP("merge_across_nodes"), 1) ||
725+
numa_available() ? 0 :
726+
ksm_write_sysfs(KSM_FP("merge_across_nodes"), 1) ||
724727
ksm_write_sysfs(KSM_FP("pages_to_scan"), page_count))
725728
return KSFT_FAIL;
726729

0 commit comments

Comments
 (0)