Skip to content

Commit 7a527d4

Browse files
Yicong YangSuzuki K Poulose
authored andcommitted
hwtracing: hisi_ptt: Optimize the trace data committing
In the current implementation, there're 4*4MiB trace buffer and hardware will fill the buffer one by one. The driver will get notified if one buffer is full and then copy data to the AUX buffer. If there's no enough room for the next trace buffer, we'll commit the AUX buffer to the perf core and try to apply a new one. In a typical configuration the AUX buffer will be 16MiB, so we'll commit the data after the whole AUX buffer is occupied. Then the driver cannot apply a new AUX buffer immediately until the committed data is consumed by userspace and then there's room in the AUX buffer again. This patch tries to optimize this by commit the data after one single trace buffer is filled. Since there's still room in the AUX buffer, driver can apply a new one without failure and don't need to wait for the userspace to consume the data. Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20231010084731.30450-4-yangyicong@huawei.com
1 parent e8b7d87 commit 7a527d4

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

drivers/hwtracing/ptt/hisi_ptt.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,14 @@ static int hisi_ptt_update_aux(struct hisi_ptt *hisi_ptt, int index, bool stop)
274274
buf->pos += size;
275275

276276
/*
277-
* Just commit the traced data if we're going to stop. Otherwise if the
278-
* resident AUX buffer cannot contain the data of next trace buffer,
279-
* apply a new one.
277+
* Always commit the data to the AUX buffer in time to make sure
278+
* userspace got enough time to consume the data.
279+
*
280+
* If we're not going to stop, apply a new one and check whether
281+
* there's enough room for the next trace.
280282
*/
281-
if (stop) {
282-
perf_aux_output_end(handle, buf->pos);
283-
} else if (buf->length - buf->pos < HISI_PTT_TRACE_BUF_SIZE) {
284-
perf_aux_output_end(handle, buf->pos);
285-
283+
perf_aux_output_end(handle, size);
284+
if (!stop) {
286285
buf = perf_aux_output_begin(handle, event);
287286
if (!buf)
288287
return -EINVAL;

0 commit comments

Comments
 (0)