Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command to measure TLB misses on LINUX

Could some one direct me to a command to measure TLB misses on LINUX, please? Is it okay to consider minor page faults as TLB misses?

like image 207
samarasa Avatar asked Jan 24 '12 06:01

samarasa


People also ask

What is TLB miss?

TLB miss occurs when the page table entry required for conversion of virtual address to physical address is not present in the TLB(translation look aside buffer).

How is cache miss measured?

You can also calculate a miss ratio by dividing the number of misses with the total number of content requests. For example, if you look over a period of time and find that the misses your cache experienced was11, and the total number of content requests was 48, you would divide 11 by 48 to get a miss ratio of 0.229.


2 Answers

You can use perf to do this. Provided your CPU supports it.

Use perf list to get some idea of the counters available. When I took this list and grepped for TLB (on my Sandy Bridge machine) I got:

rob@tartarus:~$ perf list | grep -i tlb
  dTLB-loads                                         [Hardware cache event]
  dTLB-load-misses                                   [Hardware cache event]
  dTLB-stores                                        [Hardware cache event]
  dTLB-store-misses                                  [Hardware cache event]
  dTLB-prefetches                                    [Hardware cache event]
  dTLB-prefetch-misses                               [Hardware cache event]
  iTLB-loads                                         [Hardware cache event]
  iTLB-load-misses                                   [Hardware cache event]

You can then use this particular counter with: perf record -e <event0>,<event1>,..

And then just use perf report to look at the results.

like image 74
Rob Bradford Avatar answered Sep 16 '22 23:09

Rob Bradford


To see this information for the entire system, you could use the following line. This will record the counters for 1 minute (60 seconds).

perf stat -e dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses sleep 60

If miss ratio is higher than 1% you should look into using huge pages.

like image 41
Mircea Vutcovici Avatar answered Sep 16 '22 23:09

Mircea Vutcovici