6

I have a large amount of data stored in a file. This file is mmap'ed, but at any time I access only a small amount of the data. I want to understand my program's access pattern so that I can optimize the ordering of the data (such that frequently access data are grouped into the same pages). The goal is to reduce the working set of the mmaped file.

So, I am thinking of mapping the file with R/W both disabled. Each read/write attempt would cause a SEGV. In my SEGV handler, I will record the access address and allow the program to continue.

I can decode the instruction at the faulting address, and simulate its actions (by modifying the target registers and memory locations accordingly).

However, I read somewhere that Linux can't recover from SEGVs. Is this true? When my signal handler gets called, how do I indicate to the OS that "everything is just fine, please continue immediately after the faulting instruction"?

Note that I don't want it to redo the faulting instruction, as I would have simulated it.

I just care about x86/x64 architectures for now.

Thanks!

Tomei Ningen
  • 166
  • 1
  • 6
  • 2
    For a solution see http://stackoverflow.com/questions/2663456/write-a-signal-handler-to-catch-sigsegv Note that you may not always be able to handle SIGSEGV yourself (the kernel might decide to take the application down right away). – peterph Sep 26 '13 at 09:38

0 Answers0