I have an app that uses multiple memory mapped files. If I check the major page faults numbers (with /proc/<pid>/stat), they skyrocket.

I was wondering if it's possible to monitor somehow what memory mapped files are affected by the page swap ins and outs for a process?

At least I would like to see see what mmap-ed files are accessed for a process. I tried with strace, but I found no reads, because I guess no system calls are needed for the direct access to memory.

I would be happy also to know the virtual address in process space where they happen, so at least I could map them manually to the files in pmap output

1 Answer 1

perf trace -F maj


To connect to an existing process, use -p $PID. If you don't want to show system calls, pass --no-syscalls as well. The system call arguments won't be shown with the same level of detail as strace.

  • It seems we don't have perf trace, but we have perf record. It seems it's similar... Jun 5, 2018 at 11:02
  • with the peft record tool , I get this output while processing the log with perf script myprocess 28050 major-faults: 32301f2b () myprocess 28050 major-faults: 3239df34 () myprocess 28050 major-faults: 3239df34 () are the numbers in the last columns the info I'm looking for? Jun 5, 2018 at 11:26
  • @jackmalkovick hmm, I've seen this output before unix.stackexchange.com/questions/434171/… I'm not really sure what to guess about your output, except to say that I think the () part is normally supposed to show a filename.
    – sourcejedi
    Jun 5, 2018 at 12:06
  • I'd wonder a bit whether you're using a JIT language like Java, then I'd guess that the file indications in perf script refer to the faulting instruction (when what you want is the address inside the page that is being faulted in), and in your case the instruction is in anonymous memory.
    – sourcejedi
    Jun 5, 2018 at 12:08
  • Uh... yes. I'm using Java. I expected to see the virtual memory address where the page fault happen, not the address of the instruction that produced it. With the address I can match it to a file using pmap Jun 5, 2018 at 12:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .