Re: [PATCH v10 01/21] rcuref: Provide rcuref_is_dead().

From: Peter Zijlstra
Date: Fri Mar 14 2025 - 06:39:29 EST


On Wed, Mar 12, 2025 at 04:16:14PM +0100, Sebastian Andrzej Siewior wrote:

> +/**
> + * rcuref_is_dead - Check if the rcuref has been already marked dead
> + * @ref: Pointer to the reference count
> + *
> + * Return: True if the object has been marked DEAD. This signals that a previous
> + * invocation of rcuref_put() returned true on this reference counter meaning
> + * the protected object can safely be scheduled for deconstruction.
> + * Otherwise, returns false.
> + */
> +static inline bool rcuref_is_dead(rcuref_t *ref)
> +{
> + unsigned int c = atomic_read(&ref->refcnt);
> +
> + return (c >= RCUREF_RELEASED) && (c < RCUREF_NOREF);
> +}

I had to check, but yes, the compiler generates sane code for this.