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

2012-11-29 Thread Jamie Lokier
Kent Overstreet wrote: > On Thu, Nov 29, 2012 at 09:54:47PM +0100, Andi Kleen wrote: > > > > The regular atomic_t is limited in ways that you are not. > > > > See my original mail. > > > > > > I don't follow, can you explain? > > > > For most cases the reference count is tied to some object, whic

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

2012-11-29 Thread Kent Overstreet
On Thu, Nov 29, 2012 at 09:54:47PM +0100, Andi Kleen wrote: > > > The regular atomic_t is limited in ways that you are not. > > > See my original mail. > > > > I don't follow, can you explain? > > For most cases the reference count is tied to some object, which are > naturally limited by memory s

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

2012-11-29 Thread Andi Kleen
> > The regular atomic_t is limited in ways that you are not. > > See my original mail. > > I don't follow, can you explain? For most cases the reference count is tied to some object, which are naturally limited by memory size or other physical resources. But in the assymetric CPU case with your

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

2012-11-29 Thread Kent Overstreet
On Thu, Nov 29, 2012 at 12:42:17PM -0800, Andi Kleen wrote: > Kent Overstreet writes: > > > On Thu, Nov 29, 2012 at 02:34:52PM -0500, Benjamin LaHaise wrote: > >> On Thu, Nov 29, 2012 at 11:29:25AM -0800, Kent Overstreet wrote: > >> > There's some kind of symmetry going on here, and if I'd been a

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

2012-11-29 Thread Andi Kleen
Kent Overstreet writes: > On Thu, Nov 29, 2012 at 02:34:52PM -0500, Benjamin LaHaise wrote: >> On Thu, Nov 29, 2012 at 11:29:25AM -0800, Kent Overstreet wrote: >> > There's some kind of symmetry going on here, and if I'd been awake more >> > in college I could probably say exactly why it works, b

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

2012-11-29 Thread Kent Overstreet
On Thu, Nov 29, 2012 at 02:34:52PM -0500, Benjamin LaHaise wrote: > On Thu, Nov 29, 2012 at 11:29:25AM -0800, Kent Overstreet wrote: > > There's some kind of symmetry going on here, and if I'd been awake more > > in college I could probably say exactly why it works, but it does. > > I think the ca

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

2012-11-29 Thread Benjamin LaHaise
On Thu, Nov 29, 2012 at 11:29:25AM -0800, Kent Overstreet wrote: > There's some kind of symmetry going on here, and if I'd been awake more > in college I could probably say exactly why it works, but it does. I think the catch is that using only a 32 bit counter is something the user could arbitra

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

2012-11-29 Thread Kent Overstreet
On Thu, Nov 29, 2012 at 08:20:03PM +0100, Andi Kleen wrote: > > The trick is that we don't watch for the refcount hitting 0 until we're > > shutting down - so this only works if you keep track of your initial > > refcount. As long as we're not shutting down, we know the refcount can't > > hit 0 bec

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

2012-11-29 Thread Andi Kleen
> The trick is that we don't watch for the refcount hitting 0 until we're > shutting down - so this only works if you keep track of your initial > refcount. As long as we're not shutting down, we know the refcount can't > hit 0 because we haven't released the initial refcount. This seems dangerous

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

2012-11-29 Thread Kent Overstreet
On Thu, Nov 29, 2012 at 07:59:53PM +0100, Andi Kleen wrote: > On Thu, Nov 29, 2012 at 10:57:20AM -0800, Kent Overstreet wrote: > > On Thu, Nov 29, 2012 at 10:45:04AM -0800, Andi Kleen wrote: > > > Kent Overstreet writes: > > > > > > > This implements a refcount with similar semantics to > > > > a

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

2012-11-29 Thread Andi Kleen
On Thu, Nov 29, 2012 at 10:57:20AM -0800, Kent Overstreet wrote: > On Thu, Nov 29, 2012 at 10:45:04AM -0800, Andi Kleen wrote: > > Kent Overstreet writes: > > > > > This implements a refcount with similar semantics to > > > atomic_get()/atomic_dec_and_test(), that starts out as just an atomic_t >

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

2012-11-29 Thread Kent Overstreet
On Thu, Nov 29, 2012 at 10:45:04AM -0800, Andi Kleen wrote: > Kent Overstreet 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 > > get

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

2012-11-29 Thread Andi Kleen
Kent Overstreet 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

[PATCH 22/25] Generic dynamic per cpu refcounting

2012-11-28 Thread Kent Overstreet
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. It also implements two stage shutdown, as we need it to tear down the percpu cou