title: perf annotated assembly seems off
body: <p>I want to measure the amount of time a C++ atomic fetch_add takes on different settings.  I wrote something like this:</p>
  
  <pre><code>atomic&lt;uint64_t&gt; x(0);
  for (uint64_t i = 0; i &lt; REPS; i+=1g) {
    x.fetch_add(1);
  } 
  </code></pre>
  
  <p>So that if <code>REPS</code> is high enough, I assume will be able to average the the <code>fetch_add</code> per second happening. First, I needed to validate most of the time was indeed spent within fetch_add, as opposed to loop overhead, for example.  So I ran perf to do this. </p>
  
  <p>This is the assembly from objdump:</p>
  
  <pre><code>400ed0:       b8 00 b4 c4 04          mov    $0x4c4b400,%eax
  400ed5:       0f 1f 00                nopl   (%rax)
  400ed8:       f0 83 05 7c 22 20 00    lock addl $0x1,0x20227c(%rip)
  400edf:       01 
  400ee0:       83 e8 01                sub    $0x1,%eax
  400ee3:       75 f3                   jne    400ed8 &lt;_Z10incrsharedv+0x8&gt;
  </code></pre>
  
  <p>perf  (for the cycles event) says 100% of the cycles go into <code>sub    $0x1,%eax</code>, as opposed to what I would expect, <code>lock addl $0x1,0x20227c(%rip)</code> or the jump.  Any ideas why? is this accurate, or is it just a measurement artifact? In the second case, why would perf systematically attribute the latency to the <code>sub</code> line rather than to <code>addl</code>? </p>