title: Linux perf command for cache references
body: <p>I want to measure cache miss rate of my code. We can use perf list to show supported the events. My desktop has a Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz processor, the perf list contains cache-refrences, and cache-misses, like this:</p>
  
  <pre><code>  cpu-cycles OR cycles                               [Hardware event]
    stalled-cycles-frontend OR idle-cycles-frontend    [Hardware event]
    stalled-cycles-backend OR idle-cycles-backend      [Hardware event]
    instructions                                       [Hardware event]
    cache-references                                   [Hardware event]
    cache-misses                                       [Hardware event]
  </code></pre>
  
  <p>I think cache-misses is mapped to hardware event LLC-misses according to the Intel architectures software developer's manual (I confirm this by comparing <strong>perf stat -e r412e</strong> and <strong>perf stat -e cache-misses</strong>, they given almost identical result). But how is cache-references counted? I didn't find a event or way to get total cache references using existing hardware events. So I'm wondering if this cache-references is accurate on my computer? </p>