From 826e03e6e56ad4ea4fa5f24144940909f8c7d873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 1 Oct 2021 15:44:43 -0400 Subject: [PATCH] gallium/pb_slab: use simple_mtx_t Acked-By: Mike Blumenkrantz Reviewed-by: Timothy Arceri Reviewed-by: Kristian H. Kristensen Part-of: --- src/gallium/auxiliary/pipebuffer/pb_slab.c | 20 ++++++++++---------- src/gallium/auxiliary/pipebuffer/pb_slab.h | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/pipebuffer/pb_slab.c b/src/gallium/auxiliary/pipebuffer/pb_slab.c index 9918e854b1e..edb52dca8c7 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_slab.c @@ -120,7 +120,7 @@ pb_slab_alloc(struct pb_slabs *slabs, unsigned size, unsigned heap) (1 + slabs->allow_three_fourths_allocations) + three_fourths; group = &slabs->groups[group_index]; - mtx_lock(&slabs->mutex); + simple_mtx_lock(&slabs->mutex); /* If there is no candidate slab at all, or the first slab has no free * entries, try reclaiming entries. @@ -146,11 +146,11 @@ pb_slab_alloc(struct pb_slabs *slabs, unsigned size, unsigned heap) * There's a chance that racing threads will end up allocating multiple * slabs for the same group, but that doesn't hurt correctness. */ - mtx_unlock(&slabs->mutex); + simple_mtx_unlock(&slabs->mutex); slab = slabs->slab_alloc(slabs->priv, heap, entry_size, group_index); if (!slab) return NULL; - mtx_lock(&slabs->mutex); + simple_mtx_lock(&slabs->mutex); list_add(&slab->head, &group->slabs); } @@ -159,7 +159,7 @@ pb_slab_alloc(struct pb_slabs *slabs, unsigned size, unsigned heap) list_del(&entry->head); slab->num_free--; - mtx_unlock(&slabs->mutex); + simple_mtx_unlock(&slabs->mutex); return entry; } @@ -173,9 +173,9 @@ pb_slab_alloc(struct pb_slabs *slabs, unsigned size, unsigned heap) void pb_slab_free(struct pb_slabs* slabs, struct pb_slab_entry *entry) { - mtx_lock(&slabs->mutex); + simple_mtx_lock(&slabs->mutex); list_addtail(&entry->head, &slabs->reclaim); - mtx_unlock(&slabs->mutex); + simple_mtx_unlock(&slabs->mutex); } /* Check if any of the entries handed to pb_slab_free are ready to be re-used. @@ -187,9 +187,9 @@ pb_slab_free(struct pb_slabs* slabs, struct pb_slab_entry *entry) void pb_slabs_reclaim(struct pb_slabs *slabs) { - mtx_lock(&slabs->mutex); + simple_mtx_lock(&slabs->mutex); pb_slabs_reclaim_locked(slabs); - mtx_unlock(&slabs->mutex); + simple_mtx_unlock(&slabs->mutex); } /* Initialize the slabs manager. @@ -237,7 +237,7 @@ pb_slabs_init(struct pb_slabs *slabs, list_inithead(&group->slabs); } - (void) mtx_init(&slabs->mutex, mtx_plain); + (void) simple_mtx_init(&slabs->mutex, mtx_plain); return true; } @@ -261,5 +261,5 @@ pb_slabs_deinit(struct pb_slabs *slabs) } FREE(slabs->groups); - mtx_destroy(&slabs->mutex); + simple_mtx_destroy(&slabs->mutex); } diff --git a/src/gallium/auxiliary/pipebuffer/pb_slab.h b/src/gallium/auxiliary/pipebuffer/pb_slab.h index a7940b6b513..c6b115eca13 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_slab.h +++ b/src/gallium/auxiliary/pipebuffer/pb_slab.h @@ -45,6 +45,7 @@ #define PB_SLAB_H #include "pb_buffer.h" +#include "util/simple_mtx.h" #include "util/list.h" #include "os/os_thread.h" @@ -111,7 +112,7 @@ typedef bool (slab_can_reclaim_fn)(void *priv, struct pb_slab_entry *); */ struct pb_slabs { - mtx_t mutex; + simple_mtx_t mutex; unsigned min_order; unsigned num_orders;