From: Ravikiran G Thirumalai <hidden> Date: 2005-09-13 16:10:21
The net_device has a refcnt used to keep track of it's uses.
This is used at the time of unregistering the network device
(module unloading ..) (see netdev_wait_allrefs) .
For loopback_dev , this refcnt increment/decrement is causing
unnecessary traffic on the interlink for NUMA system
affecting it's performance. This patch improves tbench numbers by 6% on a
8way x86 Xeon (x445).
This patch is dependent on the bigref patch
Signed-off-by : Niraj Kumar [off-list ref]
Signed-off-by : Shai Fultheim [off-list ref]
Signed-off-by : Ravikiran Thirumalai [off-list ref]
Index: alloc_percpu-2.6.13/drivers/net/loopback.c
===================================================================
@@ -377,7 +378,7 @@/* device queue lock */spinlock_tqueue_lock;/* Number of references to this device */-atomic_trefcnt;+structbigrefnetdev_refcnt;/* delayed register/unregister */structlist_headtodo_list;/* device name hash chain */
@@ -677,11 +678,11 @@staticinlinevoiddev_put(structnet_device*dev){-atomic_dec(&dev->refcnt);+bigref_put(&dev->netdev_refcnt,NULL);}-#define __dev_put(dev) atomic_dec(&(dev)->refcnt)-#define dev_hold(dev) atomic_inc(&(dev)->refcnt)+#define __dev_put(dev) bigref_put(&(dev)->netdev_refcnt, NULL);+#define dev_hold(dev) bigref_get(&(dev)->netdev_refcnt);/* Carrier loss detection, dial on demand. The functions netif_carrier_on*and_offmaybecalledfromIRQcontext,butitiscaller
@@ -2838,7 +2839,7 @@printk(KERN_EMERG"unregister_netdevice: ""waiting for %s to become free. Usage ""count = %d\n",-dev->name,atomic_read(&dev->refcnt));+dev->name,bigref_val(&dev->netdev_refcnt));warning_time=jiffies;}}
@@ -2986,6 +2988,7 @@#ifdef CONFIG_SYSFS/* Compatiablity with error handling in drivers */if(dev->reg_state==NETREG_UNINITIALIZED){+bigref_destroy(&dev->netdev_refcnt);kfree((char*)dev-dev->padded);return;}
@@ -2996,6 +2999,7 @@/* will free via class release */class_device_put(&dev->class_dev);#else+bigref_destroy(&dev->netdev_refcnt);kfree((char*)dev-dev->padded);#endif}
From: Stephen Hemminger <hidden> Date: 2005-09-13 16:27:10
On Tue, 13 Sep 2005 09:10:12 -0700
Ravikiran G Thirumalai [off-list ref] wrote:
The net_device has a refcnt used to keep track of it's uses.
This is used at the time of unregistering the network device
(module unloading ..) (see netdev_wait_allrefs) .
For loopback_dev , this refcnt increment/decrement is causing
unnecessary traffic on the interlink for NUMA system
affecting it's performance. This patch improves tbench numbers by 6% on a
8way x86 Xeon (x445).
Since when is bringing a network device up/down performance critical?
From: Ben Greear <hidden> Date: 2005-09-13 16:35:37
Stephen Hemminger wrote:
On Tue, 13 Sep 2005 09:10:12 -0700
Ravikiran G Thirumalai [off-list ref] wrote:
quoted
The net_device has a refcnt used to keep track of it's uses.
This is used at the time of unregistering the network device
(module unloading ..) (see netdev_wait_allrefs) .
For loopback_dev , this refcnt increment/decrement is causing
unnecessary traffic on the interlink for NUMA system
affecting it's performance. This patch improves tbench numbers by 6% on a
8way x86 Xeon (x445).
Since when is bringing a network device up/down performance critical?
We grab and drop a reference for each poll of a device, roughly.
See dev_hold in _netif_rx_schedule(struct net_device *dev)
in include/netdevice.h, for instance.
Thanks,
Ben
--
Ben Greear [off-list ref]
Candela Technologies Inc http://www.candelatech.com
From: Stephen Hemminger <hidden> Date: 2005-09-13 16:46:11
On Tue, 13 Sep 2005 09:35:14 -0700
Ben Greear [off-list ref] wrote:
Stephen Hemminger wrote:
quoted
On Tue, 13 Sep 2005 09:10:12 -0700
Ravikiran G Thirumalai [off-list ref] wrote:
quoted
The net_device has a refcnt used to keep track of it's uses.
This is used at the time of unregistering the network device
(module unloading ..) (see netdev_wait_allrefs) .
For loopback_dev , this refcnt increment/decrement is causing
unnecessary traffic on the interlink for NUMA system
affecting it's performance. This patch improves tbench numbers by 6% on a
8way x86 Xeon (x445).
Since when is bringing a network device up/down performance critical?
We grab and drop a reference for each poll of a device, roughly.
See dev_hold in _netif_rx_schedule(struct net_device *dev)
in include/netdevice.h, for instance.
Yeah, that would be an issue, especially since the rest of that
path is nicely per-cpu
From: Eric Dumazet <hidden> Date: 2005-09-13 18:28:07
Ravikiran G Thirumalai a écrit :
The net_device has a refcnt used to keep track of it's uses.
This is used at the time of unregistering the network device
(module unloading ..) (see netdev_wait_allrefs) .
For loopback_dev , this refcnt increment/decrement is causing
unnecessary traffic on the interlink for NUMA system
affecting it's performance. This patch improves tbench numbers by 6% on a
8way x86 Xeon (x445).
@@ -377,7 +378,7 @@/* device queue lock */spinlock_tqueue_lock;/* Number of references to this device */-atomic_trefcnt;+structbigrefnetdev_refcnt;/* delayed register/unregister */structlist_headtodo_list;/* device name hash chain */
@@ -677,11 +678,11 @@
Hum...
Did you tried to place refcnt/netdev_refcnt in a separate cache line than
queue_lock ? I got good results too...
> /* device queue lock */
> spinlock_t queue_lock;
> /* Number of references to this device */
> - atomic_t refcnt;
> + struct bigref netdev_refcnt ____cacheline_aligned_in_smp ;
> /* delayed register/unregister */
> struct list_head todo_list;
> /* device name hash chain */
Every time a cpu take the queue_lock spinlock, it exclusively gets one cache
line. If another cpu try to access netdev_refcnt, it has to grab this cache
line (even if properely per_cpu designed, there is still one shared field). In
fact the whole struct net_device should be re-ordered for SMP/NUMA performance.
Eric
From: Ravikiran G Thirumalai <hidden> Date: 2005-09-13 18:53:55
On Tue, Sep 13, 2005 at 08:27:52PM +0200, Eric Dumazet wrote:
Ravikiran G Thirumalai a écrit :
Hum...
Did you tried to place refcnt/netdev_refcnt in a separate cache line than
queue_lock ? I got good results too...
quoted
/* device queue lock */
spinlock_t queue_lock;
/* Number of references to this device */
- atomic_t refcnt;
+ struct bigref netdev_refcnt ____cacheline_aligned_in_smp ;
/* delayed register/unregister */
struct list_head todo_list;
/* device name hash chain */
Every time a cpu take the queue_lock spinlock, it exclusively gets one
cache line. If another cpu try to access netdev_refcnt, it has to grab this
cache line (even if properely per_cpu designed, there is still one shared
field). In fact the whole struct net_device should be re-ordered for
SMP/NUMA performance.
I agree. Maybe placing the queue_lock in a different cacheline is the
right approach?
Thanks,
Kiran
Since when is bringing a network device up/down performance critical?
The issue is the dev_get()'s that occur all over the place
to during packet transmit/receive, that's what they are
trying to address.
I'm still against all of these invasive NUMA changes to the
networking though, they are simply too ugly and special cased
to consider seriously.
Since when is bringing a network device up/down performance critical?
The issue is the dev_get()'s that occur all over the place
to during packet transmit/receive, that's what they are
trying to address.
I'm still against all of these invasive NUMA changes to the
networking though, they are simply too ugly and special cased
to consider seriously.
All of them or the dst ones? Hopefully the netdevice refcounter patch
is not ugly or complicated as the dst ones? And why are they special cased?
Are networking workloads with high route locality not interesting?
Thanks,
Kiran