I need to make the process to run in real time as much as possible.
All the communication is done via shared memory - memory mapped files - no system calls at all - it uses busy waiting on shared memory.
The process runs under real time priority and all memory is locked with mlockall(MCL_CURRENT|MCL_FUTURE)
which succeeds and process has enough ulimits
to have all the memory locked.
When I run it on it perf stat -p PID
I still get counts of minor page faults.
I tested this with both process affinity and without.
Question:
Is it possible to eliminate them at all - even minor page faults?
You should try to keep code that can be modified and code that cannot be modified in separate sections of a large program. This will reduce page traffic by reducing the number of pages that are changed. Also, try to prevent I/O buffers from crossing page boundaries unnecessarily.
The mapping between the virtual address space and physical memory is handled by the Linux kernel and by the CPU's MMU using pages of memory. When the CPU needs to access a page that isn't in memory it raises a page fault. A major page fault is one that can only be satisfied by accessing the disk.
A minor page fault is a type of exception that occurs when the operating system encounters an error in memory that can be caused by either hardware or software errors.
A minor fault means the page is in memory but not allocated to the requesting process or not marked as present in the memory management unit. A major fault means the page in no longer in memory.
I solved this problem by switching from memory mapped files to POSIX shared memory shm_open
+ memory locking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With