On Wed, Jan 25, 2006 at 12:10:48PM +0100, Eric Dumazet wrote:
>
> So we cannot change atomic_dec_and_test(atomic_t *v) but introduce a new
> function like :
>
> int atomic_dec_refcount(atomic_t *v)
> {
> #ifdef CONFIG_SMP
> /* avoid an atomic op if we are the last user of this refcount */
> if (atomic_read(v) == 1) {
> atomic_set(v, 0); /* not a real atomic op on most machines */
> return 1;
> }
> #endif
> return atomic_dec_and_test(v);
> }
>
> The cost of the extra conditional branch is worth, if it can avoid an
> atomic op.
>
If it can always avoid an atomic op then the conditional branch is
useless, and if it can avoid the atomic op in 20% of cases then it
might still be useless (especially considering the extra icache).
Actual measurements would be required I think.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]