Mesa (master): gallium/aux: Avoid creating queue when traces not enabled

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 8 16:18:27 UTC 2020


Module: Mesa
Branch: master
Commit: 4c670b13dd5a5e9425941bc425d1ba4afcfe3c15
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c670b13dd5a5e9425941bc425d1ba4afcfe3c15

Author: Rob Clark <robdclark at chromium.org>
Date:   Sat Dec  5 10:39:45 2020 -0800

gallium/aux: Avoid creating queue when traces not enabled

Avoids unnecessarily creating an extra thread when tracing is not
enabled.  Which also side-steps a chrome/ium sandbox issue with
the setscheduler call in u_queue.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7974>

---

 src/gallium/auxiliary/util/u_trace.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_trace.c b/src/gallium/auxiliary/util/u_trace.c
index 152ff33a82e..2d9b542a2bc 100644
--- a/src/gallium/auxiliary/util/u_trace.c
+++ b/src/gallium/auxiliary/util/u_trace.c
@@ -180,21 +180,28 @@ u_trace_context_init(struct u_trace_context *utctx,
 
    list_inithead(&utctx->flushed_trace_chunks);
 
+   utctx->out = get_tracefile();
+
+   if (!utctx->out)
+      return;
+
    bool ret = util_queue_init(&utctx->queue, "traceq", 256, 1,
          UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY |
          UTIL_QUEUE_INIT_RESIZE_IF_FULL);
    assert(ret);
 
-   utctx->out = ret ? get_tracefile() : NULL;
+   if (!ret)
+      utctx->out = NULL;
 }
 
 void
 u_trace_context_fini(struct u_trace_context *utctx)
 {
+   if (!utctx->out)
+      return;
    util_queue_finish(&utctx->queue);
    util_queue_destroy(&utctx->queue);
-   if (utctx->out)
-      fflush(utctx->out);
+   fflush(utctx->out);
    free_chunks(&utctx->flushed_trace_chunks);
 }
 



More information about the mesa-commit mailing list