All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] testcases/kernel/mem/vma/vma01.c: fix the right start/end memory address
@ 2012-03-24 17:30 Wang Sheng-Hui
  2012-04-01 10:17 ` Caspar Zhang
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Sheng-Hui @ 2012-03-24 17:30 UTC (permalink / raw)
  To: ltp-list, shubham

For a VMA with memory range 6*ps, regardless of it's two 3*ps or
one single 6*ps, t is the start addr of the vma, u = t + 3*ps, and
the end addr is t + 6*ps.

For the check process, x should start from t, not u, and later check
for the second 3*ps should resume from u.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
---
 testcases/kernel/mem/vma/vma01.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/mem/vma/vma01.c b/testcases/kernel/mem/vma/vma01.c
index 398d7a1..4b66121 100644
--- a/testcases/kernel/mem/vma/vma01.c
+++ b/testcases/kernel/mem/vma/vma01.c
@@ -112,12 +112,12 @@ static void check_vma(void)
 		printf("child : u = %p\n", u);
 		memset(u, 2, ps);
 
-		x = get_end_addr(u, MAPS_FILE);
-		if (x == u + 6*ps)
+		x = get_end_addr(t, MAPS_FILE);
+		if (x == t + 6*ps)
 			exit(1);
-		if (x == u + 3*ps) {
-			y = get_end_addr(x, MAPS_FILE);
-			if (y == x + 3*ps)
+		if (x == u) {
+			y = get_end_addr(u, MAPS_FILE);
+			if (y == u + 3*ps)
 				exit(0);
 		}
 		exit(255);
-- 
1.7.1

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] testcases/kernel/mem/vma/vma01.c: fix the right start/end memory address
  2012-03-24 17:30 [LTP] [PATCH] testcases/kernel/mem/vma/vma01.c: fix the right start/end memory address Wang Sheng-Hui
@ 2012-04-01 10:17 ` Caspar Zhang
  0 siblings, 0 replies; 2+ messages in thread
From: Caspar Zhang @ 2012-04-01 10:17 UTC (permalink / raw)
  To: Wang Sheng-Hui; +Cc: ltp-list

On 03/25/2012 01:30 AM, Wang Sheng-Hui wrote:
> For a VMA with memory range 6*ps, regardless of it's two 3*ps or
> one single 6*ps, t is the start addr of the vma, u = t + 3*ps, and
> the end addr is t + 6*ps.
> 
> For the check process, x should start from t, not u, and later check
> for the second 3*ps should resume from u.

Hi Shenghui, thanks for the patch.

However, your patch doesn't work in some situation, e.g.: when t mmapped
at highest addr (it is the most common situation), which makes t+3*ps
over boundary, so mmap will map to another addr near t+3*ps. So I
propose for the following increment fix:

 static void check_vma(void)
 {
        int status;
-       void *t, *u, *x, *y;
+       void *t, *u, *v, *x, *y;

-       t = mmap(NULL, 3*ps, PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0, 0);
+       v = mmap(NULL, ps, PROT_READ, MAP_ANONYMOUS|MAP_PRIVATE, 0, 0);
+       if (v == MAP_FAILED)
+               tst_brkm(TBROK|TERRNO, cleanup, "mmap");
+       t = mmap(v - 6*ps, 3*ps, PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,
0, 0);
        if (t == MAP_FAILED)
                tst_brkm(TBROK|TERRNO, cleanup, "mmap");
        memset(t, 1, ps);

A new addr v introduced before other mappings, used to locate the
highest addr. And in order not to be merged with other mappings, v is
mapped with READ-only prot.

result using your patch w/o my increment patch:

# ./vma01
parent: t = 0x7f82dd437000
child : u = 0x7f82dd434000
vma01       0  TINFO  :  s = 0x7f82dd437000, t = 0x7f82dd43a000
vma01       1  TBROK  :  unexpected VMA found.
vma01       2  TBROK  :  Remaining cases broken

result using your patch w/ my increment patch:

# ./vma01
parent: t = 0x7f418066f000
child : u = 0x7f4180672000
vma01       0  TINFO  :  s = 0x7f418066f000, t = 0x7f4180672000
vma01       0  TINFO  :  s = 0x7f4180672000, t = 0x7f4180675000
vma01       1  TPASS  :  two 3*ps VMAs found.

Thoughts?

Thanks,
Caspar

> 
> Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
> ---
>  testcases/kernel/mem/vma/vma01.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/testcases/kernel/mem/vma/vma01.c b/testcases/kernel/mem/vma/vma01.c
> index 398d7a1..4b66121 100644
> --- a/testcases/kernel/mem/vma/vma01.c
> +++ b/testcases/kernel/mem/vma/vma01.c
> @@ -112,12 +112,12 @@ static void check_vma(void)
>  		printf("child : u = %p\n", u);
>  		memset(u, 2, ps);
>  
> -		x = get_end_addr(u, MAPS_FILE);
> -		if (x == u + 6*ps)
> +		x = get_end_addr(t, MAPS_FILE);
> +		if (x == t + 6*ps)
>  			exit(1);
> -		if (x == u + 3*ps) {
> -			y = get_end_addr(x, MAPS_FILE);
> -			if (y == x + 3*ps)
> +		if (x == u) {
> +			y = get_end_addr(u, MAPS_FILE);
> +			if (y == u + 3*ps)
>  				exit(0);
>  		}
>  		exit(255);


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2012-04-01 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-24 17:30 [LTP] [PATCH] testcases/kernel/mem/vma/vma01.c: fix the right start/end memory address Wang Sheng-Hui
2012-04-01 10:17 ` Caspar Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.