From d065304367140c4a855fbbeccb1896ba84edccfc Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 3 May 2023 16:07:34 -0400 Subject: [PATCH] aux/pipebuffer: add a return to pb_slabs_reclaim() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this lets drivers determine whether any reclaims have happened Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/pipebuffer/pb_slab.c | 16 ++++++++++++---- src/gallium/auxiliary/pipebuffer/pb_slab.h | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/pipebuffer/pb_slab.c b/src/gallium/auxiliary/pipebuffer/pb_slab.c index fa166b6a61d..8b79dfa1f96 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_slab.c @@ -73,14 +73,16 @@ pb_slab_reclaim(struct pb_slabs *slabs, struct pb_slab_entry *entry) #define MAX_FAILED_RECLAIMS 2 -static void +static unsigned pb_slabs_reclaim_locked(struct pb_slabs *slabs) { struct pb_slab_entry *entry, *next; unsigned num_failed_reclaims = 0; + unsigned num_reclaims = 0; LIST_FOR_EACH_ENTRY_SAFE(entry, next, &slabs->reclaim, head) { if (slabs->can_reclaim(slabs->priv, entry)) { pb_slab_reclaim(slabs, entry); + num_reclaims++; /* there are typically three possible scenarios when reclaiming: * - all entries reclaimed * - no entries reclaimed @@ -93,17 +95,21 @@ pb_slabs_reclaim_locked(struct pb_slabs *slabs) break; } } + return num_reclaims; } -static void +static unsigned pb_slabs_reclaim_all_locked(struct pb_slabs *slabs) { struct pb_slab_entry *entry, *next; + unsigned num_reclaims = 0; LIST_FOR_EACH_ENTRY_SAFE(entry, next, &slabs->reclaim, head) { if (slabs->can_reclaim(slabs->priv, entry)) { pb_slab_reclaim(slabs, entry); + num_reclaims++; } } + return num_reclaims; } /* 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 * required since pb_slab_alloc will eventually do the same thing. */ -void +unsigned pb_slabs_reclaim(struct pb_slabs *slabs) { + unsigned num_reclaims; simple_mtx_lock(&slabs->mutex); - pb_slabs_reclaim_locked(slabs); + num_reclaims = pb_slabs_reclaim_locked(slabs); simple_mtx_unlock(&slabs->mutex); + return num_reclaims; } /* Initialize the slabs manager. diff --git a/src/gallium/auxiliary/pipebuffer/pb_slab.h b/src/gallium/auxiliary/pipebuffer/pb_slab.h index 4fa5fd8d7d9..b59c7b0796a 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_slab.h +++ b/src/gallium/auxiliary/pipebuffer/pb_slab.h @@ -143,7 +143,7 @@ pb_slab_alloc(struct pb_slabs *slabs, unsigned size, unsigned heap); void pb_slab_free(struct pb_slabs* slabs, struct pb_slab_entry *entry); -void +unsigned pb_slabs_reclaim(struct pb_slabs *slabs); bool