Command to measure TLB misses on LINUX
Asked Answered
E

2

6

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?

Ellerey answered 24/1, 2012 at 6:21 Comment(5)
I have no idea; TLB misses are deep inside the processor. page fauts are not TLB misses.Rabbinism
Minor page faults not major page faults?Ellerey
What CPU family ? I'm guessing x86-64 but you need to specify the processor for this as any solution may involve accessing CPU performance registers ?Cabriolet
@Paul R: You mean that I need to monitor performance counters.Ellerey
@kkp: possibly - some CPUs have a performance register for TLB misses, some don't - see the discussion under this article: software.intel.com/en-us/articles/…Cabriolet
T
13

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.

Towers answered 19/2, 2012 at 17:44 Comment(2)
oprofile may also have access to TLB miss counters, for older kernels.Mccall
I've used oprofile in the past too - unfortunately the version shipping in Fedora 16 is one release behind the one that includes support for Sandy Bridge. I didn't want to recommend something I couldn't test.Towers
A
8

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.

Abyss answered 18/8, 2016 at 18:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.