Commit 4c3d5e7b authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: reorder some fields of net_device

As time passed, some fields were added in net_device, and not
at sensible offsets.

Lets reorder some fields to reduce number of cache lines in RX path.
Fields not used in data path should be moved out of this critical cache
line.

In particular, move broadcast[] to the end of the rx section,
as it is less used, and ethernet uses only the beginning of the 32bytes
field.

Before patch :

offsetof(struct net_device,dev_addr)=0x258
offsetof(struct net_device,rx_handler)=0x2b8
offsetof(struct net_device,ingress_queue)=0x2c8
offsetof(struct net_device,broadcast)=0x278

After :

offsetof(struct net_device,dev_addr)=0x280
offsetof(struct net_device,rx_handler)=0x298
offsetof(struct net_device,ingress_queue)=0x2a8
offsetof(struct net_device,broadcast)=0x2b0
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8f0923c1
...@@ -1071,6 +1071,8 @@ struct net_device { ...@@ -1071,6 +1071,8 @@ struct net_device {
struct list_head dev_list; struct list_head dev_list;
struct list_head napi_list; struct list_head napi_list;
struct list_head unreg_list; struct list_head unreg_list;
struct list_head upper_dev_list; /* List of upper devices */
/* currently active device features */ /* currently active device features */
netdev_features_t features; netdev_features_t features;
...@@ -1143,6 +1145,13 @@ struct net_device { ...@@ -1143,6 +1145,13 @@ struct net_device {
spinlock_t addr_list_lock; spinlock_t addr_list_lock;
struct netdev_hw_addr_list uc; /* Unicast mac addresses */ struct netdev_hw_addr_list uc; /* Unicast mac addresses */
struct netdev_hw_addr_list mc; /* Multicast mac addresses */ struct netdev_hw_addr_list mc; /* Multicast mac addresses */
struct netdev_hw_addr_list dev_addrs; /* list of device
* hw addresses
*/
#ifdef CONFIG_SYSFS
struct kset *queues_kset;
#endif
bool uc_promisc; bool uc_promisc;
unsigned int promiscuity; unsigned int promiscuity;
unsigned int allmulti; unsigned int allmulti;
...@@ -1175,21 +1184,11 @@ struct net_device { ...@@ -1175,21 +1184,11 @@ struct net_device {
* avoid dirtying this cache line. * avoid dirtying this cache line.
*/ */
struct list_head upper_dev_list; /* List of upper devices */
/* Interface address info used in eth_type_trans() */ /* Interface address info used in eth_type_trans() */
unsigned char *dev_addr; /* hw address, (before bcast unsigned char *dev_addr; /* hw address, (before bcast
because most packets are because most packets are
unicast) */ unicast) */
struct netdev_hw_addr_list dev_addrs; /* list of device
hw addresses */
unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
#ifdef CONFIG_SYSFS
struct kset *queues_kset;
#endif
#ifdef CONFIG_RPS #ifdef CONFIG_RPS
struct netdev_rx_queue *_rx; struct netdev_rx_queue *_rx;
...@@ -1200,18 +1199,14 @@ struct net_device { ...@@ -1200,18 +1199,14 @@ struct net_device {
/* Number of RX queues currently active in device */ /* Number of RX queues currently active in device */
unsigned int real_num_rx_queues; unsigned int real_num_rx_queues;
#ifdef CONFIG_RFS_ACCEL
/* CPU reverse-mapping for RX completion interrupts, indexed
* by RX queue number. Assigned by driver. This must only be
* set if the ndo_rx_flow_steer operation is defined. */
struct cpu_rmap *rx_cpu_rmap;
#endif
#endif #endif
rx_handler_func_t __rcu *rx_handler; rx_handler_func_t __rcu *rx_handler;
void __rcu *rx_handler_data; void __rcu *rx_handler_data;
struct netdev_queue __rcu *ingress_queue; struct netdev_queue __rcu *ingress_queue;
unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
/* /*
* Cache lines mostly used on transmit path * Cache lines mostly used on transmit path
...@@ -1233,6 +1228,12 @@ struct net_device { ...@@ -1233,6 +1228,12 @@ struct net_device {
#ifdef CONFIG_XPS #ifdef CONFIG_XPS
struct xps_dev_maps __rcu *xps_maps; struct xps_dev_maps __rcu *xps_maps;
#endif #endif
#ifdef CONFIG_RFS_ACCEL
/* CPU reverse-mapping for RX completion interrupts, indexed
* by RX queue number. Assigned by driver. This must only be
* set if the ndo_rx_flow_steer operation is defined. */
struct cpu_rmap *rx_cpu_rmap;
#endif
/* These may be needed for future network-power-down code. */ /* These may be needed for future network-power-down code. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment