All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next-2.6] net: shrinks struct net_device
@ 2010-09-16 12:58 Eric Dumazet
  2010-09-17  4:59 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2010-09-16 12:58 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Jiri Pirko

commit ab95bfe01 (net: replace hooks in __netif_receive_skb) added
rx_handler at wrong place, between two cache line aligned objects,
creating a big hole (a full cache line)

Move rx_handler and rx_handler_data before rx_queue, filling existing
hole.

Move master field in the cache line(s) used in receive path.

This saves 64 bytes (or L1_CACHE_BYTES), and avoids two possible
cache misses in receive path.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 include/linux/netdevice.h |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 8992fff..ec17887 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -918,10 +918,6 @@ struct net_device {
 	unsigned short		needed_headroom;
 	unsigned short		needed_tailroom;
 
-	struct net_device	*master; /* Pointer to master device of a group,
-					  * which this device is member of.
-					  */
-
 	/* Interface address info. */
 	unsigned char		perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
 	unsigned char		addr_assign_type; /* hw address assignment type */
@@ -951,7 +947,7 @@ struct net_device {
 						   assign before registering */
 
 /*
- * Cache line mostly used on receive path (including eth_type_trans())
+ * Cache lines mostly used on receive path (including eth_type_trans())
  */
 	unsigned long		last_rx;	/* Time of last Rx
 						 * This should not be set in
@@ -961,6 +957,10 @@ struct net_device {
 						 * avoid dirtying this cache line.
 						 */
 
+	struct net_device	*master; /* Pointer to master device of a group,
+					  * which this device is member of.
+					  */
+
 	/* Interface address info used in eth_type_trans() */
 	unsigned char		*dev_addr;	/* hw address, (before bcast
 						   because most packets are
@@ -980,10 +980,14 @@ struct net_device {
 	unsigned int		num_rx_queues;
 #endif
 
-	struct netdev_queue	rx_queue;
 	rx_handler_func_t	*rx_handler;
 	void			*rx_handler_data;
 
+	struct netdev_queue	rx_queue; /* use two cache lines */
+
+/*
+ * Cache lines mostly used on transmit path
+ */
 	struct netdev_queue	*_tx ____cacheline_aligned_in_smp;
 
 	/* Number of TX queues allocated at alloc_netdev_mq() time  */
@@ -997,9 +1001,7 @@ struct net_device {
 
 	unsigned long		tx_queue_len;	/* Max frames per queue allowed */
 	spinlock_t		tx_global_lock;
-/*
- * One part is mostly used on xmit path (device)
- */
+
 	/* These may be needed for future network-power-down code. */
 
 	/*



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

* Re: [PATCH net-next-2.6] net: shrinks struct net_device
  2010-09-16 12:58 [PATCH net-next-2.6] net: shrinks struct net_device Eric Dumazet
@ 2010-09-17  4:59 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-09-17  4:59 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, jpirko

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 16 Sep 2010 14:58:13 +0200

> commit ab95bfe01 (net: replace hooks in __netif_receive_skb) added
> rx_handler at wrong place, between two cache line aligned objects,
> creating a big hole (a full cache line)
> 
> Move rx_handler and rx_handler_data before rx_queue, filling existing
> hole.
> 
> Move master field in the cache line(s) used in receive path.
> 
> This saves 64 bytes (or L1_CACHE_BYTES), and avoids two possible
> cache misses in receive path.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Also applied, thanks Eric.

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

end of thread, other threads:[~2010-09-17  4:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-16 12:58 [PATCH net-next-2.6] net: shrinks struct net_device Eric Dumazet
2010-09-17  4:59 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.