On Mon, 17 Jun 2013, Kent Overstreet wrote:

> +static inline unsigned alloc_local_tag(struct percpu_ida *pool,
> +                                    struct percpu_ida_cpu *tags)
> +{
> +     int tag = -ENOSPC;
> +
> +     spin_lock(&tags->lock);
> +     if (tags->nr_free)
> +                     tag = tags->freelist[--tags->nr_free];
> +     spin_unlock(&tags->lock);
> +
> +     return tag;
> +}

This could be made much faster by avoiding real atomics (coming with
spinlocks) and using per cpu atomics instead. Slub f.e. uses a single
linked per cpu list managed via this_cpu_cmpxchg.

In order to avoid locking completely the state of the percpu tag list must
fit into one word that can be handled via the local cmpxchg (or two with
the cmpxchg_double). May require some changes to the data structure.



--
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/

Reply via email to