'Mapping physical memory without page cache

What I want to do is to speed up the writing of data from RAM to SSD.

So far, I have confirmed that if I place the source data at the address acquired by malloc and open the destination file with the O_DIRECT flag, the write speed is very fast. The above method cannot be used for my purpose because the source data must be specified by physical address and size.

On the other hand, mapping /dev/mem with mmap allows us to handle such data, but the speed is too slow. The reason for the slow speed is probably the large number of page faults and the fact that O_DIRECT cannot be used.

So I think that if we can map the target area of physical memory to user space without using page cache, we can write files to SSD faster than the existing mmap method. It would be ideal if we can also use the O_DIRECT flag. Please let me know if you have a good way to do this or a better way for my purpose.

I have another question for the same purpose and would appreciate your advice here as well.( How to write data to SSD fast with a Linux userland program)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source