From 8092d58e2e2f3076ad5e5ef88670f3290df25f1b Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Sat, 18 Dec 2021 16:48:00 +0200 Subject: [PATCH] util/u_trace: protect against reentrant calls With the Iris driver, the first tracepoint triggers the tracepoint for "begin of command buffer" which leads to 2 tracepoints using the same idx. Signed-off-by: Lionel Landwerlin Reviewed-by: Danylo Piliaiev Part-of: --- src/util/perf/u_trace.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/util/perf/u_trace.c b/src/util/perf/u_trace.c index aae22856c20..29c9c8c5652 100644 --- a/src/util/perf/u_trace.c +++ b/src/util/perf/u_trace.c @@ -560,6 +560,7 @@ void * u_trace_append(struct u_trace *ut, void *cs, const struct u_tracepoint *tp) { struct u_trace_chunk *chunk = get_chunk(ut, tp->payload_sz); + unsigned tp_idx = chunk->num_traces++; assert(tp->payload_sz == ALIGN_NPOT(tp->payload_sz, 8)); @@ -571,15 +572,13 @@ u_trace_append(struct u_trace *ut, void *cs, const struct u_tracepoint *tp) } /* record a timestamp for the trace: */ - ut->utctx->record_timestamp(ut, cs, chunk->timestamps, chunk->num_traces, tp->end_of_pipe); + ut->utctx->record_timestamp(ut, cs, chunk->timestamps, tp_idx, tp->end_of_pipe); - chunk->traces[chunk->num_traces] = (struct u_trace_event) { + chunk->traces[tp_idx] = (struct u_trace_event) { .tp = tp, .payload = payload, }; - chunk->num_traces++; - return payload; }