• David Ahern's avatar
    sparc: perf: Make counting mode actually work · d51291cb
    David Ahern authored
    Currently perf-stat (aka, counting mode) does not work:
    
    $ perf stat ls
    ...
     Performance counter stats for 'ls':
    
              1.585665      task-clock (msec)         #    0.580 CPUs utilized
                    24      context-switches          #    0.015 M/sec
                     0      cpu-migrations            #    0.000 K/sec
                    86      page-faults               #    0.054 M/sec
       <not supported>      cycles
       <not supported>      stalled-cycles-frontend
       <not supported>      stalled-cycles-backend
       <not supported>      instructions
       <not supported>      branches
       <not supported>      branch-misses
    
           0.002735100 seconds time elapsed
    
    The reason is that state is never reset (stays with PERF_HES_UPTODATE set).
    Add a call to sparc_pmu_enable_event during the added_event handling.
    Clean up the encoding since pmu_start calls sparc_pmu_enable_event which
    does the same. Passing PERF_EF_RELOAD to sparc_pmu_start means the call
    to sparc_perf_event_set_period can be removed as well.
    
    With this patch:
    
    $ perf stat ls
    ...
     Performance counter stats for 'ls':
    
              1.552890      task-clock (msec)         #    0.552 CPUs utilized
                    24      context-switches          #    0.015 M/sec
                     0      cpu-migrations            #    0.000 K/sec
                    86      page-faults               #    0.055 M/sec
             5,748,997      cycles                    #    3.702 GHz
       <not supported>      stalled-cycles-frontend:HG
       <not supported>      stalled-cycles-backend:HG
             1,684,362      instructions:HG           #    0.29  insns per cycle
               295,133      branches:HG               #  190.054 M/sec
                28,007      branch-misses:HG          #    9.49% of all branches
    
           0.002815665 seconds time elapsed
    Signed-off-by: default avatarDavid Ahern <david.ahern@oracle.com>
    Acked-by: default avatarBob Picco <bob.picco@oracle.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    d51291cb
perf_event.c 44.7 KB