Bring sizeof(net_device) down to < 2K bytes
Subsystems (3)
v2 cover Bring sizeof(net_device) down to < 2K bytes
The size of struct net_device crossed the 2K boundary a while ago which is a waste in combination with many net namespaces. This series brings the size of struct net_device down to well below 2K in total size with a typical configuration. Some reserves a several holes leave room for further expansion.
Before:
/* size: 2176, cachelines: 34, members: 121 */
After:
/* size: 1984, cachelines: 31, members: 120 */
Thomas Graf (2):
e1000e: Move pm_qos_req to e1000e adapter
net_device: Reorder members to fill holes
drivers/net/ethernet/intel/e1000e/e1000.h | 1 + drivers/net/ethernet/intel/e1000e/netdev.c | 8 +++--- include/linux/netdevice.h | 46 ++++++++++++++---------------- 3 files changed, 26 insertions(+), 29 deletions(-)
---
v2:
- Moved pm_qos_req to e1000e adapter entirely as suggested by Daniel
- Dropped patch 2 based on comment from Eric. __alignof__ is not reliable to derive alignment of kmalloc returned pointer.
PATCH v2 1/2 e1000e: Move pm_qos_req to e1000e adapter
e1000e is the only driver requiring pm_qos_req, instead of causing every device to waste up to 240 bytes. Allocate it for the specific driver.
--- drivers/net/ethernet/intel/e1000e/e1000.h | 1 + drivers/net/ethernet/intel/e1000e/netdev.c | 8 ++++---- include/linux/netdevice.h | 1 - 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/e1000e/e1000.h +1 -0
@@ -343,6 +343,7 @@ struct e1000_adapter {struct timecounter tc;struct ptp_clock *ptp_clock;struct ptp_clock_info ptp_clock_info; +struct pm_qos_request pm_qos_req;u16 eee_advert; };
drivers/net/ethernet/intel/e1000e/netdev.c +4 -4
@@ -3297,9 +3297,9 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)ew32 (RXDCTL (0 ), rxdctl |0x3 ); } -pm_qos_update_request (&adapter->netdev->pm_qos_req, lat); +pm_qos_update_request (&adapter->pm_qos_req, lat); }else { -pm_qos_update_request (&adapter->netdev->pm_qos_req, +pm_qos_update_request (&adapter->pm_qos_req,PM_QOS_DEFAULT_VALUE ); }
@@ -4403,7 +4403,7 @@ static int e1000_open(struct net_device *netdev)e1000_update_mng_vlan (adapter);/* DMA latency requirement to workaround jumbo issue */ -pm_qos_add_request (&adapter->netdev->pm_qos_req,PM_QOS_CPU_DMA_LATENCY , +pm_qos_add_request (&adapter->pm_qos_req,PM_QOS_CPU_DMA_LATENCY ,PM_QOS_DEFAULT_VALUE );/* before we allocate an interrupt, we must be ready to handle it.
@@ -4514,7 +4514,7 @@ static int e1000_close(struct net_device *netdev) !test_bit(__E1000_TESTING, &adapter->state))e1000e_release_hw_control (adapter); -pm_qos_remove_request (&adapter->netdev->pm_qos_req); +pm_qos_remove_request (&adapter->pm_qos_req);pm_runtime_put_sync (&pdev->dev);
include/linux/netdevice.h +0 -1
@@ -1743,7 +1743,6 @@ struct net_device {#endif struct phy_device *phydev;struct lock_class_key *qdisc_tx_busylock; -struct pm_qos_request pm_qos_req; };#define to_net_dev (d) container_of(d, struct net_device, dev)
Signature · 1 line
1.9.3
Re: [PATCH 1/2 net-next] e1000e: Move pm_qos_req to e1000e adapter
Quoted 5 lines · Thomas Graf
e1000e is the only driver requiring
pm_qos_req, instead of causing every device to waste up to 240 bytes. Allocate it for the specific driver.Signed-off-by Thomas Graf <[email protected]>
Quoted 5 lines
--- drivers/net/ethernet/intel/e1000e/e1000.h | 1 + drivers/net/ethernet/intel/e1000e/netdev.c | 8 ++++---- include/linux/netdevice.h | 1 - 3 files changed, 5 insertions(+), 5 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20150410/bd78a132/attachment.asc>
PATCH v2 2/2 net_device: Reorder members to fill holes
In reply to Thomas GrafSome trivial reorders while preserving the RX/TX cache lines split to fill a couple of holes.
--- include/linux/netdevice.h | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-)
include/linux/netdevice.h +21 -24
@@ -1305,6 +1305,8 @@ enum netdev_priv_flags {* @base_addr: Device I/O address * @irq: Device IRQ number * +* @carrier_changes: Stats to monitor carrier on<->off transitions +* * @state: Generic network queuing layer state, see netdev_state_t * @dev_list: The global list of network devices * @napi_list: List entry, that is used for polling napi devices
@@ -1338,8 +1340,6 @@ enum netdev_priv_flags {* @tx_dropped: Dropped packets by core network, * do not use this in drivers * -* @carrier_changes: Stats to monitor carrier on<->off transitions -* * @wireless_handlers: List of functions to handle Wireless Extensions, * instead of ioctl, * see <net/iw_handler.h> for details.
@@ -1382,14 +1382,14 @@ enum netdev_priv_flags {* @dev_port: Used to differentiate devices that share * the same function * @addr_list_lock: XXX: need comments on this one -* @uc: unicast mac addresses -* @mc: multicast mac addresses -* @dev_addrs: list of device hw addresses -* @queues_kset: Group of all Kobjects in the Tx and RX queues * @uc_promisc: Counter, that indicates, that promiscuous mode * has been enabled due to the need to listen to * additional unicast addresses in a device that * does not implement ndo_set_rx_mode() +* @uc: unicast mac addresses +* @mc: multicast mac addresses +* @dev_addrs: list of device hw addresses +* @queues_kset: Group of all Kobjects in the Tx and RX queues * @promiscuity: Number of times, the NIC is told to work in * Promiscuous mode, if it becomes 0 the NIC will * exit from working in Promiscuous mode
@@ -1419,6 +1419,12 @@ enum netdev_priv_flags {* @ingress_queue: XXX: need comments on this one * @broadcast: hw bcast address * +* @rx_cpu_rmap: 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 +* @index_hlist: Device index hash chain +* * @_tx: Array of TX queues * @num_tx_queues: Number of TX queues allocated at alloc_netdev_mq() time * @real_num_tx_queues: Number of TX queues currently active in device
@@ -1428,11 +1434,6 @@ enum netdev_priv_flags {* * @xps_maps: XXX: need comments on this one * -* @rx_cpu_rmap: 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 -* * @trans_start: Time (in jiffies) of last Tx * @watchdog_timeo: Represents the timeout that is used by * the watchdog ( see dev_watchdog() )
@@ -1440,7 +1441,6 @@ enum netdev_priv_flags {* * @pcpu_refcnt: Number of references to this device * @todo_list: Delayed register/unregister -* @index_hlist: Device index hash chain * @link_watch_list: XXX: need comments on this one * * @reg_state: Register/unregister state machine
@@ -1507,6 +1507,8 @@ struct net_device {unsigned long base_addr;int irq; +atomic_t carrier_changes; +/* * Some hardware also needs these fields (state,dev_list, * napi_list,unreg_list,close_list) but they are not
@@ -1547,8 +1549,6 @@ struct net_device {atomic_long_t rx_dropped;atomic_long_t tx_dropped; -atomic_t carrier_changes; -#ifdef CONFIG_WIRELESS_EXT const struct iw_handler_def * wireless_handlers;struct iw_public_data * wireless_data;
@@ -1588,6 +1588,8 @@ struct net_device {unsigned short dev_id;unsigned short dev_port;spinlock_t addr_list_lock; +unsigned char name_assign_type; +bool uc_promisc;struct netdev_hw_addr_list uc;struct netdev_hw_addr_list mc;struct netdev_hw_addr_list dev_addrs;
@@ -1595,10 +1597,6 @@ struct net_device {#ifdef CONFIG_SYSFS struct kset *queues_kset;#endif - -unsigned char name_assign_type; - -bool uc_promisc;unsigned int promiscuity;unsigned int allmulti;
@@ -1645,7 +1643,10 @@ struct net_device {struct netdev_queue __rcu *ingress_queue;unsigned char broadcast[MAX_ADDR_LEN ]; - +#ifdef CONFIG_RFS_ACCEL +struct cpu_rmap *rx_cpu_rmap; +#endif +struct hlist_node index_hlist;/* * Cache lines mostly used on transmit path
@@ -1656,13 +1657,11 @@ struct net_device {struct Qdisc *qdisc;unsigned long tx_queue_len;spinlock_t tx_global_lock; +int watchdog_timeo;#ifdef CONFIG_XPS struct xps_dev_maps __rcu *xps_maps;#endif -#ifdef CONFIG_RFS_ACCEL -struct cpu_rmap *rx_cpu_rmap; -#endif /* These may be needed for future network-power-down code. */
@@ -1672,13 +1671,11 @@ struct net_device {*/ unsigned long trans_start; -int watchdog_timeo;struct timer_list watchdog_timer;int __percpu *pcpu_refcnt;struct list_head todo_list; -struct hlist_node index_hlist;struct list_head link_watch_list;enum {NETREG_UNINITIALIZED =0 ,
Signature · 1 line
1.9.3
Re: [PATCH 2/2 net-next] net_device: Reorder members to fill holes
Quoted 7 lines · Thomas Graf
Some trivial reorders while preserving the RX/TX cache lines split to fill a couple of holes.
Signed-off-by Thomas Graf <[email protected]>--- include/linux/netdevice.h | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-)
Thanks Thomas !
David Miller
maintainerFrom: Thomas Graf <[email protected]>
Date: Fri, 10 Apr 2015 15:52:36 +0200
Quoted 11 lines
The size of struct
net_devicecrossed the 2K boundary a while ago which is a waste in combination with many net namespaces. This series brings the size of structnet_devicedown to well below 2K in total size with a typical configuration. Some reserves a several holes leave room for further expansion.Before:
/* size: 2176, cachelines: 34, members: 121 */After:
/* size: 1984, cachelines: 31, members: 120 */
Series applied, thanks Thomas