If you mmap a file, it creates a virtual mapping of some range of memory. Then when you try to access that range of virtual address, it copies over the data from the region you are mapping to so you have the data.
Msync is supposed to synchronize any changes you made to the virtual range and copy those changes back to the memory you mapped to.
Is there a way to do the reverse of this? That is, to remap a virtual space to the same memory range, so that any changes made to the physical memory since the first time you used mmap are reflected in your virtual mapping?
The direct way to do this would be just to unmap and do mmap again, but I want to know if there is a more efficient method of doing this.
This is assuming that I am just using mmap to read from physical memory, not making any changes to it.
There is no reverse operation as all the changes into underlying file are immediately available in the mapped memory - they share the same memory. The same for other mappings of the same file - they refer to the same physical memory so any change is immediately available in all other processes for all mappings of the same area.
Note that by file I mean any type of file, including physical devices, regular files, etc.