syscalls/madvise02.c: Fix ENOMEM errno tests
PATCH 1/1 syscalls/madvise02.c: Fix ENOMEM errno tests
With commit 212a4b9 on some distros(e.g. RHEL6.9/7.5), running madvise02 got the following error:
------------------------------------------------------
...
madvise02.c:181: CONF: MADV_UNMERGEABLE is not supported madvise02.c:196: FAIL: madvise succeeded unexpectedly madvise02.c:196: FAIL: madvise succeeded unexpectedly madvise02.c:181: CONF: MADV_WILLNEED is not supported
...
-------------------------------------------------------
If MAP_SIZE was equal to a pagesize, shared_anon may get the same address which was a part of file2 and already unmapped, so that the whole address of file2 became valid again. Subsequently, ENOMEM errno tests succeeded, so changing the order of mmaps to make shared_anon get different address.
--- testcases/kernel/syscalls/madvise/madvise02.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/madvise/madvise02.c +2 -2
@@ -156,11 +156,11 @@ static void setup(void)SAFE_FSTAT (fd, &st); file1 =SAFE_MMAP (0 , st.st_size,PROT_READ ,MAP_SHARED , fd,0 ); + shared_anon =SAFE_MMAP (0 ,MAP_SIZE ,PROT_READ ,MAP_SHARED | +MAP_ANONYMOUS ,-1 ,0 ); file2 =SAFE_MMAP (0 , st.st_size,PROT_READ ,MAP_SHARED , fd,0 );SAFE_MUNMAP (file2 + st.st_size - pagesize, pagesize); file3 =SAFE_MMAP (0 , st.st_size,PROT_READ ,MAP_PRIVATE , fd,0 ); - shared_anon =SAFE_MMAP (0 ,MAP_SIZE ,PROT_READ ,MAP_SHARED | -MAP_ANONYMOUS ,-1 ,0 ); nonalign = file1 +100 ;
Signature · 1 line
1.8.3.1
PATCH 1/1 syscalls/madvise02.c: Fix ENOMEM errno tests
----- Original Message -----
Quoted 11 lines
With commit 212a4b9 on some distros(e.g. RHEL6.9/7.5), running madvise02 got the following error:
------------------------------------------------------
...
madvise02.c:181: CONF:MADV_UNMERGEABLEis not supported madvise02.c:196: FAIL: madvise succeeded unexpectedly madvise02.c:196: FAIL: madvise succeeded unexpectedly madvise02.c:181: CONF:MADV_WILLNEEDis not supported
...
-------------------------------------------------------
Quoted 7 lines
If
MAP_SIZEwas equal to a pagesize,shared_anonmay get the same address which was a part of file2 and already unmapped, so that the whole address of file2 became valid again. Subsequently, ENOMEM errno tests succeeded, so changing the order of mmaps to makeshared_anonget different address.Signed-off-by Xiao Yang <[email protected]>
Hi,
I changed patch to move MUNMAP() instead and added comment explaining why.
You can review it here:
https://github.com/linux-test-project/ltp/commit/030e321ce1dfdc3a8daf7ef5a5b7bb7734cf2d9f
Thanks,
Jan
PATCH 1/1 syscalls/madvise02.c: Fix ENOMEM errno tests
Quoted 18 lines · Jan Stancek
----- Original Message -----
Quoted 17 lines
With commit 212a4b9 on some distros(e.g. RHEL6.9/7.5), running madvise02 got the following error:
------------------------------------------------------
...
madvise02.c:181: CONF:MADV_UNMERGEABLEis not supported madvise02.c:196: FAIL: madvise succeeded unexpectedly madvise02.c:196: FAIL: madvise succeeded unexpectedly madvise02.c:181: CONF:MADV_WILLNEEDis not supported
...
-------------------------------------------------------If
MAP_SIZEwas equal to a pagesize,shared_anonmay get the same address which was a part of file2 and already unmapped, so that the whole address of file2 became valid again. Subsequently, ENOMEM errno tests succeeded, so changing the order of mmaps to makeshared_anonget different address.
Quoted 8 lines
Quoted 1 line
Signed-off-by Xiao Yang<[email protected]>Hi,
I changed patch to move
MUNMAP()instead and added comment explaining why.You can review it here:
https://github.com/linux-test-project/ltp/commit/030e321ce1dfdc3a8daf7ef5a5b7bb7734cf2d9f
Hi Jan,
Thanks for your quick review, and it seems better to me. :-)
Thanks,
Xiao Yang
Quoted 5 lines
Thanks,
Jan