public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] mm/lib: ksm code style fixes.
@ 2012-07-09  9:51 Caspar Zhang
  2012-07-09  9:51 ` [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning Caspar Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Caspar Zhang @ 2012-07-09  9:51 UTC (permalink / raw)
  To: Zhouping Liu; +Cc: LTP list

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]


This patch gives some minor fixes to the following two commits:

f9ae09a lib/mem.c: using read_file to replace the redundant code
60c41a5 lib/mem.c: add _wait_ksmd_done func to wait ksmd finish his job

to make the codes cleaner and easier to understand.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
---
 testcases/kernel/mem/lib/mem.c |   69 +++++++++++++++------------------------
 1 files changed, 27 insertions(+), 42 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-mm-lib-ksm-code-style-fixes.patch --]
[-- Type: text/x-patch; name="0001-mm-lib-ksm-code-style-fixes.patch", Size: 3474 bytes --]

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index f746d06..6283f25 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -133,72 +133,57 @@ static void _check(char *path, long int value)
 {
 	FILE *fp;
 	char buf[BUFSIZ], fullpath[BUFSIZ];
-	long tmp;
+	long actual_val;
 
 
 	snprintf(fullpath, BUFSIZ, "%s%s", PATH_KSM, path);
 	read_file(fullpath, buf);
-	tmp = SAFE_STRTOL(cleanup, buf, LONG_MIN, LONG_MAX);
+	actual_val = SAFE_STRTOL(cleanup, buf, 0, LONG_MAX);
 
-	tst_resm(TINFO, "%s is %ld.", path, tmp);
-	if (tmp != value)
+	tst_resm(TINFO, "%s is %ld.", path, actual_val);
+	if (actual_val != value)
 		tst_resm(TFAIL, "%s is not %ld.", path, value);
 }
 
 static void _wait_ksmd_done(void)
 {
 	char buf[BUFSIZ];
-	long run, pages_shared, pages_sharing, pages_volatile, pages_unshared;
-	long old_run = 0, old_pages_shared = 0, old_pages_sharing = 0,
-	     old_pages_volatile = 0, old_pages_unshared = 0;
-	long tmp;
-	int changed = 1, count = 0;
+	long pages_shared, pages_sharing, pages_volatile, pages_unshared;
+	long old_pages_shared = 0, old_pages_sharing = 0;
+	long old_pages_volatile = 0, old_pages_unshared = 0;
+	int changing = 1, count = 0;
 
-	while(changed) {
-		while(sleep(5))
-			continue;
-
-		changed = 0;
+	while (changing) {
+		sleep(5);
 		count++;
 
-		read_file(PATH_KSM "run", buf);
-		run = SAFE_STRTOL(cleanup, buf, LONG_MIN, LONG_MAX);
-		if (run != old_run) {
-			old_run = run;
-			changed = 1;
-		}
-
 		read_file(PATH_KSM "pages_shared", buf);
-		pages_shared = SAFE_STRTOL(cleanup, buf, LONG_MIN, LONG_MAX);
-		if (pages_shared != old_pages_shared) {
-			old_pages_shared = pages_shared;
-			changed = 1;
-		}
+		pages_shared = SAFE_STRTOL(cleanup, buf, 0, LONG_MAX);
 
 		read_file(PATH_KSM "pages_sharing", buf);
-		pages_sharing = SAFE_STRTOL(cleanup, buf, LONG_MIN, LONG_MAX);
-		if (pages_sharing != old_pages_sharing) {
-			old_pages_sharing = pages_sharing;
-			changed = 1;
-		}
+		pages_sharing = SAFE_STRTOL(cleanup, buf, 0, LONG_MAX);
 
 		read_file(PATH_KSM "pages_volatile", buf);
-		pages_volatile = SAFE_STRTOL(cleanup, buf, LONG_MIN, LONG_MAX);
-		if (pages_volatile != old_pages_volatile) {
-			old_pages_volatile = pages_volatile;
-			changed = 1;
-		}
+		pages_volatile = SAFE_STRTOL(cleanup, buf, 0, LONG_MAX);
 
 		read_file(PATH_KSM "pages_unshared", buf);
-		pages_unshared = SAFE_STRTOL(cleanup, buf, LONG_MIN, LONG_MAX);
-		if (pages_unshared != old_pages_unshared) {
+		pages_unshared = SAFE_STRTOL(cleanup, buf, 0, LONG_MAX);
+
+		if (pages_shared != old_pages_shared ||
+		    pages_sharing != old_pages_sharing ||
+		    pages_volatile != old_pages_volatile ||
+		    pages_unshared != old_pages_unshared) {
+			old_pages_shared   = pages_shared;
+			old_pages_sharing  = pages_sharing;
+			old_pages_volatile = pages_volatile;
 			old_pages_unshared = pages_unshared;
-			changed = 1;
+		} else {
+			changing = 0;
 		}
 	}
 
-	tst_resm(TINFO, "ksm daemon takes %ds to scan all "
-		    "mergeable pages", count * 5);
+	tst_resm(TINFO, "ksm daemon takes %ds to scan all mergeable pages",
+		    count * 5);
 }
 
 static void _group_check(int run, int pages_shared, int pages_sharing,
@@ -736,7 +721,7 @@ long count_numa(long nodes[])
 
 	nnodes = 0;
 	for (i = 0; i <= MAXNODES; i++)
-		if(path_exist(PATH_SYS_SYSTEM "/node/node%d", i))
+		if (path_exist(PATH_SYS_SYSTEM "/node/node%d", i))
 			nodes[nnodes++] = i;
 
 	return nnodes;

[-- Attachment #3: Type: text/plain, Size: 395 bytes --]

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
  2012-07-09  9:51 [LTP] [PATCH 1/2] mm/lib: ksm code style fixes Caspar Zhang
@ 2012-07-09  9:51 ` Caspar Zhang
  2012-07-09 10:11   ` Zhouping Liu
  2012-07-09 11:32   ` Wanlong Gao
  2012-07-09 10:08 ` [LTP] [PATCH 1/2] mm/lib: ksm code style fixes Zhouping Liu
  2012-07-11  0:59 ` Wanlong Gao
  2 siblings, 2 replies; 12+ messages in thread
From: Caspar Zhang @ 2012-07-09  9:51 UTC (permalink / raw)
  To: Zhouping Liu; +Cc: LTP list

[-- Attachment #1: Type: text/plain, Size: 377 bytes --]


for some systems under pressure, we've observed that sleeping 5 seconds
is not sufficient for completing ksm scanning, to fix this, we should
give ksmd more time to scan the mergable pages by increasing sleeping
time to 10s.

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
---
 testcases/kernel/mem/lib/mem.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-mm-lib-increase-sleep-time-in-ksm-scanning.patch --]
[-- Type: text/x-patch; name="0002-mm-lib-increase-sleep-time-in-ksm-scanning.patch", Size: 374 bytes --]

diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
index 6283f25..bb56e36 100644
--- a/testcases/kernel/mem/lib/mem.c
+++ b/testcases/kernel/mem/lib/mem.c
@@ -154,7 +154,7 @@ static void _wait_ksmd_done(void)
 	int changing = 1, count = 0;
 
 	while (changing) {
-		sleep(5);
+		sleep(10);
 		count++;
 
 		read_file(PATH_KSM "pages_shared", buf);

[-- Attachment #3: Type: text/plain, Size: 395 bytes --]

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] mm/lib: ksm code style fixes.
  2012-07-09  9:51 [LTP] [PATCH 1/2] mm/lib: ksm code style fixes Caspar Zhang
  2012-07-09  9:51 ` [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning Caspar Zhang
@ 2012-07-09 10:08 ` Zhouping Liu
  2012-07-09 12:00   ` Wanlong Gao
  2012-07-11  0:59 ` Wanlong Gao
  2 siblings, 1 reply; 12+ messages in thread
From: Zhouping Liu @ 2012-07-09 10:08 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: LTP list



----- Original Message -----
> From: "Caspar Zhang" <caspar@casparzhang.com>
> To: "Zhouping Liu" <zliu@redhat.com>
> Cc: "LTP list" <ltp-list@lists.sourceforge.net>
> Sent: Monday, July 9, 2012 5:51:52 PM
> Subject: [PATCH 1/2] mm/lib: ksm code style fixes.
> 
> 
> This patch gives some minor fixes to the following two commits:
> 
> f9ae09a lib/mem.c: using read_file to replace the redundant code
> 60c41a5 lib/mem.c: add _wait_ksmd_done func to wait ksmd finish his
> job
> 
> to make the codes cleaner and easier to understand.

Looks good for me.

Reviewed-by: Zhouping Liu <zliu@redhat.com>


> 
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
> ---
>  testcases/kernel/mem/lib/mem.c |   69
>  +++++++++++++++------------------------
>  1 files changed, 27 insertions(+), 42 deletions(-)
> 
> 

-- 
Thanks,
Zhouping

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
  2012-07-09  9:51 ` [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning Caspar Zhang
@ 2012-07-09 10:11   ` Zhouping Liu
  2012-07-09 11:32   ` Wanlong Gao
  1 sibling, 0 replies; 12+ messages in thread
From: Zhouping Liu @ 2012-07-09 10:11 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: LTP list



----- Original Message -----
> From: "Caspar Zhang" <caspar@casparzhang.com>
> To: "Zhouping Liu" <zliu@redhat.com>
> Cc: "LTP list" <ltp-list@lists.sourceforge.net>
> Sent: Monday, July 9, 2012 5:51:53 PM
> Subject: [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
> 
> 
> for some systems under pressure, we've observed that sleeping 5
> seconds
> is not sufficient for completing ksm scanning, to fix this, we should
> give ksmd more time to scan the mergable pages by increasing sleeping
> time to 10s.

I agreed your fixing.

Reviewed-by: Zhouping Liu <zliu@redhat.com>

> 
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
> ---
>  testcases/kernel/mem/lib/mem.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> 

-- 
Thanks,
Zhouping

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
  2012-07-09  9:51 ` [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning Caspar Zhang
  2012-07-09 10:11   ` Zhouping Liu
@ 2012-07-09 11:32   ` Wanlong Gao
  2012-07-09 12:37     ` Caspar Zhang
  1 sibling, 1 reply; 12+ messages in thread
From: Wanlong Gao @ 2012-07-09 11:32 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: LTP list

On 07/09/2012 05:51 PM, Caspar Zhang wrote:
> 
> for some systems under pressure, we've observed that sleeping 5 seconds
> is not sufficient for completing ksm scanning, to fix this, we should
> give ksmd more time to scan the mergable pages by increasing sleeping
> time to 10s.

If 5s is not enough, isn't we waiting here already?

Thanks,
Wanlong Gao

> 
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
> ---
>  testcases/kernel/mem/lib/mem.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> 
> 
> 
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] mm/lib: ksm code style fixes.
  2012-07-09 10:08 ` [LTP] [PATCH 1/2] mm/lib: ksm code style fixes Zhouping Liu
@ 2012-07-09 12:00   ` Wanlong Gao
  0 siblings, 0 replies; 12+ messages in thread
From: Wanlong Gao @ 2012-07-09 12:00 UTC (permalink / raw)
  To: Zhouping Liu; +Cc: LTP list

On 07/09/2012 06:08 PM, Zhouping Liu wrote:
> 
> 
> ----- Original Message -----
>> From: "Caspar Zhang" <caspar@casparzhang.com>
>> To: "Zhouping Liu" <zliu@redhat.com>
>> Cc: "LTP list" <ltp-list@lists.sourceforge.net>
>> Sent: Monday, July 9, 2012 5:51:52 PM
>> Subject: [PATCH 1/2] mm/lib: ksm code style fixes.
>>
>>
>> This patch gives some minor fixes to the following two commits:
>>
>> f9ae09a lib/mem.c: using read_file to replace the redundant code
>> 60c41a5 lib/mem.c: add _wait_ksmd_done func to wait ksmd finish his
>> job
>>
>> to make the codes cleaner and easier to understand.
> 
> Looks good for me.
> 
> Reviewed-by: Zhouping Liu <zliu@redhat.com>

Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

> 
> 
>>
>> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
>> ---
>>  testcases/kernel/mem/lib/mem.c |   69
>>  +++++++++++++++------------------------
>>  1 files changed, 27 insertions(+), 42 deletions(-)
>>
>>
> 



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
  2012-07-09 11:32   ` Wanlong Gao
@ 2012-07-09 12:37     ` Caspar Zhang
  2012-07-09 13:10       ` Wanlong Gao
  0 siblings, 1 reply; 12+ messages in thread
From: Caspar Zhang @ 2012-07-09 12:37 UTC (permalink / raw)
  To: gaowanlong; +Cc: LTP list

On 07/09/2012 07:32 PM, Wanlong Gao wrote:
> On 07/09/2012 05:51 PM, Caspar Zhang wrote:
>>
>> for some systems under pressure, we've observed that sleeping 5 seconds
>> is not sufficient for completing ksm scanning, to fix this, we should
>> give ksmd more time to scan the mergable pages by increasing sleeping
>> time to 10s.
>
> If 5s is not enough, isn't we waiting here already?

Sorry, I'm not catching you... :-( the problem currently we encounter is 
that if 5s given, all ksm values (pages_sharing, pages_shared, etc) 
might remain the same between before and after sleeping, so the 
wait_ksmd function could exit. But in fact the kernel could be busy 
under pressure and it just needs more than 5s to merge the same page. 
Using 10s as polling interval can make sure if ksm values remains the 
same between each loop, it should indicates that ksmd has done scanning 
correctly.

Thanks,
Caspar

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
  2012-07-09 12:37     ` Caspar Zhang
@ 2012-07-09 13:10       ` Wanlong Gao
  2012-07-09 14:15         ` Caspar Zhang
  0 siblings, 1 reply; 12+ messages in thread
From: Wanlong Gao @ 2012-07-09 13:10 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: LTP list

On 07/09/2012 08:37 PM, Caspar Zhang wrote:
> On 07/09/2012 07:32 PM, Wanlong Gao wrote:
>> On 07/09/2012 05:51 PM, Caspar Zhang wrote:
>>>
>>> for some systems under pressure, we've observed that sleeping 5 seconds
>>> is not sufficient for completing ksm scanning, to fix this, we should
>>> give ksmd more time to scan the mergable pages by increasing sleeping
>>> time to 10s.
>>
>> If 5s is not enough, isn't we waiting here already?
> 
> Sorry, I'm not catching you... :-( the problem currently we encounter is that if 5s given, all ksm values (pages_sharing, pages_shared, etc) might remain the same between before and after sleeping, so the wait_ksmd function could exit. But in fact the kernel could be busy under pressure and it just needs more than 5s to merge the same page. Using 10s as polling interval can make sure if ksm values remains the same between each loop, it should indicates that ksmd has done scanning correctly.
> 

Oops, it's a serious problem, so can we first wait for changing and then wait for not changing?
I'm afraid that hard coded sleep time can't do the right thing on some systems.

Thanks,
Wanlong Gao

> Thanks,
> Caspar
> 



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
  2012-07-09 13:10       ` Wanlong Gao
@ 2012-07-09 14:15         ` Caspar Zhang
  2012-07-09 15:51           ` Zhouping Liu
  0 siblings, 1 reply; 12+ messages in thread
From: Caspar Zhang @ 2012-07-09 14:15 UTC (permalink / raw)
  To: gaowanlong; +Cc: LTP list

On 07/09/2012 09:10 PM, Wanlong Gao wrote:
> On 07/09/2012 08:37 PM, Caspar Zhang wrote:
>> On 07/09/2012 07:32 PM, Wanlong Gao wrote:
>>> On 07/09/2012 05:51 PM, Caspar Zhang wrote:
>>>>
>>>> for some systems under pressure, we've observed that sleeping 5
>>>> seconds is not sufficient for completing ksm scanning, to fix
>>>> this, we should give ksmd more time to scan the mergable pages
>>>> by increasing sleeping time to 10s.
>>>
>>> If 5s is not enough, isn't we waiting here already?
>>
>> Sorry, I'm not catching you... :-( the problem currently we
>> encounter is that if 5s given, all ksm values (pages_sharing,
>> pages_shared, etc) might remain the same between before and after
>> sleeping, so the wait_ksmd function could exit. But in fact the
>> kernel could be busy under pressure and it just needs more than 5s
>> to merge the same page. Using 10s as polling interval can make sure
>> if ksm values remains the same between each loop, it should
>> indicates that ksmd has done scanning correctly.
>>
>
> Oops, it's a serious problem, so can we first wait for changing and
> then wait for not changing? I'm afraid that hard coded sleep time
> can't do the right thing on some systems.

IMO the current implementation does the same thing as you suggested. We 
wait for certain interval (5s for now, 10s proposed), and check if ksm 
values increased, if still changing, continue next sleep interval. 
Adding a "wait-for-not-changing" in fact has the same effect as 
increasing the original sleep time.

theoretically, sleeping interval should be as larger as possible, but it 
will cost unnecessary running time if the interval is set too big in the 
this case. I'd say 10s is a "for-now-best-practice" during my several 
running (both w/ and w/o pressure). Besides, I'm not sure how ksm 
developers think of current ksm performance, but I think if ksmd takes 
more than 10s to merge two same pages, it will be a big performance issue.

I'd suggest everyone interested in this case try 10s on your systems to 
see if it works. Also if you have idea of design a flexible waiting 
time, it will be perfect.

Thanks,
Caspar

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
  2012-07-09 14:15         ` Caspar Zhang
@ 2012-07-09 15:51           ` Zhouping Liu
  2012-07-10  0:25             ` Wanlong Gao
  0 siblings, 1 reply; 12+ messages in thread
From: Zhouping Liu @ 2012-07-09 15:51 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: LTP list



----- Original Message -----
> From: "Caspar Zhang" <caspar@casparzhang.com>
> To: gaowanlong@cn.fujitsu.com
> Cc: "Zhouping Liu" <zliu@redhat.com>, "LTP list" sourceforge.net>
> Sent: Monday, July 9, 2012 10:15:17 PM
> Subject: Re: [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
> 
> On 07/09/2012 09:10 PM, Wanlong Gao wrote:
> > On 07/09/2012 08:37 PM, Caspar Zhang wrote:
> >> On 07/09/2012 07:32 PM, Wanlong Gao wrote:
> >>> On 07/09/2012 05:51 PM, Caspar Zhang wrote:
> >>>>
> >>>> for some systems under pressure, we've observed that sleeping 5
> >>>> seconds is not sufficient for completing ksm scanning, to fix
> >>>> this, we should give ksmd more time to scan the mergable pages
> >>>> by increasing sleeping time to 10s.
> >>>
> >>> If 5s is not enough, isn't we waiting here already?
> >>
> >> Sorry, I'm not catching you... :-( the problem currently we
> >> encounter is that if 5s given, all ksm values (pages_sharing,
> >> pages_shared, etc) might remain the same between before and after
> >> sleeping, so the wait_ksmd function could exit. But in fact the
> >> kernel could be busy under pressure and it just needs more than 5s
> >> to merge the same page. Using 10s as polling interval can make
> >> sure
> >> if ksm values remains the same between each loop, it should
> >> indicates that ksmd has done scanning correctly.
> >>
> >
> > Oops, it's a serious problem, so can we first wait for changing and
> > then wait for not changing? I'm afraid that hard coded sleep time
> > can't do the right thing on some systems.
> 
> IMO the current implementation does the same thing as you suggested.
> We
> wait for certain interval (5s for now, 10s proposed), and check if
> ksm
> values increased, if still changing, continue next sleep interval.
> Adding a "wait-for-not-changing" in fact has the same effect as
> increasing the original sleep time.
> 
> theoretically, sleeping interval should be as larger as possible, but
> it
> will cost unnecessary running time if the interval is set too big in
> the
> this case. I'd say 10s is a "for-now-best-practice" during my several
> running (both w/ and w/o pressure). Besides, I'm not sure how ksm
> developers think of current ksm performance, but I think if ksmd
> takes
> more than 10s to merge two same pages, it will be a big performance
> issue.

yes, I think so.

and 5s interval is enough, I tested it on several low-memory/dull systems
during composing the patch, it's all OK.
But in order to cover more different systems, IMO, I also proposed 10s,
and it shouldn't be more bigger, or it will be a defect of ksm performance.

-- 
Thanks,
Zhouping

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
  2012-07-09 15:51           ` Zhouping Liu
@ 2012-07-10  0:25             ` Wanlong Gao
  0 siblings, 0 replies; 12+ messages in thread
From: Wanlong Gao @ 2012-07-10  0:25 UTC (permalink / raw)
  To: Zhouping Liu; +Cc: LTP list

On 07/09/2012 11:51 PM, Zhouping Liu wrote:
> 
> 
> ----- Original Message -----
>> From: "Caspar Zhang" <caspar@casparzhang.com>
>> To: gaowanlong@cn.fujitsu.com
>> Cc: "Zhouping Liu" <zliu@redhat.com>, "LTP list" sourceforge.net>
>> Sent: Monday, July 9, 2012 10:15:17 PM
>> Subject: Re: [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning
>>
>> On 07/09/2012 09:10 PM, Wanlong Gao wrote:
>>> On 07/09/2012 08:37 PM, Caspar Zhang wrote:
>>>> On 07/09/2012 07:32 PM, Wanlong Gao wrote:
>>>>> On 07/09/2012 05:51 PM, Caspar Zhang wrote:
>>>>>>
>>>>>> for some systems under pressure, we've observed that sleeping 5
>>>>>> seconds is not sufficient for completing ksm scanning, to fix
>>>>>> this, we should give ksmd more time to scan the mergable pages
>>>>>> by increasing sleeping time to 10s.
>>>>>
>>>>> If 5s is not enough, isn't we waiting here already?
>>>>
>>>> Sorry, I'm not catching you... :-( the problem currently we
>>>> encounter is that if 5s given, all ksm values (pages_sharing,
>>>> pages_shared, etc) might remain the same between before and after
>>>> sleeping, so the wait_ksmd function could exit. But in fact the
>>>> kernel could be busy under pressure and it just needs more than 5s
>>>> to merge the same page. Using 10s as polling interval can make
>>>> sure
>>>> if ksm values remains the same between each loop, it should
>>>> indicates that ksmd has done scanning correctly.
>>>>
>>>
>>> Oops, it's a serious problem, so can we first wait for changing and
>>> then wait for not changing? I'm afraid that hard coded sleep time
>>> can't do the right thing on some systems.
>>
>> IMO the current implementation does the same thing as you suggested.
>> We
>> wait for certain interval (5s for now, 10s proposed), and check if
>> ksm
>> values increased, if still changing, continue next sleep interval.
>> Adding a "wait-for-not-changing" in fact has the same effect as
>> increasing the original sleep time.
>>
>> theoretically, sleeping interval should be as larger as possible, but
>> it
>> will cost unnecessary running time if the interval is set too big in
>> the
>> this case. I'd say 10s is a "for-now-best-practice" during my several
>> running (both w/ and w/o pressure). Besides, I'm not sure how ksm
>> developers think of current ksm performance, but I think if ksmd
>> takes
>> more than 10s to merge two same pages, it will be a big performance
>> issue.
> 
> yes, I think so.
> 
> and 5s interval is enough, I tested it on several low-memory/dull systems
> during composing the patch, it's all OK.
> But in order to cover more different systems, IMO, I also proposed 10s,
> and it shouldn't be more bigger, or it will be a defect of ksm performance.

Ok, no objection.

Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

> 



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 1/2] mm/lib: ksm code style fixes.
  2012-07-09  9:51 [LTP] [PATCH 1/2] mm/lib: ksm code style fixes Caspar Zhang
  2012-07-09  9:51 ` [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning Caspar Zhang
  2012-07-09 10:08 ` [LTP] [PATCH 1/2] mm/lib: ksm code style fixes Zhouping Liu
@ 2012-07-11  0:59 ` Wanlong Gao
  2 siblings, 0 replies; 12+ messages in thread
From: Wanlong Gao @ 2012-07-11  0:59 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: LTP list

On 07/09/2012 05:51 PM, Caspar Zhang wrote:
> 
> This patch gives some minor fixes to the following two commits:
> 
> f9ae09a lib/mem.c: using read_file to replace the redundant code
> 60c41a5 lib/mem.c: add _wait_ksmd_done func to wait ksmd finish his job
> 
> to make the codes cleaner and easier to understand.
> 
> Signed-off-by: Caspar Zhang <caspar@casparzhang.com>

Pushed this series. Thank you.

Wanlong Gao

> ---
>  testcases/kernel/mem/lib/mem.c |   69 +++++++++++++++------------------------
>  1 files changed, 27 insertions(+), 42 deletions(-)
> 
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> 
> 
> 
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2012-07-11  0:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-09  9:51 [LTP] [PATCH 1/2] mm/lib: ksm code style fixes Caspar Zhang
2012-07-09  9:51 ` [LTP] [PATCH 2/2] mm/lib: increase sleep time in ksm scanning Caspar Zhang
2012-07-09 10:11   ` Zhouping Liu
2012-07-09 11:32   ` Wanlong Gao
2012-07-09 12:37     ` Caspar Zhang
2012-07-09 13:10       ` Wanlong Gao
2012-07-09 14:15         ` Caspar Zhang
2012-07-09 15:51           ` Zhouping Liu
2012-07-10  0:25             ` Wanlong Gao
2012-07-09 10:08 ` [LTP] [PATCH 1/2] mm/lib: ksm code style fixes Zhouping Liu
2012-07-09 12:00   ` Wanlong Gao
2012-07-11  0:59 ` Wanlong Gao

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