Question

I am doing a project on Linux scheduler that tries to minimize number of page faults.

I have finished the algorithm implementation, and I need to measure the effect. I am wondering if Linux provides tools to the record number of page faults that have happened during the whole execution process?

Basically, I want something like

$ pfstat ./a.out
page faults: 3
Execution Time: 1003 ms

Is there such a tool? I want to make sure before deciding to write one by myself, which will be a lot of work...

Was it helpful?

Solution

On most systems /usr/bin/time will report page faults, eg:

$ /usr/bin/time /bin/true
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 1632maxresident)k
40inputs+0outputs (1major+141minor)pagefaults 0swaps

OTHER TIPS

I recommend perf-stat:

$ perf stat make

 Performance counter stats for 'make':

          4.142908 task-clock                #    0.781 CPUs utilized          
                 0 context-switches          #    0.000 K/sec                  
                 0 CPU-migrations            #    0.000 K/sec                  
               318 page-faults               #    0.077 M/sec                  
         3,111,777 cycles                    #    0.751 GHz                    
         1,956,914 stalled-cycles-frontend   #   62.89% frontend cycles idle   
         2,275,123 stalled-cycles-backend    #   73.11% backend  cycles idle   
        11,244,599 instructions              #    3.61  insns per cycle        
                                             #    0.20  stalled cycles per insn [65.87%]
     <not counted> branches                
     <not counted> branch-misses           

       0.005305316 seconds time elapsed

It counts page faults as well as a lot of other performance counters.

But it requires you install a package perf.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top