public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/1] ksm: fix occasional page_volatile false positives
@ 2022-05-12  1:38 Andrea Arcangeli
  2022-05-12  1:38 ` [LTP] [PATCH 1/1] " Andrea Arcangeli
  0 siblings, 1 reply; 4+ messages in thread
From: Andrea Arcangeli @ 2022-05-12  1:38 UTC (permalink / raw)
  To: ltp; +Cc: Eirik Fuller

Hello everyone,

Some LTP KSM tests (ksm0[2-4]) occasionally reported some
page_volatile elevated failure that turned out to be a false positive
from LTP.

This proposed fix has been verified by running the tests in a loop
like this: "while ./ksm02; do : ; done".

Thanks,
Andrea

Andrea Arcangeli (1):
  ksm: fix occasional page_volatile false positives

 testcases/kernel/mem/lib/mem.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 1/1] ksm: fix occasional page_volatile false positives
  2022-05-12  1:38 [LTP] [PATCH 0/1] ksm: fix occasional page_volatile false positives Andrea Arcangeli
@ 2022-05-12  1:38 ` Andrea Arcangeli
  2022-05-13  1:51   ` Li Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Andrea Arcangeli @ 2022-05-12  1:38 UTC (permalink / raw)
  To: ltp; +Cc: Eirik Fuller

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 <liwan@redhat.com>
Tested-by: Li Wang <liwan@redhat.com>
Tested-by: Eirik Fuller <efuller@redhat.com>
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---
 testcases/kernel/mem/lib/mem.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

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,


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/1] ksm: fix occasional page_volatile false positives
  2022-05-12  1:38 ` [LTP] [PATCH 1/1] " Andrea Arcangeli
@ 2022-05-13  1:51   ` Li Wang
  2022-05-13  8:51     ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Li Wang @ 2022-05-13  1:51 UTC (permalink / raw)
  To: Andrea Arcangeli, Cyril Hrubis; +Cc: Eirik Fuller, LTP List


[-- Attachment #1.1: Type: text/plain, Size: 1170 bytes --]

Andrea Arcangeli <aarcange@redhat.com> wrote:

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 <liwan@redhat.com>
> Tested-by: Li Wang <liwan@redhat.com>
>

This email address is valid but I prefer to use the my
name liwang@ for better remembering :).
(Anyway this doesn't matter, we can ignore this.)



> Tested-by: Eirik Fuller <efuller@redhat.com>
> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
>

Reviewed-by: Li Wang <liwang@redhat.com>

@Cryril, I vote for adding this patch in the new release.
Plz take this into consideration, thanks.


-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 2711 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH 1/1] ksm: fix occasional page_volatile false positives
  2022-05-13  1:51   ` Li Wang
@ 2022-05-13  8:51     ` Cyril Hrubis
  0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2022-05-13  8:51 UTC (permalink / raw)
  To: Li Wang; +Cc: Eirik Fuller, LTP List

Hi!
> Reviewed-by: Li Wang <liwang@redhat.com>
> 
> @Cryril, I vote for adding this patch in the new release.
> Plz take this into consideration, thanks.

Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-13  8:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-12  1:38 [LTP] [PATCH 0/1] ksm: fix occasional page_volatile false positives Andrea Arcangeli
2022-05-12  1:38 ` [LTP] [PATCH 1/1] " Andrea Arcangeli
2022-05-13  1:51   ` Li Wang
2022-05-13  8:51     ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox