From: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
To: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
Subject: [PATCH 2/2] net: dummy: allocate devices with alloc_netdev_id
Date: Tue, 7 Jun 2011 04:39:46 +0300 [thread overview]
Message-ID: <1307410786-19110-3-git-send-email-lucian.grijincu@gmail.com> (raw)
In-Reply-To: <1307410786-19110-1-git-send-email-lucian.grijincu@gmail.com>
The most like case is that no one else is registering devices with a
name like "dummy%d".
We can bring the complexity down by replacing:
- alloc_netdev_id which is O(N) with
- alloc_netdev_id which, on the average case, is O(1).
$ time modprobe dummy numdummies=5000
- with alloc_netdev : 9.50s
- with alloc_netdev_id: 3.50s
NOTE: Stats generated on a heavily patched 3.0-rc1 which replaces the
current O(N^2) sysctl algorithm with a better one.
Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
---
drivers/net/dummy.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index 39cf9b9..24d4ee5 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -159,12 +159,14 @@ static struct rtnl_link_ops dummy_link_ops __read_mostly = {
module_param(numdummies, int, 0);
MODULE_PARM_DESC(numdummies, "Number of dummy pseudo devices");
+
+static int last_device_id = -1;
static int __init dummy_init_one(void)
{
struct net_device *dev_dummy;
int err;
- dev_dummy = alloc_netdev(0, "dummy%d", dummy_setup);
+ dev_dummy = alloc_netdev_id(0, "dummy%d", dummy_setup, &last_device_id);
if (!dev_dummy)
return -ENOMEM;
--
1.7.5.2.317.g391b14
next prev parent reply other threads:[~2011-06-07 1:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-07 1:39 [PATCH 0/2] speed up net device allocation using pattern names Lucian Adrian Grijincu
2011-06-07 1:39 ` [PATCH 1/2] net: add alloc_netdev_mqs_id Lucian Adrian Grijincu
2011-06-07 1:39 ` Lucian Adrian Grijincu [this message]
2011-06-07 3:19 ` [PATCH 2/2] net: dummy: allocate devices with alloc_netdev_id Eric Dumazet
2011-06-07 3:38 ` David Miller
2011-06-07 7:49 ` Lucian Adrian Grijincu
2011-06-07 7:59 ` Eric Dumazet
2011-06-07 8:30 ` Lucian Adrian Grijincu
2011-06-07 9:29 ` David Miller
2011-06-09 7:20 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1307410786-19110-3-git-send-email-lucian.grijincu@gmail.com \
--to=lucian.grijincu@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).