Skip to content

Commit 7bc1ee2

Browse files
Thomas Richterhcahca
authored andcommitted
s390/cpum_sf: Simplify release of SDBs and SDBTs
Free_sampling_buffer() releases the Sampling Data Buffers (SDBs) and Sampling Data Buffer Table (SDBTs) allocated at event initialization. Both buffers are of PAGE_SIZE bytes. Each SDBT consists of 512 entries. The first 511 entries point to SDBs the last entry points to a successor SDBT. The last SDBT in the list points to the origin of all SDBTs. SDBTs do not contain holes, that is an entry always points to a SDB. If less than 511 SDBs have been allocation, the last entry points to the origin SDBT. Simplify the release of the SDBs and SDBTs, walk along the SDBT chain, release SDBs and SDBTs and stop when reaching the origin again. Signed-off-by: Thomas Richter <[email protected]> Reviewed-by: Sumanth Korikkar <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent 9c7260b commit 7bc1ee2

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

arch/s390/kernel/perf_cpum_sf.c

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -180,39 +180,27 @@ static int sf_buffer_available(struct cpu_hw_sf *cpuhw)
180180
*/
181181
static void free_sampling_buffer(struct sf_buffer *sfb)
182182
{
183-
unsigned long *sdbt, *curr;
184-
185-
if (!sfb->sdbt)
186-
return;
183+
unsigned long *sdbt, *curr, *head;
187184

188185
sdbt = sfb->sdbt;
189-
curr = sdbt;
190-
186+
if (!sdbt)
187+
return;
188+
sfb->sdbt = NULL;
191189
/* Free the SDBT after all SDBs are processed... */
192-
while (1) {
193-
if (!*curr || !sdbt)
194-
break;
195-
196-
/* Process table-link entries */
190+
head = sdbt;
191+
curr = sdbt;
192+
do {
197193
if (is_link_entry(curr)) {
194+
/* Process table-link entries */
198195
curr = get_next_sdbt(curr);
199-
if (sdbt)
200-
free_page((unsigned long)sdbt);
201-
202-
/* If the origin is reached, sampling buffer is freed */
203-
if (curr == sfb->sdbt)
204-
break;
205-
else
206-
sdbt = curr;
196+
free_page((unsigned long)sdbt);
197+
sdbt = curr;
207198
} else {
208199
/* Process SDB pointer */
209-
if (*curr) {
210-
free_page((unsigned long)phys_to_virt(*curr));
211-
curr++;
212-
}
200+
free_page((unsigned long)phys_to_virt(*curr));
201+
curr++;
213202
}
214-
}
215-
203+
} while (curr != head);
216204
memset(sfb, 0, sizeof(*sfb));
217205
}
218206

0 commit comments

Comments
 (0)