[LTP] [PATCH] direct_io: diotest4: fix mips MAP_SHARED/MAP_FIXED mmap

Cyril Hrubis chrubis@suse.cz
Thu Jul 4 16:08:49 CEST 2019


Hi!
> > > diff --git a/include/lapi/mmap.h b/include/lapi/mmap.h
> > > index 18547c0d47ed..98b6ade1e2ab 100644
> > > --- a/include/lapi/mmap.h
> > > +++ b/include/lapi/mmap.h
> > > @@ -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?
> 
> This fixes the original problem of bad alignment.
> Hunk below improves on it by removing MAP_FIXED altogether.

Ah, that is needed for the HAVE_SYS_SHM_H.

> I could split it into 2 patches, if you prefer that.

Yes please, both are acked, so just push them.

> > > diff --git a/testcases/kernel/io/direct_io/diotest4.c
> > > b/testcases/kernel/io/direct_io/diotest4.c
> > > index e4616e400abd..bf200cd41a27 100644
> > > --- a/testcases/kernel/io/direct_io/diotest4.c
> > > +++ b/testcases/kernel/io/direct_io/diotest4.c
> > > @@ -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));
> > 
> > Agree here, the part that computes the mmap addres based on the sbrk()
> > output looks completely bogus to me.
> > 
> > --
> > Cyril Hrubis
> > chrubis@suse.cz
> > 

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list