From: Ben Greear <[EMAIL PROTECTED]> Date: Thu, 01 Sep 2005 23:11:28 -0700
> A quick optimization is to kmalloc chunks of 1000 or so structs at once > and then write a cheap foomalloc method to grab and release them. We > already take a lock (at least in my implementation), so this should be > small overhead. Better to eliminate all the kmalloc()'s altogether. It's bad for a debugging facility to have a known failure mode. > Maybe it's just too late..but I am not understanding this. How > do you print all of the current users of the device when you are > trying to release the device and something has a reference to it? The netdev_pointer's get linked in to a head pointer in the netdev itself. struct netdev { ... struct hlist_head debug_ref_list; ... }; struct netdev_pointer { ... struct hlist_node debug_ref_node; ... }; So you walk the debug_ref_list to get all the references grabbed of the object. > > Perhaps an even better idea for class #2 is to use a stack local > > "struct netdev_pointer", since that is the mode in which this > > case typically occurs, all within the same function so the function > > stack frame is live during the entire dummy refrence grab. > > Could you actually detect a reference leak in this case? The struct goes out > of scope when the method ends..but since we don't have auto-destructors > like C++, then there is nothing to force the release of the reference. Most of the cases in this class are in the scope of the method, ie. we do the put before the function returns. > Bad caps I can quickly fix..but I actually went to some trouble to > try to get the tabbing correct. Is my patch coming through with spaces > instead of tabs or something like that? Yes, spaces instead of tabs: - slave_dev = dev_get_by_name(srq.slave_name); + /* Need this up here so we know what the eventual reference for + * the slave_dev will be. This is to help with debugging netdev + * ref counts. --Ben + */ + s = kmalloc(sizeof(*s), GFP_KERNEL); + if (!s) { + return -ENOMEM; + } + + slave_dev = dev_get_by_name(srq.slave_name, &s->dev); and the unnecessary bracing there needs to be eliminated as well. Some of us still read code in 24 line terminals from time to time :) - 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