lkml.org 
[lkml]   [2006]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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/

\
 
 \ /
  Last update: 2006-01-25 12:21    [W:0.079 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site