]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
powerpc/perf/hv-24x7: Display change in counter values
authorSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Tue, 26 Jan 2016 04:05:36 +0000 (23:05 -0500)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 10 Mar 2016 11:56:55 +0000 (22:56 +1100)
For 24x7 counters, perf displays the raw value of the 24x7 counter, which
is a monotonically increasing value.

perf stat -C 0 -e \
'hv_24x7/HPM_0THRD_NON_IDLE_CCYC__PHYS_CORE,core=1/' \
sleep 1

 Performance counter stats for 'CPU(s) 0':

     9,105,403,170      hv_24x7/HPM_0THRD_NON_IDLE_CCYC__PHYS_CORE,core=1/

       0.000425751 seconds time elapsed

In the typical usage of 'perf stat' this counter value is not as useful
as the _change_ in the counter value over the duration of the application.

Have h_24x7_event_init() set the event's prev_count to the raw value of
the 24x7 counter at the time of initialization. When the application
terminates, hv_24x7_event_read() will compute the change in value and
report to the perf tool. Similarly, for the transaction interface, clear
the event count to 0 at the beginning of the transaction.

perf stat -C 0 -e \
'hv_24x7/HPM_0THRD_NON_IDLE_CCYC__PHYS_CORE,core=1/' \
sleep 1

 Performance counter stats for 'CPU(s) 0':

           245,758      hv_24x7/HPM_0THRD_NON_IDLE_CCYC__PHYS_CORE,core=1/

       1.006366383 seconds time elapsed

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/perf/hv-24x7.c

index b7a9a03ca59d39c1a2fb0bdae7c08d9145ef3221..77b958f213a0340ecb9962d6f1d33c362d62bca5 100644 (file)
@@ -1222,11 +1222,12 @@ static int h_24x7_event_init(struct perf_event *event)
                return -EACCES;
        }
 
-       /* see if the event complains */
+       /* Get the initial value of the counter for this event */
        if (single_24x7_request(event, &ct)) {
                pr_devel("test hcall failed\n");
                return -EIO;
        }
+       (void)local64_xchg(&event->hw.prev_count, ct);
 
        return 0;
 }
@@ -1289,6 +1290,16 @@ static void h_24x7_event_read(struct perf_event *event)
                        h24x7hw = &get_cpu_var(hv_24x7_hw);
                        h24x7hw->events[i] = event;
                        put_cpu_var(h24x7hw);
+                       /*
+                        * Clear the event count so we can compute the _change_
+                        * in the 24x7 raw counter value at the end of the txn.
+                        *
+                        * Note that we could alternatively read the 24x7 value
+                        * now and save its value in event->hw.prev_count. But
+                        * that would require issuing a hcall, which would then
+                        * defeat the purpose of using the txn interface.
+                        */
+                       local64_set(&event->count, 0);
                }
 
                put_cpu_var(hv_24x7_reqb);