aux/pipebuffer: add a return to pb_slabs_reclaim()

this lets drivers determine whether any reclaims have happened

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23073>
This commit is contained in:
Mike Blumenkrantz 2023-05-03 16:07:34 -04:00 committed by Marge Bot
parent fde8bf7b7f
commit d065304367
2 changed files with 13 additions and 5 deletions

View file

@ -73,14 +73,16 @@ pb_slab_reclaim(struct pb_slabs *slabs, struct pb_slab_entry *entry)
#define MAX_FAILED_RECLAIMS 2 #define MAX_FAILED_RECLAIMS 2
static void static unsigned
pb_slabs_reclaim_locked(struct pb_slabs *slabs) pb_slabs_reclaim_locked(struct pb_slabs *slabs)
{ {
struct pb_slab_entry *entry, *next; struct pb_slab_entry *entry, *next;
unsigned num_failed_reclaims = 0; unsigned num_failed_reclaims = 0;
unsigned num_reclaims = 0;
LIST_FOR_EACH_ENTRY_SAFE(entry, next, &slabs->reclaim, head) { LIST_FOR_EACH_ENTRY_SAFE(entry, next, &slabs->reclaim, head) {
if (slabs->can_reclaim(slabs->priv, entry)) { if (slabs->can_reclaim(slabs->priv, entry)) {
pb_slab_reclaim(slabs, entry); pb_slab_reclaim(slabs, entry);
num_reclaims++;
/* there are typically three possible scenarios when reclaiming: /* there are typically three possible scenarios when reclaiming:
* - all entries reclaimed * - all entries reclaimed
* - no entries reclaimed * - no entries reclaimed
@ -93,17 +95,21 @@ pb_slabs_reclaim_locked(struct pb_slabs *slabs)
break; break;
} }
} }
return num_reclaims;
} }
static void static unsigned
pb_slabs_reclaim_all_locked(struct pb_slabs *slabs) pb_slabs_reclaim_all_locked(struct pb_slabs *slabs)
{ {
struct pb_slab_entry *entry, *next; struct pb_slab_entry *entry, *next;
unsigned num_reclaims = 0;
LIST_FOR_EACH_ENTRY_SAFE(entry, next, &slabs->reclaim, head) { LIST_FOR_EACH_ENTRY_SAFE(entry, next, &slabs->reclaim, head) {
if (slabs->can_reclaim(slabs->priv, entry)) { if (slabs->can_reclaim(slabs->priv, entry)) {
pb_slab_reclaim(slabs, entry); pb_slab_reclaim(slabs, entry);
num_reclaims++;
} }
} }
return num_reclaims;
} }
/* Allocate a slab entry of the given size from the given heap. /* Allocate a slab entry of the given size from the given heap.
@ -215,12 +221,14 @@ pb_slab_free(struct pb_slabs* slabs, struct pb_slab_entry *entry)
* some no longer used memory. However, calling this function is not strictly * some no longer used memory. However, calling this function is not strictly
* required since pb_slab_alloc will eventually do the same thing. * required since pb_slab_alloc will eventually do the same thing.
*/ */
void unsigned
pb_slabs_reclaim(struct pb_slabs *slabs) pb_slabs_reclaim(struct pb_slabs *slabs)
{ {
unsigned num_reclaims;
simple_mtx_lock(&slabs->mutex); simple_mtx_lock(&slabs->mutex);
pb_slabs_reclaim_locked(slabs); num_reclaims = pb_slabs_reclaim_locked(slabs);
simple_mtx_unlock(&slabs->mutex); simple_mtx_unlock(&slabs->mutex);
return num_reclaims;
} }
/* Initialize the slabs manager. /* Initialize the slabs manager.

View file

@ -143,7 +143,7 @@ pb_slab_alloc(struct pb_slabs *slabs, unsigned size, unsigned heap);
void void
pb_slab_free(struct pb_slabs* slabs, struct pb_slab_entry *entry); pb_slab_free(struct pb_slabs* slabs, struct pb_slab_entry *entry);
void unsigned
pb_slabs_reclaim(struct pb_slabs *slabs); pb_slabs_reclaim(struct pb_slabs *slabs);
bool bool