Mesa (main): gallium/pb_slab: use simple_mtx_t
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Oct 6 00:12:41 UTC 2021
Module: Mesa
Branch: main
Commit: 826e03e6e56ad4ea4fa5f24144940909f8c7d873
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=826e03e6e56ad4ea4fa5f24144940909f8c7d873
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri Oct 1 15:44:43 2021 -0400
gallium/pb_slab: use simple_mtx_t
Acked-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13152>
---
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;
More information about the mesa-commit
mailing list