netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] ixp2000: rtnl_lock out of loop will be faster
@ 2007-12-12  8:48 Wang Chen
  2007-12-12 20:01 ` Lennert Buytenhek
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Chen @ 2007-12-12  8:48 UTC (permalink / raw)
  To: David S. Miller, Jeff Garzik; +Cc: buytenh, netdev, Wang Chen

[PATCH 3/4] [NETDEV] ixp2000: rtnl_lock out of loop will be faster

Before this patch, it gets and releases the lock at each
iteration of the loop. Changing unregister_netdev to
unregister_netdevice and locking outside of the loop will
be faster for this approach.

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
 ixpdev.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff -Nurp linux-2.6.24.rc5.org/drivers/net/ixp2000/ixpdev.c linux-2.6.24.rc5/drivers/net/ixp2000/ixpdev.c
--- linux-2.6.24.rc5.org/drivers/net/ixp2000/ixpdev.c	2007-12-12 10:19:41.000000000 +0800
+++ linux-2.6.24.rc5/drivers/net/ixp2000/ixpdev.c	2007-12-12 16:25:44.000000000 +0800
@@ -15,6 +15,7 @@
 #include <linux/etherdevice.h>
 #include <linux/init.h>
 #include <linux/moduleparam.h>
+#include <linux/rtnetlink.h>
 #include <asm/hardware/uengine.h>
 #include <asm/mach-types.h>
 #include <asm/io.h>
@@ -375,14 +376,16 @@ int ixpdev_init(int __nds_count, struct 
 	ixp2000_uengine_load(1, &ixp2400_tx);
 	ixp2000_uengine_start_contexts(1, 0xff);
 
+	rtnl_lock();
 	for (i = 0; i < nds_count; i++) {
-		err = register_netdev(nds[i]);
+		err = register_netdevice(nds[i]);
 		if (err) {
 			while (--i >= 0)
-				unregister_netdev(nds[i]);
+				unregister_netdevice(nds[i]);
 			goto err_free_tx;
 		}
 	}
+	rtnl_unlock();
 
 	for (i = 0; i < nds_count; i++) {
 		printk(KERN_INFO "%s: IXP2000 MSF ethernet (port %d), "
@@ -395,6 +398,7 @@ int ixpdev_init(int __nds_count, struct 
 	return 0;
 
 err_free_tx:
+	rtnl_unlock();
 	for (i = 0; i < TX_BUF_COUNT; i++)
 		free_page((unsigned long)phys_to_virt(tx_desc[i].buf_addr));
 
@@ -412,8 +416,10 @@ void ixpdev_deinit(void)
 
 	/* @@@ Flush out pending packets.  */
 
+	rtnl_lock();
 	for (i = 0; i < nds_count; i++)
-		unregister_netdev(nds[i]);
+		unregister_netdevice(nds[i]);
+	rtnl_unlock();
 
 	ixp2000_uengine_stop_contexts(1, 0xff);
 	ixp2000_uengine_stop_contexts(0, 0xff);


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/4] ixp2000: rtnl_lock out of loop will be faster
  2007-12-12  8:48 [PATCH 3/4] ixp2000: rtnl_lock out of loop will be faster Wang Chen
@ 2007-12-12 20:01 ` Lennert Buytenhek
  0 siblings, 0 replies; 2+ messages in thread
From: Lennert Buytenhek @ 2007-12-12 20:01 UTC (permalink / raw)
  To: Wang Chen; +Cc: David S. Miller, Jeff Garzik, netdev

On Wed, Dec 12, 2007 at 04:48:28PM +0800, Wang Chen wrote:

> [PATCH 3/4] [NETDEV] ixp2000: rtnl_lock out of loop will be faster
> 
> Before this patch, it gets and releases the lock at each
> iteration of the loop. Changing unregister_netdev to
> unregister_netdevice and locking outside of the loop will
> be faster for this approach.

Since the number of net devices is typically either 2 or 3 (depending
on the specific model card you're using), and this is not in any kind
of hot path at all, I don't see a whole lot of benefit of acquiring
the RTNL separately.  Besides, I'm slightly worried about putting
knowledge of the RTNL into the driver directly.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-12 20:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-12  8:48 [PATCH 3/4] ixp2000: rtnl_lock out of loop will be faster Wang Chen
2007-12-12 20:01 ` Lennert Buytenhek

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).