From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyril Hrubis Date: Wed, 3 Feb 2016 14:30:53 +0100 Subject: [LTP] [PATCH V2 31/32] vma03: fix page size offset as per page size alignment In-Reply-To: <1452302060-103643-31-git-send-email-raj.khem@gmail.com> References: <1452302060-103643-1-git-send-email-raj.khem@gmail.com> <1452302060-103643-31-git-send-email-raj.khem@gmail.com> Message-ID: <20160203133052.GD30788@rei.lan> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ltp@lists.linux.it 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 > Signed-off-by: Khem Raj > --- > 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