gallium/pb_slab: use simple_mtx_t
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13152>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user