Condividi tramite


Measuring TLB misses

Posted by: Sue Loh

 

Question: How can I measure TLB misses on Windows CE? 

Answer:

 

If you are running a MIPS or SH processor then CeLog will capture counts of TLB misses.  On each thread switch it'll record a "TLB miss" event which has the count of TLB misses that happened during the time since the last thread switch.  That's a lot less informative than you might be hoping for -- it won't tell you the exact times of the TLB misses, or what addresses they happened on.  You'd have to manually instrument the kernel's TLB miss handler to get that.  And Kernel Tracker doesn't really do a good job of displaying TLB misses.  You'd be better off running readlog.exe.  If you use the "-s -v" parameters to get a verbose summary, it will add up TLB misses per thread, for example:

 

0x0002E942 0x00013242 0x00013242 0:00:00.099.172 Active shell.exe

        Time in process 0x00013242: 0:00:00.099.172 (100.0% of thread run-time)

                     Total TLB Misses: 500

                Total thread switches: 25

  min TLB misses in one thread switch: 2

  max TLB misses in one thread switch: 35

                    TLB Misses/switch: 20.00

                   Total run time, ms: 99

                        TLB Misses/ms: 5.05

On ARM and x86, the OS has no knowledge of TLB misses, because TLB misses are handled completely in hardware.  There is no software TLB miss handler that the OS could use to record the events.  The only possible way for you to find out about TLB misses on ARM/x86 is if the CPU has hardware performance counters you can use to measure them.  Performance counters vary from one manufacturer to another and from one CPU to another, so look in the reference manual from the CPU manufacturer.  If they are supported you'd end up having to write CPU-specific code to access them.

Comments

  • Anonymous
    January 23, 2007
    By the way, measuring cache misses is similar -- on all CPUs, they are handled entirely in hardware.  So your CPU would have to expose some hardware performance counters in order for you to measure them.  So again look in the reference manual from the CPU manufacturer.Sue
  • Anonymous
    January 23, 2007
    The comment has been removed
  • Anonymous
    January 24, 2007
    Hi Sue,thanks for this informative post.Do you think that is possible to use the MIPS' software TLB miss handler to expand the 512 MB (physical) RAM limit of WinCE?I found this article which could be the basis for that: http://support.microsoft.com/kb/841192/en-us, but I am sure of the implication for the OS itself with such change...Thanks,Alex
  • Anonymous
    January 24, 2007
    The comment has been removed
  • Anonymous
    January 25, 2007
    The comment has been removed
  • Anonymous
    January 25, 2007
    Thank you for that tip about the ARM trick.  I don't know when I might get to use it but it's good to know.  Generally TLB misses are a much bigger issue on MIPS and SH since software handling is so much slower than hardware handled TLB misses.I don't think we could implement it with page tables, because I don't think we can control what entries are in the TLB.  Or, I'm not creative enough to figure out how to do it in the short time I've thought about it.  :-) At most I think we could measure page faults but that's not the same as TLB misses.Sue