zink/bo: check for usage before completion when reclaiming bos
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

checking completion alone disregards submit_count, which is used to
determine the validity of any existing usage pointer. this could lead to
large numbers of bos with stale usage and infinite memory ballooning

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41936>
This commit is contained in:
Mike Blumenkrantz 2026-06-01 11:10:58 -04:00 committed by Marge Bot
parent cf1ca02bd0
commit fa867cf189

View file

@ -135,6 +135,13 @@ bo_can_reclaim(struct zink_screen *screen, struct pb_buffer_lean *pbuf)
{
struct zink_bo *bo = zink_bo(pbuf);
/* ensure that submit_count is checked to determine if the usage pointer is stale */
if (!zink_bo_has_usage(bo)) {
/* if (submit_count > 1) then the usage pointer is invalid */
bo->reads.u = NULL;
bo->writes.u = NULL;
return true;
}
return zink_screen_usage_check_completion(screen, bo->reads.u) && zink_screen_usage_check_completion(screen, bo->writes.u);
}