Hi David, 在 2021/8/15 4:07, David Laight 写道: > ... >>>>> Let me describe my use case more clearly (just ignore if you're not >>>>> interested in it): >>>>> >>>>> 1. Prog A mmap() 4GB memory (anon or file-mapping), suppose the >>>>> allocated VA range is [0x40000000,0x140000000) >>>>> >>>>> 2. Prog A specifies [0x48000000,0x50000000) and >>>>> [0x80000000,0x100000000) will be shared by its child. >>>>> >>>>> 3. Prog A fork() Prog B and then Prog B exec() a new ELF binary. >>>>> >>>>> 4. Prog B notice the shared ranges (e.g. by input parameters or >>>>> ...) >>>>> and remap them to a continuous VA range. > > Remapping to contiguous VA is going to be difficult in the > general case for (IIRC) VIVT caches. > The required cache coherence may only be attainable by > using uncached mappings. > The Prog B uses mremap() syscall to remapping the shared ranges to other places, this is a common case for mremap in userspace. The cache coherence should already be processed in mremap core logic, otherwise there's maybe something wrong in mremap(). > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) >