All of lore.kernel.org
 help / color / mirror / Atom feed
* Impact of perf_event_paranoid default to 2 on measurement accuracy
@ 2016-08-25 15:42 William Cohen
  2016-08-25 22:02 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: William Cohen @ 2016-08-25 15:42 UTC (permalink / raw)
  To: linux-perf-users

Hi All,

Recent kernels have changed the default setting of /proc/sys/kernel/perf_event_paranoid from 1 to 2 which excludes kernel space measurements.  Has there been some review of the metrics and computation of derived metrics to make sure they are correct and reasonable?  Below are two runs on the same machine back-to-back with the only change being the perf_event_paranoid setting.  The stalled-cycles-fronend looks to be still be counting kernel events for the perf_event_paranoid=2.  The GHz calculation looks questionable (probably because task-clock is measuring total time rather than just user-space time).
 
$ uname -a
Linux santana 4.6.7-300.fc24.x86_64 #1 SMP Wed Aug 17 18:48:43 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

[wcohen@santana tmp]$ cat /proc/sys/kernel/perf_event_paranoid 
2
[wcohen@santana tmp]$ perf stat true

 Performance counter stats for 'true':

          0.585445      task-clock:u (msec)       #    0.546 CPUs utilized          
                 0      context-switches:u        #    0.000 K/sec                  
                 0      cpu-migrations:u          #    0.000 K/sec                  
                43      page-faults:u             #    0.073 M/sec                  
           203,342      cycles:u                  #    0.347 GHz                    
           747,423      stalled-cycles-frontend:u #  367.57% frontend cycles idle   
           120,230      instructions:u            #    0.59  insn per cycle         
                                                  #    6.22  stalled cycles per insn
            20,197      branches:u                #   34.499 M/sec                  
             1,796      branch-misses:u           #    8.89% of all branches        

       0.001071608 seconds time elapsed

[wcohen@santana tmp]$ cat /proc/sys/kernel/perf_event_paranoid 
1
[wcohen@santana tmp]$ perf stat true

 Performance counter stats for 'true':

          0.505810      task-clock (msec)         #    0.478 CPUs utilized          
                 0      context-switches          #    0.000 K/sec                  
                 0      cpu-migrations            #    0.000 K/sec                  
                46      page-faults               #    0.091 M/sec                  
           799,143      cycles                    #    1.580 GHz                    
           549,326      stalled-cycles-frontend   #   68.74% frontend cycles idle   
           571,246      instructions              #    0.71  insn per cycle         
                                                  #    0.96  stalled cycles per insn
           105,510      branches                  #  208.596 M/sec                  
             4,958      branch-misses             #    4.70% of all branches        

       0.001058620 seconds time elapsed

Details on the processor below from /proc/cpu:

vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz
stepping	: 9
microcode	: 0x1c
cpu MHz		: 1200.312
cache size	: 6144 KB


When events are explicitly specified it looks like user-space specifier is just pasted on rather than properly excluding kernel space specifiers even for events that this cannot be specified on:

$ perf stat -e task-clock:k -e task-clock:u -e page-faults:k -e page-faults:u -e cycles:k -e cycles:u true

 Performance counter stats for 'true':

          0.795325      task-clock:ku (msec)      #    0.498 CPUs utilized          
          0.795325      task-clock:u (msec)       #    0.498 CPUs utilized          
                 0      page-faults:ku            #    0.000 K/sec                  
                43      page-faults:u             #    0.054 M/sec                  
                 0      cycles:ku                 #    0.000 GHz                    
           245,909      cycles:u                  #    0.309 GHz                    

       0.001597513 seconds time elapsed


-Will

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Impact of perf_event_paranoid default to 2 on measurement accuracy
  2016-08-25 15:42 Impact of perf_event_paranoid default to 2 on measurement accuracy William Cohen
@ 2016-08-25 22:02 ` Andi Kleen
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Kleen @ 2016-08-25 22:02 UTC (permalink / raw)
  To: William Cohen; +Cc: linux-perf-users

William Cohen <wcohen@redhat.com> writes:

> Hi All,
>
> Recent kernels have changed the default setting of /proc/sys/kernel/perf_event_paranoid from 1 to 2 which excludes kernel space measurements.  Has there been some review of the metrics and computation of derived metrics to make sure they are correct and reasonable?  Below are two runs on the same machine back-to-back with the only change being the perf_event_paranoid setting.  The stalled-cycles-fronend looks to be still be counting kernel events for the perf_event_paranoid=2.  The GHz calculation looks questionable (probably because task-clock is measuring total time rather than just user-space time).

Yes that's a good point. Probably the only option would be to stop using
task-clock for any calculations if perf_event_period==2 and not having
the right capabilities.

Unfortunately this wouldn't handle non standard security models with
more restrictions.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-25 22:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-25 15:42 Impact of perf_event_paranoid default to 2 on measurement accuracy William Cohen
2016-08-25 22:02 ` Andi Kleen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.