s390/pai: simplify event start function for perf stat
authorThomas Richter <tmricht@linux.ibm.com>
Fri, 26 Jan 2024 12:32:03 +0000 (13:32 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Tue, 20 Feb 2024 13:37:32 +0000 (14:37 +0100)
When an event is started, read the current value of the
PAI counter. This value is saved in event::hw.prev_count.
When an event is stopped, this value is subtracted from the current
value read out at event stop time. The difference is the delta
of this counter.

Simplify the logic and read the event value every time the event is
started. This scheme is identical to other device drivers.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/kernel/perf_pai_crypto.c
arch/s390/kernel/perf_pai_ext.c

index 8c98bd493707251cd7c4e07db48405468bc6efdb..61fb4e716476fb8fa65b80ecccd99b8be1336869 100644 (file)
@@ -326,17 +326,9 @@ static void paicrypt_start(struct perf_event *event, int flags)
 {
        u64 sum;
 
-       /* Event initialization sets last_tag to 0. When later on the events
-        * are deleted and re-added, do not reset the event count value to zero.
-        * Events are added, deleted and re-added when 2 or more events
-        * are active at the same time.
-        */
        if (!event->attr.sample_period) {       /* Counting */
-               if (!event->hw.last_tag) {
-                       event->hw.last_tag = 1;
-                       sum = paicrypt_getall(event);   /* Get current value */
-                       local64_set(&event->hw.prev_count, sum);
-               }
+               sum = paicrypt_getall(event);   /* Get current value */
+               local64_set(&event->hw.prev_count, sum);
        } else {                                /* Sampling */
                perf_sched_cb_inc(event->pmu);
        }
index 21a18eafb5767ef7420d62eb109248b56114931f..dd84c4d6fbe9226f6aa0f7f8fe6e86420b404753 100644 (file)
@@ -331,11 +331,8 @@ static void paiext_start(struct perf_event *event, int flags)
        u64 sum;
 
        if (!event->attr.sample_period) {       /* Counting */
-               if (!event->hw.last_tag) {
-                       event->hw.last_tag = 1;
-                       sum = paiext_getall(event);     /* Get current value */
-                       local64_set(&event->hw.prev_count, sum);
-               }
+               sum = paiext_getall(event);     /* Get current value */
+               local64_set(&event->hw.prev_count, sum);
        } else {                                /* Sampling */
                perf_sched_cb_inc(event->pmu);
        }