How to disable copy to write and zero filled on demand for mmap ()

I am implementing the cp (file copy) command with mmap (). To do this, I compared the source file in MAP_PRIVATE mode (as I just want to read) and in the target file in MAP_SHARED mode (since I need to overwrite the modified contents of the target file).

At the same time, I observed a decrease in performance due to the large number of small page errors that occur due to 2 reasons. 1) Zero padding on demand when calling mmap (MAP_PRIVATE) for the source file. 2) Copy the record when calling mmap (MAP_SHARED) for the destination file.

Is there a way to disable Zero-fill-on-demand and Copy-on-write?

Thanks Harish

+5
source share
1 answer

MMAP_POPULATE mmap (2):

http://linux.die.net/man/2/mmap

MAP_POPULATE ( Linux 2.5.46) (prefault) . - . . MAP_POPULATE Linux 2.6.23.

mmapped . (1) (2) ().

+2

All Articles