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

Author: Dave Airlie <[email protected]>
Date:   Mon Feb  8 16:10:26 2021 +1000

llvmpipe: add a mutex around debug resource tracking

The debug resource tracking triggers an asan warning, add a mutex
around it to avoid multi-thread failures with vulkan CTS test:

dEQP-VK.api.object_management.multithreaded_per_thread_device.buffer_uniform_small

Reviewed-by: Adam Jackson <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8912>

---

 src/gallium/drivers/llvmpipe/lp_texture.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index 2bf223d66f9..7f27cbb9a74 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -56,6 +56,7 @@
 
 #ifdef DEBUG
 static struct llvmpipe_resource resource_list;
+static mtx_t resource_list_mutex = _MTX_INITIALIZER_NP;
 #endif
 static unsigned id_counter = 0;
 
@@ -307,7 +308,9 @@ llvmpipe_resource_create_all(struct pipe_screen *_screen,
    lpr->id = id_counter++;
 
 #ifdef DEBUG
+   mtx_lock(&resource_list_mutex);
    insert_at_tail(&resource_list, lpr);
+   mtx_unlock(&resource_list_mutex);
 #endif
 
    return &lpr->base;
@@ -374,8 +377,10 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
       }
    }
 #ifdef DEBUG
+   mtx_lock(&resource_list_mutex);
    if (lpr->next)
       remove_from_list(lpr);
+   mtx_unlock(&resource_list_mutex);
 #endif
 
    FREE(lpr);
@@ -510,7 +515,9 @@ llvmpipe_resource_from_handle(struct pipe_screen *screen,
    lpr->id = id_counter++;
 
 #ifdef DEBUG
+   mtx_lock(&resource_list_mutex);
    insert_at_tail(&resource_list, lpr);
+   mtx_unlock(&resource_list_mutex);
 #endif
 
    return &lpr->base;
@@ -871,6 +878,7 @@ llvmpipe_print_resources(void)
    unsigned n = 0, total = 0;
 
    debug_printf("LLVMPIPE: current resources:\n");
+   mtx_lock(&resource_list_mutex);
    foreach(lpr, &resource_list) {
       unsigned size = llvmpipe_resource_size(&lpr->base);
       debug_printf("resource %u at %p, size %ux%ux%u: %u bytes, refcount %u\n",
@@ -880,6 +888,7 @@ llvmpipe_print_resources(void)
       total += size;
       n++;
    }
+   mtx_unlock(&resource_list_mutex);
    debug_printf("LLVMPIPE: total size of %u resources: %u\n", n, total);
 }
 #endif

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to