Re: [PATCH 3/3] kref: Remove the memory barriers

From: Peter Zijlstra
Date: Mon Dec 12 2011 - 03:56:50 EST


On Mon, 2011-12-12 at 11:48 +0800, Ming Lei wrote:
> We can't assume any lock about kref usage, because kref is often used
> in lockless scenario.

Then you're doing it wrong, seriously.

kref in lockless scenarios simply doesn't work, you need rcu (or another
means to stabilize storage) and atomic_inc_not_zero() as well as means
to validate your object after the lookup.


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