Re: [PATCH -tip 00/12] locking/atomics: Add and use inc,dec calls for FETCH-OP flavors

From: James Bottomley
Date: Fri Jun 24 2016 - 12:46:15 EST


On Mon, 2016-06-20 at 13:05 -0700, Davidlohr Bueso wrote:
> Hi,
>
> The series is really straightforward and based on Peter's work that
> introduces[1] the atomic_fetch_$op machinery. Only patch 1 implements
> the actual atomic_fetch_{inc,dec} calls based on
> atomic_fetch_{add,sub}.

Could I just ask why? atomic_inc_return(x) - 1 seems a reasonable
thing to do to me. Is it because on architectures where atomics are
implemented in asm, it costs us one more CPU instruction to do the
extra decrement which gcc can't optimise? If that's it, I'm not sure
the added complexity justifies the cycle savings.

James