7

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?

Artyom
  • 31,019
  • 21
  • 127
  • 215

2 Answers2

6

I solved this problem by switching from memory mapped files to POSIX shared memory shm_open + memory locking.

Artyom
  • 31,019
  • 21
  • 127
  • 215
0

If I understand the question correct, avoiding the minor page faults completely isn't possible. In most modern OS's including Linux, the OS doesn't load all the text and data segments into memory when the programs start. It allocates internal data structures and pages are essentially faulted in when the text and data are needed. This causing a page fault physical memory is made available to the process, swapping page from backing store. Therefore, minor page fault could be avoided without accessing backing store which might not possible.

Sunil Bojanapally
  • 12,528
  • 4
  • 33
  • 46
  • I'm talking about minor page fault which is caused by TLB misses – Artyom Dec 03 '12 at 12:02
  • TLB miss is hardware-handled in most modern CPU. It should be invisible to OS; only slowing down some memory accesses and incrementing hardware performance monitoring counter (DTLB_LOAD_MISSES.ANY in Intel). – osgx Dec 19 '12 at 07:36
  • How can I reduce the minor page fault? I do have lots of memory but still haunted by the minor page fault problem that makes the CPU usage too much to carry other jobs – Liu Weibo Dec 06 '17 at 09:31