public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] ksm: wait 3 increments of full_scans before checking the results
@ 2011-02-14  6:14 Han Pingtian
  2011-02-14  6:25 ` Garrett Cooper
  0 siblings, 1 reply; 9+ messages in thread
From: Han Pingtian @ 2011-02-14  6:14 UTC (permalink / raw)
  To: ltp-list

The KSM developer tell us that we should wait 3~5 increments of the
/sys/kernel/mm/ksm/full_scans before checking ksm* testcases's results.
Otherwise, there may be some stuck pages that cause the testing failed.

Signed-off-by: Han Pingtian <phan@redhat.com>
---
 testcases/kernel/mem/lib/mem.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 1a53359..98cca12 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -298,8 +298,31 @@ void group_check(int run, int pages_shared, int pages_sharing,
 		int pages_volatile, int pages_unshared,
 		int sleep_millisecs, int pages_to_scan)
 {
-        /* 5 seconds for ksm to scan pages. */
-	sleep(5);
+	int fd;
+	char buf[BUFSIZ];
+	int old_num, new_num;
+
+	fd = open("/sys/kernel/mm/ksm/full_scans", O_RDONLY);
+	if (fd < 0)
+		tst_brkm(TBROK|TERRNO, cleanup, "open");
+
+        /* 1 seconds for ksm to scan pages. */
+	sleep(1);
+
+	/* wait 3 increments of full_scans */
+	if (read(fd, buf, BUFSIZ) < 0)
+		tst_brkm(TBROK|TERRNO, cleanup, "read");
+	old_num = new_num = atoi(buf);
+	lseek(fd, 0, SEEK_SET);
+	while (new_num < old_num * 3) {
+		sleep(1);
+		if (read(fd, buf, BUFSIZ) < 0)
+			tst_brkm(TBROK|TERRNO, cleanup, "read");
+		new_num = atoi(buf);
+		lseek(fd, 0, SEEK_SET);
+	}
+	close(fd);
+
 	tst_resm(TINFO, "check!");
 	check("run", run);
 	check("pages_shared", pages_shared);
-- 
1.7.1

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2011-02-24  5:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-14  6:14 [LTP] [PATCH] ksm: wait 3 increments of full_scans before checking the results Han Pingtian
2011-02-14  6:25 ` Garrett Cooper
2011-02-15  3:13   ` Han Pingtian
2011-02-15 14:37     ` Garrett Cooper
2011-02-16  2:59       ` Han Pingtian
2011-02-21  5:43         ` Han Pingtian
2011-02-23  8:46           ` Garrett Cooper
2011-02-23 10:12             ` Han Pingtian
2011-02-24  5:33               ` Garrett Cooper

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