From 28bde895567aaf897171eebdbfe4ed9e860092f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 1 Oct 2021 15:40:40 -0400 Subject: [PATCH] util/slab: use simple_mtx_t Acked-By: Mike Blumenkrantz Reviewed-by: Timothy Arceri Reviewed-by: Kristian H. Kristensen Part-of: --- src/gallium/winsys/crocus/drm/meson.build | 1 + src/util/slab.c | 18 +++++++++--------- src/util/slab.h | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gallium/winsys/crocus/drm/meson.build b/src/gallium/winsys/crocus/drm/meson.build index 4e82fe52437..66b8dabb153 100644 --- a/src/gallium/winsys/crocus/drm/meson.build +++ b/src/gallium/winsys/crocus/drm/meson.build @@ -26,4 +26,5 @@ libcrocuswinsys = static_library( inc_gallium, inc_gallium_aux, inc_gallium_drivers, ], gnu_symbol_visibility : 'hidden', + dependencies : [dep_valgrind], ) diff --git a/src/util/slab.c b/src/util/slab.c index b0f07e0202d..1e778a12381 100644 --- a/src/util/slab.c +++ b/src/util/slab.c @@ -106,7 +106,7 @@ slab_create_parent(struct slab_parent_pool *parent, unsigned item_size, unsigned num_items) { - mtx_init(&parent->mutex, mtx_plain); + simple_mtx_init(&parent->mutex, mtx_plain); parent->element_size = ALIGN_POT(sizeof(struct slab_element_header) + item_size, sizeof(intptr_t)); parent->num_elements = num_items; @@ -115,7 +115,7 @@ slab_create_parent(struct slab_parent_pool *parent, void slab_destroy_parent(struct slab_parent_pool *parent) { - mtx_destroy(&parent->mutex); + simple_mtx_destroy(&parent->mutex); } /** @@ -141,7 +141,7 @@ void slab_destroy_child(struct slab_child_pool *pool) if (!pool->parent) return; /* the slab probably wasn't even created */ - mtx_lock(&pool->parent->mutex); + simple_mtx_lock(&pool->parent->mutex); while (pool->pages) { struct slab_page_header *page = pool->pages; @@ -160,7 +160,7 @@ void slab_destroy_child(struct slab_child_pool *pool) slab_free_orphaned(elt); } - mtx_unlock(&pool->parent->mutex); + simple_mtx_unlock(&pool->parent->mutex); while (pool->free) { struct slab_element_header *elt = pool->free; @@ -211,10 +211,10 @@ slab_alloc(struct slab_child_pool *pool) /* First, collect elements that belong to us but were freed from a * different child pool. */ - mtx_lock(&pool->parent->mutex); + simple_mtx_lock(&pool->parent->mutex); pool->free = pool->migrated; pool->migrated = NULL; - mtx_unlock(&pool->parent->mutex); + simple_mtx_unlock(&pool->parent->mutex); /* Now allocate a new page. */ if (!pool->free && !slab_add_new_page(pool)) @@ -258,7 +258,7 @@ void slab_free(struct slab_child_pool *pool, void *ptr) /* The slow case: migration or an orphaned page. */ if (pool->parent) - mtx_lock(&pool->parent->mutex); + simple_mtx_lock(&pool->parent->mutex); /* Note: we _must_ re-read elt->owner here because the owning child pool * may have been destroyed by another thread in the meantime. @@ -270,10 +270,10 @@ void slab_free(struct slab_child_pool *pool, void *ptr) elt->next = owner->migrated; owner->migrated = elt; if (pool->parent) - mtx_unlock(&pool->parent->mutex); + simple_mtx_unlock(&pool->parent->mutex); } else { if (pool->parent) - mtx_unlock(&pool->parent->mutex); + simple_mtx_unlock(&pool->parent->mutex); slab_free_orphaned(elt); } diff --git a/src/util/slab.h b/src/util/slab.h index f9e7d4754fe..969b0ec5c65 100644 --- a/src/util/slab.h +++ b/src/util/slab.h @@ -42,7 +42,7 @@ #ifndef SLAB_H #define SLAB_H -#include "c11/threads.h" +#include "simple_mtx.h" #ifdef __cplusplus extern "C" { @@ -52,7 +52,7 @@ struct slab_element_header; struct slab_page_header; struct slab_parent_pool { - mtx_t mutex; + simple_mtx_t mutex; unsigned element_size; unsigned num_elements; };