Big numbers of PPP devices...

David Luyer (luyer@ucs.uwa.edu.au)
Thu, 10 Jun 1999 15:37:04 +0800


I'm looking into building a kernel to have big numbers of PPP devices,
up to 1000 or so.

net/core/dev.c seemed particularly ugly in this regard.

The following is a suggested patch. It has a caveat of not guaranteeing
continuous device numbers above 64 (eg, multiple devices allocating above
64, a module being removed and re-inserted or a module which doesn't hang
on to allocated names), but the advantage of not being so inefficient or just
giving up. I don't see that continuous device numbers are needed, they're
nice while they're easy to allocate (low numbers) but once the numbers get
big, they become a problem.

Another alternative would be to add a third argument, "hint", to
dev_alloc_name and then get dev_alloc_name to scan 100 positions starting at
"hint" (then get the driver to send an appropriate hint). This would
potentially be even more efficient, but need a change to all net drivers.

Third alternative (my preference now I think about it): add a
dev_alloc_name_hint, make dev_alloc_name a #define with a hint of 0.

Comments?

David.

--- dev.c Fri Mar 26 01:23:34 1999
+++ dev.c.new Thu Jun 10 15:30:39 1999
@@ -299,16 +299,18 @@
int dev_alloc_name(struct device *dev, const char *name)
{
int i;
- /*
- * If you need over 100 please also fix the algorithm...
- */
- for(i=0;i<100;i++)
+ static int bignumber = 65;
+
+ for(i=0;i<64;i++)
{
sprintf(dev->name,name,i);
if(dev_get(dev->name)==NULL)
return i;
}
- return -ENFILE; /* Over 100 of the things .. bail out! */
+ sprintf(dev->name,name,bignumber++);
+ if(dev_get(dev->name)==NULL)
+ return i;
+ return -ENFILE; /* This shouldn't happen! Bail out! */
}

struct device *dev_alloc(const char *name, int *err)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/