Re: [PATCH 22/25] Generic dynamic per cpu refcounting

From: Kent Overstreet
Date: Thu Nov 29 2012 - 13:57:13 EST


On Thu, Nov 29, 2012 at 10:45:04AM -0800, Andi Kleen wrote:
> Kent Overstreet <koverstreet@xxxxxxxxxx> writes:
>
> > This implements a refcount with similar semantics to
> > atomic_get()/atomic_dec_and_test(), that starts out as just an atomic_t
> > but dynamically switches to per cpu refcounting when the rate of
> > gets/puts becomes too high.
>
> This will only work if you put on the same CPU as you get, right?

Nope, no such restriction.

> In this case I would rather use RCU. It's clearly unusable for anything
> blocking (or not get_cpu) Normally RCU already handles the "ref count for short non
> blocking case"

The kioctx refcount isn't held for short nonblocking duration,
io_getevents() holds it and may block for arbitrarily long. Maybe SRCU
could be made to work for it (I havent' really looked at the RCU
variants) but it doesn't seem like a good idea.

This thing really is just a refcount, the percpu part isn't exposed to
the user at all.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/