Re: [PATCH] refcount: provide same memory ordering guarantees as in atomic_t

From: Peter Zijlstra
Date: Mon Oct 23 2017 - 09:12:39 EST


On Mon, Oct 23, 2017 at 02:09:44PM +0300, Elena Reshetova wrote:
> Currently arch. independent implementation of refcount_t in
> lib/refcount.c provides weak memory ordering guarantees
> compare to its analog atomic_t implementations.
> While it should not be a problem for most of the actual
> cases of refcounters, it is more understandable for everyone
> (and more error-prone for future users) to provide exactly
> same memory ordering guarantees as atomics.
>
> If speed is of a concern, then either more efficient arch.
> dependent refcount_t implementation should be used or if there
> are enough users in the future we might need to provide both
> strict and relaxed refcount_t APIs.
>
> Suggested-by: Kees Cook <keescook@xxxxxxxxxxxx>

NAK