Messages in this thread | | | Date | Wed, 25 Jan 2006 12:18:29 +0100 | From | Nick Piggin <> | Subject | Re: [RFC] non-refcounted pages, application to slab? |
| |
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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |