From: "Tobin C. Harding" <me@tobin.cc>
To: "David S . Miller" <davem@davemloft.net>
Cc: mawilcox@microsoft.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, "Tobin C. Harding" <me@tobin.cc>
Subject: [PATCH 0/2] net: Replace custom page based bitmap with IDA
Date: Sun, 12 Feb 2017 13:57:32 +1100 [thread overview]
Message-ID: <1486868254-5386-1-git-send-email-me@tobin.cc> (raw)
Current implementation of __dev_alloc_name uses a custom bitmap of
a single page to iterate network device id's and allocate an
unused id. This is seemingly the same task that the IDA does. Also the
current implementation leads to a upper limit of 8 * PAGE_SIZE on the
number of network id's (for each name format i.e eth0).
This patch uses the kernel's IDA as a replacement to the page based
bitmap. This has the effect of simplifying the code and removing
the upper limit.
Testing was carried out using a simple network device module, the
core of which is;
#define NDEVICES 32768 /* current implementation hard limit */
/* test driver */
static int tm_init_module(void)
{
int result;
int i;
unsigned long before, after, diff, msec;
pr_debug("tm: init module");
before = jiffies;
for (i = 0; i < NDEVICES; i++) {
devs[i] = alloc_netdev(0, "sn%d",
NET_NAME_UNKNOWN, tm_init);
if (!devs[i])
return -ENOMEM;
result = register_netdev(devs[i]);
if (result) {
pr_err("tm: error %i registering device \"%s\"\n",
result, devs[i]->name);
tm_cleanup();
return -ENODEV;
}
}
after = jiffies;
diff = (long)after - (long)before;
msec = diff * 1000 / HZ;
pr_debug("tm: Total milliseconds: %ld\n", msec);
return 0;
}
module_init(tm_init_module);
The main objective of this patch is to simplify the code of __dev_alloc_name.
As a side effect the hard limit is also removed. Results from running the,
admittedly convoluted, test module show that the patched version is slightly slower.
Benchmarks
==========
System: core i5 Linux 4.10.0-rc7+ #18 SMP
$ qemu-system-x86_64 -kernel arch/x86_64/boot/bzImage -drive file=/home/tobin/build/imgs/qemu-image.img,index=0,media=disk,format=raw -append "root=/dev/sda console=ttyS0" --enable-kvm --nographic -m 12G
Current implementation
#define NDEVICES 30000
[ 134.376741] tm: Total milliseconds: 127152
Patched version
#define NDEVICES 30000
[ 226.960212] tm: Total milliseconds: 220756
#define NDEVICES 35000
[ 276.590994] tm: Total milliseconds: 270620
Tobin C. Harding (2):
include: Fix checkpatch whitespace error and warning
net: Replace custom page based bitmap with IDA
include/linux/idr.h | 4 ++--
net/core/dev.c | 20 ++++++--------------
2 files changed, 8 insertions(+), 16 deletions(-)
--
2.7.4
next reply other threads:[~2017-02-12 2:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-12 2:57 Tobin C. Harding [this message]
2017-02-12 2:57 ` [PATCH 1/2] include: Fix checkpatch whitespace error and warning Tobin C. Harding
2017-02-12 10:39 ` Sergei Shtylyov
2017-02-12 12:17 ` Matthew Wilcox
2017-02-12 2:57 ` [PATCH 2/2] net: Replace custom page based bitmap with IDA Tobin C. Harding
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=1486868254-5386-1-git-send-email-me@tobin.cc \
--to=me@tobin.cc \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mawilcox@microsoft.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
all inboxes | Powered by JetHome®