direct_io: diotest4: fix mips MAP_SHARED/MAP_FIXED mmap
PATCH 1/1 direct_io: diotest4: fix mips MAP_SHARED/MAP_FIXED mmap
Hongzhi reports that this test is failing on mips64 with 5.1+:
diotest4 10 TBROK : diotest4.c:368: can't mmap file: Invalid argument diotest4 11 TBROK : diotest4.c:368: Remaining cases broken
I could reproduce it on emulated 5kc-malta, running 5.2.0-rc7.
Test is trying to map in area immediately following heap as MAP_SHARED, but it's using wrong alignment, because MMAP_GRANULARITY is always defined as single page - lapi/mmap.h is not including config.h.
Usage of MAP_FIXED in test seems unnecessary, so drop that too and let the kernel pick an address.
--- include/lapi/mmap.h | 2 ++ testcases/kernel/io/direct_io/diotest4.c | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-)
include/lapi/mmap.h +2 -0
@@ -19,6 +19,8 @@#ifndef LAPI_MMAP_H__ #define LAPI_MMAP_H__ +#include "config.h" +#ifndef MAP_HUGETLB # define MAP_HUGETLB 0x40000#endif
testcases/kernel/io/direct_io/diotest4.c +2 -6
@@ -352,18 +352,14 @@ int main(int argc, char *argv[]) total++;/* Test-10: read, write to a mmaped file */ - shm_base = (char *)(((long )sbrk (0 ) + (shmsz -1 )) & ~(shmsz -1 )); -if (shm_base ==NULL ) { -tst_brkm (TBROK , cleanup,"sbrk failed: %s" ,strerror (errno)); - } offset =4096 ; count = bufsize;if ((fd =open (filename,O_DIRECT |O_RDWR )) <0 ) {tst_brkm (TBROK , cleanup,"can't open %s: %s" , filename,strerror (errno)); } - shm_base =mmap (shm_base,0x100000 ,PROT_READ |PROT_WRITE , -MAP_SHARED |MAP_FIXED , fd,0 ); + shm_base =mmap (0 ,0x100000 ,PROT_READ |PROT_WRITE , +MAP_SHARED , fd,0 );if (shm_base == (caddr_t) -1 ) {tst_brkm (TBROK , cleanup,"can't mmap file: %s" ,strerror (errno));
Signature · 1 line
1.8.3.1
PATCH 1/1 direct_io: diotest4: fix mips MAP_SHARED/MAP_FIXED mmap
Hi!
include/lapi/mmap.h line 26
Quoted 13 lines
include/lapi/mmap.h +2
-0@@ -19,6 +19,8 @@#ifndef LAPI_MMAP_H__ #define LAPI_MMAP_H__ +#include "config.h" +#ifndef MAP_HUGETLB # define MAP_HUGETLB 0x40000#endif
Huh, this looks completely unrelevant to the patch itself, or do I miss something?
Quoted 15 lines
testcases/kernel/io/direct_io/diotest4.c +0
-4@@ -352,18 +352,14 @@ int main(int argc, char *argv[]) total++;/* Test-10: read, write to a mmaped file */ - shm_base = (char *)(((long )sbrk (0 ) + (shmsz -1 )) & ~(shmsz -1 )); -if (shm_base ==NULL ) { -tst_brkm (TBROK , cleanup,"sbrk failed: %s" ,strerror (errno)); - } offset =4096 ; count = bufsize;if ((fd =open (filename,O_DIRECT |O_RDWR )) <0 ) {
testcases/kernel/io/direct_io/diotest4.c int main(int argc, char *argv[]) · line 365
Quoted 10 lines
testcases/kernel/io/direct_io/diotest4.c +2
-2tst_brkm (TBROK , cleanup,"can't open %s: %s" , filename,strerror (errno)); } - shm_base =mmap (shm_base,0x100000 ,PROT_READ |PROT_WRITE , -MAP_SHARED |MAP_FIXED , fd,0 ); + shm_base =mmap (0 ,0x100000 ,PROT_READ |PROT_WRITE , +MAP_SHARED , fd,0 );if (shm_base == (caddr_t) -1 ) {tst_brkm (TBROK , cleanup,"can't mmap file: %s" ,strerror (errno));
Agree here, the part that computes the mmap addres based on the sbrk() output looks completely bogus to me.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 direct_io: diotest4: fix mips MAP_SHARED/MAP_FIXED mmap
----- Original Message -----
Quoted 9 lines
Hi!
Quoted 8 lines
include/lapi/mmap.h +0
-0@@ -19,6 +19,8 @@#ifndef LAPI_MMAP_H__ #define LAPI_MMAP_H__
Quoted 8 lines
include/lapi/mmap.h line 26
Quoted 5 lines
include/lapi/mmap.h +2
-0+#include "config.h" +#ifndef MAP_HUGETLB # define MAP_HUGETLB 0x40000#endif Huh, this looks completely unrelevant to the patch itself, or do I miss something?
This fixes the original problem of bad alignment. Hunk below improves on it by removing MAP_FIXED altogether.
I could split it into 2 patches, if you prefer that.
Quoted 35 lines
Quoted 17 lines
testcases/kernel/io/direct_io/diotest4.c +0
-4@@ -352,18 +352,14 @@ int main(int argc, char *argv[]) total++;/* Test-10: read, write to a mmaped file */ - shm_base = (char *)(((long )sbrk (0 ) + (shmsz -1 )) & ~(shmsz -1 )); -if (shm_base ==NULL ) { -tst_brkm (TBROK , cleanup,"sbrk failed: %s" ,strerror (errno)); - } offset =4096 ; count = bufsize;if ((fd =open (filename,O_DIRECT |O_RDWR )) <0 ) {testcases/kernel/io/direct_io/diotest4.c int main(int argc, char *argv[]) · line 365
Quoted 10 lines
testcases/kernel/io/direct_io/diotest4.c +2
-2tst_brkm (TBROK , cleanup,"can't open %s: %s" , filename,strerror (errno)); } - shm_base =mmap (shm_base,0x100000 ,PROT_READ |PROT_WRITE , -MAP_SHARED |MAP_FIXED , fd,0 ); + shm_base =mmap (0 ,0x100000 ,PROT_READ |PROT_WRITE , +MAP_SHARED , fd,0 );if (shm_base == (caddr_t) -1 ) {tst_brkm (TBROK , cleanup,"can't mmap file: %s" ,strerror (errno));Agree here, the part that computes the mmap addres based on the
sbrk()output looks completely bogus to me.--
Cyril Hrubis
[email protected]
PATCH 1/1 direct_io: diotest4: fix mips MAP_SHARED/MAP_FIXED mmap
Hi!
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
include/lapi/mmap.h +0
-0@@ -19,6 +19,8 @@#ifndef LAPI_MMAP_H__ #define LAPI_MMAP_H__ Quoted 8 lines
include/lapi/mmap.h line 26
Quoted 5 lines
include/lapi/mmap.h +2
-0+#include "config.h" +#ifndef MAP_HUGETLB # define MAP_HUGETLB 0x40000#endif Huh, this looks completely unrelevant to the patch itself, or do I miss something?
Quoted 2 lines
This fixes the original problem of bad alignment. Hunk below improves on it by removing
MAP_FIXEDaltogether.
Ah, that is needed for the HAVE_SYS_SHM_H.
Quoted 1 line
I could split it into 2 patches, if you prefer that.
Yes please, both are acked, so just push them.
Quoted 34 lines
Quoted 34 lines
Quoted 16 lines
testcases/kernel/io/direct_io/diotest4.c +0
-4@@ -352,18 +352,14 @@ int main(int argc, char *argv[]) total++;/* Test-10: read, write to a mmaped file */ - shm_base = (char *)(((long )sbrk (0 ) + (shmsz -1 )) & ~(shmsz -1 )); -if (shm_base ==NULL ) { -tst_brkm (TBROK , cleanup,"sbrk failed: %s" ,strerror (errno)); - } offset =4096 ; count = bufsize;if ((fd =open (filename,O_DIRECT |O_RDWR )) <0 ) {testcases/kernel/io/direct_io/diotest4.c int main(int argc, char *argv[]) · line 365
Quoted 10 lines
testcases/kernel/io/direct_io/diotest4.c +2
-2tst_brkm (TBROK , cleanup,"can't open %s: %s" , filename,strerror (errno)); } - shm_base =mmap (shm_base,0x100000 ,PROT_READ |PROT_WRITE , -MAP_SHARED |MAP_FIXED , fd,0 ); + shm_base =mmap (0 ,0x100000 ,PROT_READ |PROT_WRITE , +MAP_SHARED , fd,0 );if (shm_base == (caddr_t) -1 ) {tst_brkm (TBROK , cleanup,"can't mmap file: %s" ,strerror (errno));Agree here, the part that computes the mmap addres based on the
sbrk()output looks completely bogus to me.--
Cyril Hrubis
[email protected]
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 direct_io: diotest4: fix mips MAP_SHARED/MAP_FIXED mmap
----- Original Message -----
Quoted 18 lines
Hi!
Quoted 17 lines
Quoted 16 lines
include/lapi/mmap.h line 26
Quoted 13 lines
include/lapi/mmap.h +2
-0@@ -19,6 +19,8 @@#ifndef LAPI_MMAP_H__ #define LAPI_MMAP_H__ +#include "config.h" +#ifndef MAP_HUGETLB # define MAP_HUGETLB 0x40000#endif Huh, this looks completely unrelevant to the patch itself, or do I miss something?
Quoted 8 lines
Quoted 2 lines
This fixes the original problem of bad alignment. Hunk below improves on it by removing
MAP_FIXEDaltogether.Ah, that is needed for the
HAVE_SYS_SHM_H.Quoted 1 line
I could split it into 2 patches, if you prefer that.
Yes please, both are acked, so just push them.
Pushed as 2 patches.