Re: [PATCH] percpu-refcount: Don't use silly cmpxchg()

From: Tejun Heo
Date: Mon Jun 03 2013 - 19:09:31 EST


On Mon, Jun 03, 2013 at 04:02:29PM -0700, Kent Overstreet wrote:
> The cmpxcgh() was just to ensure the debug check didn't race, which was
> a bit excessive. The caller is supposed to do the appropriate
> synchronization, which means percpu_ref_kill() can just do a simple
> store.
>
> Signed-off-by: Kent Overstreet <koverstreet@xxxxxxxxxx>

Applied to percpu/for-3.11.

The only concern I have left now is that we now have bitwise-and and
test instead of just test in the hot path (get/put) to test whether
the percpu part is alive. As x86 has single and-and-test instruction
which doesn't require an output register, this only adds a single
instruction but this may lead to more overhead on other architectures.

The and-and-test was added because RCU free needs to have access to
the percpu pointer after the pointer is killed and can be removed by
adding another field to struct percpu_ref which remembers the pointer
separately from the original percpu pointer, which I think is a better
trade-off given that it makes the hot path lighter and adding another
pointer field to struct percpu_ref isn't really gonna affect anything.
Plus, it'd also make the code simpler.

Anyways, it's not a big concern at this point and we can address it
later.

Thanks a lot, everyone!

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