From: Ben Greear <[EMAIL PROTECTED]>
Date: Thu, 01 Sep 2005 23:55:53 -0700
> Ok, so each object that now has a net_device* dev pointer instead
> gets this netdev_pointer object. When a reference is taken,
> this netdev_pointer object is linked into the netdevice object
> in a list. This requires a lock and is O(1) even with debugging
> disabled?
> On dev_put, you remove the reference from the netdev's list.
> This would be O(N) and require a lock with or without debugging enabled,
> right?
> (N == number of references)
All the list stuff gets compiled out unless we're debugging.
So this netdev_pointer degenerates into a fancy pointer.
We can use a "struct list_head" to avoid the unlink complexity.
> All of the code that currently goes foo->dev would have to be changed to
> foo->dev.dev for reference, and/or we'd change most methods to take a pointer
> to netdev_pointer instead of netdevice?
We'd have to hide things behind accessor macros, which is why
I named the member to be "__dev", with underscores. To make
direct accesses outside of specific interfaces be not done.
> Right, but we want to catch the cases where someone forgets, so the
> pointer object cannot be on the stack (we need something to reference
> X time later when we try to free the device and want to know who has
> a handle.) This implies kmalloc to me, since setting any static amount
> of them in the netdevice is just asking for trouble (or known failure
> mode, to use your term :)
Maybe these cases are so "obvious" that they don't need the tracking
code.
> I do like that your method gets rid of the kmalloc in at least one
> case, but to be honest, I still am partial to my method at this point
> because it has little to no cost when disabled (and it's done :))
Mine would be zero cost when disabled as well, I just forgot to
put the necessary ifdefs in some of my example code. When disabled
we'd have:
struct netdev_pointer {
struct netdev *dev;
};
and that degenerates to what we have today.
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html