Skip to contentSkip to conversation

ksm: wait 3 increments of full_scans before checking the results

PATCH Superseded Han Pingtian 2 participants 9 messages Feb 14, 2011 – Feb 24, 2011

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ksm: wait 3 increments of full_scans before checking the results

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.

---
 testcases/kernel/mem/lib/mem.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)
testcases/kernel/mem/lib/mem.c +25 -2
index 1a53359..98cca12 100644
@@ -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);
Signature · 12 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw
Quoted 3 lines · Han Pingtian

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.

A common mistake is thinking that sleep(3) is non-interruptable.
This proposed patch also has style-violations and is missing error checking around lseek, et all. Please fix these items according to the style guide.
Thanks,
-Garrett

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
Quoted 11 lines · Garrett Cooper
Quoted 3 lines · Han Pingtian

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.

A common mistake is thinking that sleep(3) is non-interruptable.
This proposed patch also has style-violations and is missing error checking around lseek, et all. Please fix these items according to the style guide.
Thanks,
-Garrett

Thanks reviewing. The patched function will be called by testcases/kernel/mem/ksm/ksm* , which all call tst_sig() in setup().
So I think we have processed the interruptable problem of sleep().

I'll submit new patch.

Quoted 11 lines

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Signature · 16 lines
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#3 lore raw
Quoted 12 lines · Han Pingtian
Quoted 11 lines · Garrett Cooper
Quoted 3 lines · Han Pingtian

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.

    A common mistake is thinking that sleep(3) is non-interruptable. This proposed patch also has style-violations and is missing error checking around lseek, et all. Please fix these items according to the style guide.
Thanks,
-Garrett

Quoted 3 lines

Thanks reviewing. The patched function will be called by testcases/kernel/mem/ksm/ksm* , which all call tst_sig() in setup(). So I think we have processed the interruptable problem of sleep().

Are you sure? I suggest reading the RETURN VALUES section of
sleep(3), along with the notes about SA_RESTART in signal(7), and compare that with what's implemented in the signal(3) equivalent in tst_sig.
HTH,
-Garrett

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#4 lore raw
Quoted 13 lines · Garrett Cooper
Quoted 12 lines · Han Pingtian
Quoted 11 lines · Garrett Cooper
Quoted 3 lines · Han Pingtian

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.

    A common mistake is thinking that sleep(3) is non-interruptable. This proposed patch also has style-violations and is missing error checking around lseek, et all. Please fix these items according to the style guide.
Thanks,
-Garrett

Quoted 8 lines
Quoted 3 lines

Thanks reviewing. The patched function will be called by testcases/kernel/mem/ksm/ksm* , which all call tst_sig() in setup(). So I think we have processed the interruptable problem of sleep().

Are you sure? I suggest reading the RETURN VALUES section of
sleep(3), along with the notes about SA_RESTART in signal(7), and compare that with what's implemented in the signal(3) equivalent in tst_sig.

Thanks. I'll try to make sure the first sleep(1) gets executed to let KSM to scan pages. The second sleep(1) is in a while loop, so I think we needn't do the same thing to it. I'll attach the v3 patch, please review. Thanks.

Quoted 13 lines

HTH,
-Garrett

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Signature · 5 lines
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY

From d88cc9ab633b757d4a878754cae1063246a516e3 Mon Sep 17 00:00:00 2001
From: Han Pingtian <[email protected]>
Date: Mon, 14 Feb 2011 11:47:59 +0800
Subject: [PATCH] ksm: wait 3 increments of full_scans before checking the results

The KSM developer tells 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.

---
 testcases/kernel/mem/lib/mem.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)
testcases/kernel/mem/lib/mem.c +28 -2
index 1a53359..435620f 100644
@@ -298,8 +298,34 @@ 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;
+
+	/* 1 seconds for ksm to scan pages. */
+	while (sleep(1) == 1)
+	    continue;
+
+	fd = open("/sys/kernel/mm/ksm/full_scans", O_RDONLY);
+	if (fd == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "open");
+
+	/* wait 3 increments of full_scans */
+	if (read(fd, buf, BUFSIZ) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "read");
+	old_num = new_num = atoi(buf);
+	if (lseek(fd, 0, SEEK_SET) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "lseek");
+	while (new_num < old_num * 3) {
+		sleep(1);
+		if (read(fd, buf, BUFSIZ) < 0)
+			tst_brkm(TBROK|TERRNO, cleanup, "read");
+		new_num = atoi(buf);
+		if (lseek(fd, 0, SEEK_SET) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "lseek");
+	}
+	close(fd);
+
 	tst_resm(TINFO, "check!");
 	check("run", run);
 	check("pages_shared", pages_shared);
Signature · 1 line
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#5 lore raw

Hello Garrett,

Any objection to merge this patch?

Thanks.

Quoted 118 lines · Han Pingtian
Quoted 13 lines · Garrett Cooper
Quoted 12 lines · Han Pingtian
Quoted 11 lines · Garrett Cooper
Quoted 3 lines · Han Pingtian

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.

    A common mistake is thinking that sleep(3) is non-interruptable. This proposed patch also has style-violations and is missing error checking around lseek, et all. Please fix these items according to the style guide.
Thanks,
-Garrett

Quoted 8 lines
Quoted 3 lines

Thanks reviewing. The patched function will be called by testcases/kernel/mem/ksm/ksm* , which all call tst_sig() in setup(). So I think we have processed the interruptable problem of sleep().

Are you sure? I suggest reading the RETURN VALUES section of
sleep(3), along with the notes about SA_RESTART in signal(7), and compare that with what's implemented in the signal(3) equivalent in tst_sig.

Thanks. I'll try to make sure the first sleep(1) gets executed to let KSM to scan pages. The second sleep(1) is in a while loop, so I think we needn't do the same thing to it. I'll attach the v3 patch, please review. Thanks.

Quoted 13 lines

HTH,
-Garrett

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Signature · 5 lines
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY
Quoted 1 line

From d88cc9ab633b757d4a878754cae1063246a516e3 Mon Sep 17 00:00:00 2001

From: Han Pingtian <[email protected]>
Date: Mon, 14 Feb 2011 11:47:59 +0800
Subject: [PATCH] ksm: wait 3 increments of full_scans before checking the results

The KSM developer tells 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.

---
 testcases/kernel/mem/lib/mem.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)
testcases/kernel/mem/lib/mem.c +28 -2
index 1a53359..435620f 100644
@@ -298,8 +298,34 @@ 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;
+
+	/* 1 seconds for ksm to scan pages. */
+	while (sleep(1) == 1)
+	    continue;
+
+	fd = open("/sys/kernel/mm/ksm/full_scans", O_RDONLY);
+	if (fd == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "open");
+
+	/* wait 3 increments of full_scans */
+	if (read(fd, buf, BUFSIZ) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "read");
+	old_num = new_num = atoi(buf);
+	if (lseek(fd, 0, SEEK_SET) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "lseek");
+	while (new_num < old_num * 3) {
+		sleep(1);
+		if (read(fd, buf, BUFSIZ) < 0)
+			tst_brkm(TBROK|TERRNO, cleanup, "read");
+		new_num = atoi(buf);
+		if (lseek(fd, 0, SEEK_SET) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "lseek");
+	}
+	close(fd);
+
 	tst_resm(TINFO, "check!");
 	check("run", run);
 	check("pages_shared", pages_shared);
Signature · 14 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Signature · 16 lines
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#6 lore raw
Quoted 3 lines · Han Pingtian

Hello Garrett,

Any objection to merge this patch?

Please resubmit a git-formatted email with the patch attached. Thanks,
-Garrett

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#7 lore raw
Quoted 8 lines · Garrett Cooper
Quoted 3 lines · Han Pingtian

Hello Garrett,

Any objection to merge this patch?

Please resubmit a git-formatted email with the patch attached. Thanks,
-Garrett

This is the rebuilded patch, sorry for the inconvenience.

Signature · 5 lines
Han Pingtian
Quality Engineer
hpt @ #kernel-qe
Red Hat, Inc
Freedom ... courage ... Commitment ... ACCOUNTABILITY

From 1345942c75c55a9702df1cd66a2402c64c430d52 Mon Sep 17 00:00:00 2001
From: Han Pingtian <[email protected]>
Date: Mon, 14 Feb 2011 11:47:59 +0800
Subject: [PATCH] ksm: wait 3 increments of full_scans before checking the results

The KSM developer tells 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.

---
 testcases/kernel/mem/lib/mem.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)
testcases/kernel/mem/lib/mem.c +28 -2
index 1a53359..435620f 100644
@@ -298,8 +298,34 @@ 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;
+
+	/* 1 seconds for ksm to scan pages. */
+	while (sleep(1) == 1)
+	    continue;
+
+	fd = open("/sys/kernel/mm/ksm/full_scans", O_RDONLY);
+	if (fd == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "open");
+
+	/* wait 3 increments of full_scans */
+	if (read(fd, buf, BUFSIZ) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "read");
+	old_num = new_num = atoi(buf);
+	if (lseek(fd, 0, SEEK_SET) == -1)
+		tst_brkm(TBROK|TERRNO, cleanup, "lseek");
+	while (new_num < old_num * 3) {
+		sleep(1);
+		if (read(fd, buf, BUFSIZ) < 0)
+			tst_brkm(TBROK|TERRNO, cleanup, "read");
+		new_num = atoi(buf);
+		if (lseek(fd, 0, SEEK_SET) == -1)
+			tst_brkm(TBROK|TERRNO, cleanup, "lseek");
+	}
+	close(fd);
+
 	tst_resm(TINFO, "check!");
 	check("run", run);
 	check("pages_shared", pages_shared);
Signature · 1 line
1.7.1

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#8 lore raw
Quoted 9 lines · Han Pingtian
Quoted 6 lines · Garrett Cooper
Quoted 3 lines · Han Pingtian

Hello Garrett,

Any objection to merge this patch?

Please resubmit a git-formatted email with the patch attached.

This is the rebuilded patch, sorry for the inconvenience.

Committed -- thanks!
-Garrett

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list