Suppose I am running a virtual machine or container, and I am allowed to run e.g. Java programs inside. Is there a way to detect page faults that occur when accessing the guest memory at the application level (i.e. from the Java program), perhaps empirically?
One possible idea I have:
- Allocate an array where each item is the size of a page
- Perform a benchmark on reading the array item into a variable
- Empirically determine the latency incurred for reads; outliers imply a page fault has occurred in the guest memory
Are there any flaws behind this approach and what are possible alternatives to detect this?