aboutsummaryrefslogtreecommitdiff
path: root/testcases/kernel/mem
diff options
context:
space:
mode:
authorAndrea Arcangeli <aarcange@redhat.com>2022-05-11 21:38:30 -0400
committerCyril Hrubis <chrubis@suse.cz>2022-05-13 10:49:22 +0200
commit17e9ae697a340242c49188ace12a60cd3bc95a53 (patch)
treeb8b0b52cca62fe103020da3a58959f96422aaa98 /testcases/kernel/mem
parent9042d74e55e112e5a09cf8fd7a2b50d81eeb4abb (diff)
downloadltp-17e9ae697a340242c49188ace12a60cd3bc95a53.tar.gz
ksm: fix occasional page_volatile false positives
The KSM scan keeps running while checking the KSM status in sysfs, but during the KSM scan the the rmap_items in the stale unstable tree of the old pass are removed from it and are later reinserted in the new unstable tree of the current pass, leading to some page_volatile false positives. The fix is stop the KSM scan temporarily while the KSM status is being read from sysfs. For reference here's an instance of the fixed false positives: mem.c:255: TFAIL: pages_volatile is not 0 but 1. mem.c:255: TFAIL: pages_unshared is not 1 but 0. Reported-by: Eirik Fuller <efuller@redhat.com> Co-developed-by: Li Wang <liwang@redhat.com> Tested-by: Li Wang <liwang@redhat.com> Tested-by: Eirik Fuller <efuller@redhat.com> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Reviewed-by: Li Wang <liwang@redhat.com> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Diffstat (limited to 'testcases/kernel/mem')
-rw-r--r--testcases/kernel/mem/lib/mem.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 090569ebb..8ddd7adf7 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -261,14 +261,31 @@ static void final_group_check(int run, int pages_shared, int pages_sharing,
int pages_volatile, int pages_unshared,
int sleep_millisecs, int pages_to_scan)
{
+ int ksm_run_orig;
+
tst_res(TINFO, "check!");
check("run", run);
+
+ /*
+ * Temporarily stop the KSM scan during the checks: during the
+ * KSM scan the rmap_items in the stale unstable tree of the
+ * old pass are removed from it and are later reinserted in
+ * the new unstable tree of the current pass. So if the checks
+ * run in the race window between removal and re-insertion, it
+ * can lead to unexpected false positives where page_volatile
+ * is elevated and page_unshared is recessed.
+ */
+ SAFE_FILE_SCANF(PATH_KSM "run", "%d", &ksm_run_orig);
+ SAFE_FILE_PRINTF(PATH_KSM "run", "0");
+
check("pages_shared", pages_shared);
check("pages_sharing", pages_sharing);
check("pages_volatile", pages_volatile);
check("pages_unshared", pages_unshared);
check("sleep_millisecs", sleep_millisecs);
check("pages_to_scan", pages_to_scan);
+
+ SAFE_FILE_PRINTF(PATH_KSM "run", "%d", ksm_run_orig);
}
void ksm_group_check(int run, int pages_shared, int pages_sharing,