]>
Commit | Line | Data |
---|---|---|
84b52de0 SL |
1 | From 35023a996c2aa5ff04d6bb194d1acd3280dc0d11 Mon Sep 17 00:00:00 2001 |
2 | From: Sasha Levin <sashal@kernel.org> | |
3 | Date: Wed, 15 Nov 2023 11:04:25 +0100 | |
4 | Subject: s390/pai: rework paiXXX_start and paiXXX_stop functions | |
5 | ||
6 | From: Thomas Richter <tmricht@linux.ibm.com> | |
7 | ||
8 | [ Upstream commit cb1259b7b574bd90ef22dac2c6282327cdae31c6 ] | |
9 | ||
10 | The PAI crypto counter and PAI NNPA counters start and stop functions | |
11 | are streamlined. Move the conditions to invoke start and stop functions | |
12 | to its respective function body and call them unconditionally. | |
13 | The start and stop functions now determine how to proceed. | |
14 | No functional change. | |
15 | ||
16 | Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> | |
17 | Acked-by: Mete Durlu <meted@linux.ibm.com> | |
18 | Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> | |
19 | Stable-dep-of: e9f3af02f639 ("s390/pai: fix sampling event removal for PMU device driver") | |
20 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
21 | --- | |
22 | arch/s390/kernel/perf_pai_crypto.c | 29 ++++++++++++------------- | |
23 | arch/s390/kernel/perf_pai_ext.c | 35 ++++++++++++++---------------- | |
24 | 2 files changed, 30 insertions(+), 34 deletions(-) | |
25 | ||
26 | diff --git a/arch/s390/kernel/perf_pai_crypto.c b/arch/s390/kernel/perf_pai_crypto.c | |
27 | index 3758e972bb5f9..ba2d2e61df747 100644 | |
28 | --- a/arch/s390/kernel/perf_pai_crypto.c | |
29 | +++ b/arch/s390/kernel/perf_pai_crypto.c | |
30 | @@ -245,10 +245,14 @@ static void paicrypt_start(struct perf_event *event, int flags) | |
31 | * Events are added, deleted and re-added when 2 or more events | |
32 | * are active at the same time. | |
33 | */ | |
34 | - if (!event->hw.last_tag) { | |
35 | - event->hw.last_tag = 1; | |
36 | - sum = paicrypt_getall(event); /* Get current value */ | |
37 | - local64_set(&event->hw.prev_count, sum); | |
38 | + if (!event->attr.sample_period) { /* Counting */ | |
39 | + if (!event->hw.last_tag) { | |
40 | + event->hw.last_tag = 1; | |
41 | + sum = paicrypt_getall(event); /* Get current value */ | |
42 | + local64_set(&event->hw.prev_count, sum); | |
43 | + } | |
44 | + } else { /* Sampling */ | |
45 | + perf_sched_cb_inc(event->pmu); | |
46 | } | |
47 | } | |
48 | ||
49 | @@ -263,19 +267,18 @@ static int paicrypt_add(struct perf_event *event, int flags) | |
50 | __ctl_set_bit(0, 50); | |
51 | } | |
52 | cpump->event = event; | |
53 | - if (flags & PERF_EF_START && !event->attr.sample_period) { | |
54 | - /* Only counting needs initial counter value */ | |
55 | + if (flags & PERF_EF_START) | |
56 | paicrypt_start(event, PERF_EF_RELOAD); | |
57 | - } | |
58 | event->hw.state = 0; | |
59 | - if (event->attr.sample_period) | |
60 | - perf_sched_cb_inc(event->pmu); | |
61 | return 0; | |
62 | } | |
63 | ||
64 | static void paicrypt_stop(struct perf_event *event, int flags) | |
65 | { | |
66 | - paicrypt_read(event); | |
67 | + if (!event->attr.sample_period) /* Counting */ | |
68 | + paicrypt_read(event); | |
69 | + else /* Sampling */ | |
70 | + perf_sched_cb_dec(event->pmu); | |
71 | event->hw.state = PERF_HES_STOPPED; | |
72 | } | |
73 | ||
74 | @@ -283,11 +286,7 @@ static void paicrypt_del(struct perf_event *event, int flags) | |
75 | { | |
76 | struct paicrypt_map *cpump = this_cpu_ptr(&paicrypt_map); | |
77 | ||
78 | - if (event->attr.sample_period) | |
79 | - perf_sched_cb_dec(event->pmu); | |
80 | - if (!event->attr.sample_period) | |
81 | - /* Only counting needs to read counter */ | |
82 | - paicrypt_stop(event, PERF_EF_UPDATE); | |
83 | + paicrypt_stop(event, PERF_EF_UPDATE); | |
84 | if (--cpump->active_events == 0) { | |
85 | __ctl_clear_bit(0, 50); | |
86 | WRITE_ONCE(S390_lowcore.ccd, 0); | |
87 | diff --git a/arch/s390/kernel/perf_pai_ext.c b/arch/s390/kernel/perf_pai_ext.c | |
88 | index 53915401c3f63..09aebfcf679df 100644 | |
89 | --- a/arch/s390/kernel/perf_pai_ext.c | |
90 | +++ b/arch/s390/kernel/perf_pai_ext.c | |
91 | @@ -327,11 +327,15 @@ static void paiext_start(struct perf_event *event, int flags) | |
92 | { | |
93 | u64 sum; | |
94 | ||
95 | - if (event->hw.last_tag) | |
96 | - return; | |
97 | - event->hw.last_tag = 1; | |
98 | - sum = paiext_getall(event); /* Get current value */ | |
99 | - local64_set(&event->hw.prev_count, sum); | |
100 | + if (!event->attr.sample_period) { /* Counting */ | |
101 | + if (!event->hw.last_tag) { | |
102 | + event->hw.last_tag = 1; | |
103 | + sum = paiext_getall(event); /* Get current value */ | |
104 | + local64_set(&event->hw.prev_count, sum); | |
105 | + } | |
106 | + } else { /* Sampling */ | |
107 | + perf_sched_cb_inc(event->pmu); | |
108 | + } | |
109 | } | |
110 | ||
111 | static int paiext_add(struct perf_event *event, int flags) | |
112 | @@ -348,21 +352,19 @@ static int paiext_add(struct perf_event *event, int flags) | |
113 | debug_sprintf_event(paiext_dbg, 4, "%s 1508 %llx acc %llx\n", | |
114 | __func__, S390_lowcore.aicd, pcb->acc); | |
115 | } | |
116 | - if (flags & PERF_EF_START && !event->attr.sample_period) { | |
117 | - /* Only counting needs initial counter value */ | |
118 | + cpump->event = event; | |
119 | + if (flags & PERF_EF_START) | |
120 | paiext_start(event, PERF_EF_RELOAD); | |
121 | - } | |
122 | event->hw.state = 0; | |
123 | - if (event->attr.sample_period) { | |
124 | - cpump->event = event; | |
125 | - perf_sched_cb_inc(event->pmu); | |
126 | - } | |
127 | return 0; | |
128 | } | |
129 | ||
130 | static void paiext_stop(struct perf_event *event, int flags) | |
131 | { | |
132 | - paiext_read(event); | |
133 | + if (!event->attr.sample_period) /* Counting */ | |
134 | + paiext_read(event); | |
135 | + else /* Sampling */ | |
136 | + perf_sched_cb_dec(event->pmu); | |
137 | event->hw.state = PERF_HES_STOPPED; | |
138 | } | |
139 | ||
140 | @@ -372,12 +374,7 @@ static void paiext_del(struct perf_event *event, int flags) | |
141 | struct paiext_map *cpump = mp->mapptr; | |
142 | struct paiext_cb *pcb = cpump->paiext_cb; | |
143 | ||
144 | - if (event->attr.sample_period) | |
145 | - perf_sched_cb_dec(event->pmu); | |
146 | - if (!event->attr.sample_period) { | |
147 | - /* Only counting needs to read counter */ | |
148 | - paiext_stop(event, PERF_EF_UPDATE); | |
149 | - } | |
150 | + paiext_stop(event, PERF_EF_UPDATE); | |
151 | if (--cpump->active_events == 0) { | |
152 | /* Disable CPU instruction lookup for PAIE1 control block */ | |
153 | __ctl_clear_bit(0, 49); | |
154 | -- | |
155 | 2.43.0 | |
156 |