Re: [PATCH 09/12] drm/ttm: nuke buffer refcounting
From: Danilo Krummrich
Date: Sat Jul 11 2026 - 09:26:29 EST
On Fri Jul 10, 2026 at 8:52 PM CEST, =?UTF-8?q?Christian=20K=C3=B6nig?= wrote:
> +/**
> + * ttm_bo_is_deleted - test if buffer is already deleted
> + * @bo: the struct ttm_buffer_object to test
> + *
> + * Returns true if the buffer is already deleted and only waiting for
> + * destruction.
> + */
> +static inline bool ttm_bo_is_deleted(struct ttm_buffer_object *bo)
> +{
> + return !kref_read(&bo->base.refcount);
> +}
This is an anti-pattern, branch decisions cannot rely on an atomic reference
count unless additional invariants are upheld that otherwise guarantee that the
read values does not instantly become meaningless.
Something like this should at least document in which context and under which
conditions it is valid to rely on the returned value.