1

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...

Gareth McCaughan
  • 19,888
  • 1
  • 41
  • 62
Alfred Zhong
  • 6,773
  • 11
  • 47
  • 59

2 Answers2

3

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.

kuroz
  • 287
  • 2
  • 9
1

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
mpe
  • 2,640
  • 1
  • 19
  • 17
  • Thanks! What does major and minor page faults mean? – Alfred Zhong May 01 '12 at 05:03
  • I'm not sure major & minor are 100% well defined. But in general a major fault means it had to do some I/O to service the fault, eg. load the page from disk. – mpe May 15 '12 at 00:53
  • From the Man Page: **Major faults**: These are faults where the page has to be read in from disk. **Minor faults**: These are faults for pages that are not valid but which have not yet been claimed by other virtual pages. Thus the data in the page is still valid but the system tables must be updated. – Lazylabs May 04 '13 at 08:49