[LTP] [PATCH V2 31/32] vma03: fix page size offset as per page size alignment

Cyril Hrubis chrubis@suse.cz
Wed Feb 3 14:30:53 CET 2016


Hi!
> the offset the param of mmap2() doesn't align the page size, but,
> this param allow must be a multiple of the page size as returned
> by sysconf(_SC_PAGE_SIZE).meanwhile offset * 4096 must be a
> multiple of the system page size, so modify the input param of offset
> pgoff = (ULONG_MAX - 1)&(~((pgsz-1)>>12));
> 
> Signed-off-by: Chuang Dong <Chuang.Dong@windriver.com>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  testcases/kernel/mem/vma/vma03.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/mem/vma/vma03.c b/testcases/kernel/mem/vma/vma03.c
> index ad8a7b4..a539233 100644
> --- a/testcases/kernel/mem/vma/vma03.c
> +++ b/testcases/kernel/mem/vma/vma03.c
> @@ -85,7 +85,7 @@ int main(int argc, char *argv[])
>  		if (fd == -1)
>  			tst_brkm(TBROK | TERRNO, NULL, "open %s", TESTFILE);
>  
> -		pgoff = ULONG_MAX - 1;
> +		pgoff = (ULONG_MAX - 1)&(~((pgsz-1)>>12));
>  		map = mmap2(NULL, pgsz, PROT_READ | PROT_WRITE, MAP_PRIVATE,
>  			    fd, pgoff);

Presumbly your system has page size larger than 4096 right? And the
mmap() fails with EINVAL since the pgoff * 4096 is not aligned. It would
be good to add note about the specific arch that needs this fix to the
commit message. Otherwise it looks good.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the Ltp mailing list