On Wed, Nov 17, 2021 at 10:35:45AM -0800, Jakub Kicinski wrote:
On Wed, 17 Nov 2021 20:24:17 +0200 Leon Romanovsky wrote:
quoted
quoted
+/* Store a raw, unprotected pointer */
+static inline void __netdev_ref_store(struct netdev_ref *ref,
+ struct net_device *dev)
+{
+ ref->dev = dev;
+
+#ifdef CONFIG_DEBUG_OBJECTS_NETDEV_REFS
+ refcount_set(&ref->cnt, 0);
This is very uncommon pattern. I would expect that first pointer access
will start from 1, like all refcount_t users. If you still prefer to
start from 0, i suggest you to use atomic_t.
It's not really "starting from 0", it's more of a "setting the count
to invalid". It can't escape from this state with a simple inc.
I understand it and this is what raises eyebrows. The refcount_t type
has very clear semantics which you are stretching too far.
Let's see what Eric had in mind for his RFC.
Thanks