[NET]: Reorder some hot fields of struct net_device

Place them on separate cache lines in SMP to lower memory bouncing
between multiple CPU accessing the device.

- One part is mostly used on receive path (including
eth_type_trans()) (poll_list, poll, quota, weight, last_rx,
dev_addr, broadcast)

- One part is mostly used on queue transmit path (qdisc)
(queue_lock, qdisc, qdisc_sleeping, qdisc_list, tx_queue_len)

- One part is mostly used on xmit path (device)
(xmit_lock, xmit_lock_owner, priv, hard_start_xmit, trans_start)

'features' is placed outside of these hot points, in a location that
may be shared by all cpus (because mostly read)

name_hlist is moved close to name[IFNAMSIZ] to speedup __dev_get_by_name()

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Eric Dumazet and committed by David S. Miller 9356b8fc 2d7ceece

+55 -34
+55 -34
include/linux/netdevice.h
··· 265 265 * the interface. 266 266 */ 267 267 char name[IFNAMSIZ]; 268 + /* device name hash chain */ 269 + struct hlist_node name_hlist; 268 270 269 271 /* 270 272 * I/O specific fields ··· 294 292 295 293 /* ------- Fields preinitialized in Space.c finish here ------- */ 296 294 295 + /* Net device features */ 296 + unsigned long features; 297 + #define NETIF_F_SG 1 /* Scatter/gather IO. */ 298 + #define NETIF_F_IP_CSUM 2 /* Can checksum only TCP/UDP over IPv4. */ 299 + #define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */ 300 + #define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */ 301 + #define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */ 302 + #define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */ 303 + #define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */ 304 + #define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */ 305 + #define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */ 306 + #define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */ 307 + #define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */ 308 + #define NETIF_F_LLTX 4096 /* LockLess TX */ 309 + 297 310 struct net_device *next_sched; 298 311 299 312 /* Interface index. Unique device identifier */ ··· 333 316 * will (read: may be cleaned up at will). 334 317 */ 335 318 336 - /* These may be needed for future network-power-down code. */ 337 - unsigned long trans_start; /* Time (in jiffies) of last Tx */ 338 - unsigned long last_rx; /* Time of last Rx */ 339 319 340 320 unsigned short flags; /* interface flags (a la BSD) */ 341 321 unsigned short gflags; ··· 342 328 unsigned mtu; /* interface MTU value */ 343 329 unsigned short type; /* interface hardware type */ 344 330 unsigned short hard_header_len; /* hardware hdr length */ 345 - void *priv; /* pointer to private data */ 346 331 347 332 struct net_device *master; /* Pointer to master device of a group, 348 333 * which this device is member of. 349 334 */ 350 335 351 336 /* Interface address info. */ 352 - unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ 353 - unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address */ 354 337 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ 355 338 unsigned char addr_len; /* hardware address length */ 356 339 unsigned short dev_id; /* for shared network cards */ ··· 357 346 int promiscuity; 358 347 int allmulti; 359 348 360 - int watchdog_timeo; 361 - struct timer_list watchdog_timer; 362 349 363 350 /* Protocol specific pointers */ 364 351 ··· 367 358 void *ec_ptr; /* Econet specific data */ 368 359 void *ax25_ptr; /* AX.25 specific data */ 369 360 370 - struct list_head poll_list; /* Link to poll list */ 361 + /* 362 + * Cache line mostly used on receive path (including eth_type_trans()) 363 + */ 364 + struct list_head poll_list ____cacheline_aligned_in_smp; 365 + /* Link to poll list */ 366 + 367 + int (*poll) (struct net_device *dev, int *quota); 371 368 int quota; 372 369 int weight; 370 + unsigned long last_rx; /* Time of last Rx */ 371 + /* Interface address info used in eth_type_trans() */ 372 + unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast 373 + because most packets are unicast) */ 373 374 375 + unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ 376 + 377 + /* 378 + * Cache line mostly used on queue transmit path (qdisc) 379 + */ 380 + /* device queue lock */ 381 + spinlock_t queue_lock ____cacheline_aligned_in_smp; 374 382 struct Qdisc *qdisc; 375 383 struct Qdisc *qdisc_sleeping; 376 - struct Qdisc *qdisc_ingress; 377 384 struct list_head qdisc_list; 378 385 unsigned long tx_queue_len; /* Max frames per queue allowed */ 379 386 380 387 /* ingress path synchronizer */ 381 388 spinlock_t ingress_lock; 389 + struct Qdisc *qdisc_ingress; 390 + 391 + /* 392 + * One part is mostly used on xmit path (device) 393 + */ 382 394 /* hard_start_xmit synchronizer */ 383 - spinlock_t xmit_lock; 395 + spinlock_t xmit_lock ____cacheline_aligned_in_smp; 384 396 /* cpu id of processor entered to hard_start_xmit or -1, 385 397 if nobody entered there. 386 398 */ 387 399 int xmit_lock_owner; 388 - /* device queue lock */ 389 - spinlock_t queue_lock; 400 + void *priv; /* pointer to private data */ 401 + int (*hard_start_xmit) (struct sk_buff *skb, 402 + struct net_device *dev); 403 + /* These may be needed for future network-power-down code. */ 404 + unsigned long trans_start; /* Time (in jiffies) of last Tx */ 405 + 406 + int watchdog_timeo; /* used by dev_watchdog() */ 407 + struct timer_list watchdog_timer; 408 + 409 + /* 410 + * refcnt is a very hot point, so align it on SMP 411 + */ 390 412 /* Number of references to this device */ 391 - atomic_t refcnt; 413 + atomic_t refcnt ____cacheline_aligned_in_smp; 414 + 392 415 /* delayed register/unregister */ 393 416 struct list_head todo_list; 394 - /* device name hash chain */ 395 - struct hlist_node name_hlist; 396 417 /* device index hash chain */ 397 418 struct hlist_node index_hlist; 398 419 ··· 435 396 NETREG_RELEASED, /* called free_netdev */ 436 397 } reg_state; 437 398 438 - /* Net device features */ 439 - unsigned long features; 440 - #define NETIF_F_SG 1 /* Scatter/gather IO. */ 441 - #define NETIF_F_IP_CSUM 2 /* Can checksum only TCP/UDP over IPv4. */ 442 - #define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */ 443 - #define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */ 444 - #define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */ 445 - #define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */ 446 - #define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */ 447 - #define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */ 448 - #define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */ 449 - #define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */ 450 - #define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */ 451 - #define NETIF_F_LLTX 4096 /* LockLess TX */ 452 - 453 399 /* Called after device is detached from network. */ 454 400 void (*uninit)(struct net_device *dev); 455 401 /* Called after last user reference disappears. */ ··· 443 419 /* Pointers to interface service routines. */ 444 420 int (*open)(struct net_device *dev); 445 421 int (*stop)(struct net_device *dev); 446 - int (*hard_start_xmit) (struct sk_buff *skb, 447 - struct net_device *dev); 448 422 #define HAVE_NETDEV_POLL 449 - int (*poll) (struct net_device *dev, int *quota); 450 423 int (*hard_header) (struct sk_buff *skb, 451 424 struct net_device *dev, 452 425 unsigned short type,