Skip to content

Commit dfc96c1

Browse files
committed
Merge branch 'netdev_diet'
Thomas Graf says: ==================== 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 */ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents cf89013 + 14ffbbb commit dfc96c1

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

drivers/net/ethernet/intel/e1000e/e1000.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ struct e1000_adapter {
343343
struct timecounter tc;
344344
struct ptp_clock *ptp_clock;
345345
struct ptp_clock_info ptp_clock_info;
346+
struct pm_qos_request pm_qos_req;
346347

347348
u16 eee_advert;
348349
};

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3297,9 +3297,9 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
32973297
ew32(RXDCTL(0), rxdctl | 0x3);
32983298
}
32993299

3300-
pm_qos_update_request(&adapter->netdev->pm_qos_req, lat);
3300+
pm_qos_update_request(&adapter->pm_qos_req, lat);
33013301
} else {
3302-
pm_qos_update_request(&adapter->netdev->pm_qos_req,
3302+
pm_qos_update_request(&adapter->pm_qos_req,
33033303
PM_QOS_DEFAULT_VALUE);
33043304
}
33053305

@@ -4403,7 +4403,7 @@ static int e1000_open(struct net_device *netdev)
44034403
e1000_update_mng_vlan(adapter);
44044404

44054405
/* DMA latency requirement to workaround jumbo issue */
4406-
pm_qos_add_request(&adapter->netdev->pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
4406+
pm_qos_add_request(&adapter->pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
44074407
PM_QOS_DEFAULT_VALUE);
44084408

44094409
/* before we allocate an interrupt, we must be ready to handle it.
@@ -4514,7 +4514,7 @@ static int e1000_close(struct net_device *netdev)
45144514
!test_bit(__E1000_TESTING, &adapter->state))
45154515
e1000e_release_hw_control(adapter);
45164516

4517-
pm_qos_remove_request(&adapter->netdev->pm_qos_req);
4517+
pm_qos_remove_request(&adapter->pm_qos_req);
45184518

45194519
pm_runtime_put_sync(&pdev->dev);
45204520

include/linux/netdevice.h

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,8 @@ enum netdev_priv_flags {
13131313
* @base_addr: Device I/O address
13141314
* @irq: Device IRQ number
13151315
*
1316+
* @carrier_changes: Stats to monitor carrier on<->off transitions
1317+
*
13161318
* @state: Generic network queuing layer state, see netdev_state_t
13171319
* @dev_list: The global list of network devices
13181320
* @napi_list: List entry, that is used for polling napi devices
@@ -1346,8 +1348,6 @@ enum netdev_priv_flags {
13461348
* @tx_dropped: Dropped packets by core network,
13471349
* do not use this in drivers
13481350
*
1349-
* @carrier_changes: Stats to monitor carrier on<->off transitions
1350-
*
13511351
* @wireless_handlers: List of functions to handle Wireless Extensions,
13521352
* instead of ioctl,
13531353
* see <net/iw_handler.h> for details.
@@ -1390,14 +1390,14 @@ enum netdev_priv_flags {
13901390
* @dev_port: Used to differentiate devices that share
13911391
* the same function
13921392
* @addr_list_lock: XXX: need comments on this one
1393-
* @uc: unicast mac addresses
1394-
* @mc: multicast mac addresses
1395-
* @dev_addrs: list of device hw addresses
1396-
* @queues_kset: Group of all Kobjects in the Tx and RX queues
13971393
* @uc_promisc: Counter, that indicates, that promiscuous mode
13981394
* has been enabled due to the need to listen to
13991395
* additional unicast addresses in a device that
14001396
* does not implement ndo_set_rx_mode()
1397+
* @uc: unicast mac addresses
1398+
* @mc: multicast mac addresses
1399+
* @dev_addrs: list of device hw addresses
1400+
* @queues_kset: Group of all Kobjects in the Tx and RX queues
14011401
* @promiscuity: Number of times, the NIC is told to work in
14021402
* Promiscuous mode, if it becomes 0 the NIC will
14031403
* exit from working in Promiscuous mode
@@ -1427,6 +1427,12 @@ enum netdev_priv_flags {
14271427
* @ingress_queue: XXX: need comments on this one
14281428
* @broadcast: hw bcast address
14291429
*
1430+
* @rx_cpu_rmap: CPU reverse-mapping for RX completion interrupts,
1431+
* indexed by RX queue number. Assigned by driver.
1432+
* This must only be set if the ndo_rx_flow_steer
1433+
* operation is defined
1434+
* @index_hlist: Device index hash chain
1435+
*
14301436
* @_tx: Array of TX queues
14311437
* @num_tx_queues: Number of TX queues allocated at alloc_netdev_mq() time
14321438
* @real_num_tx_queues: Number of TX queues currently active in device
@@ -1436,19 +1442,13 @@ enum netdev_priv_flags {
14361442
*
14371443
* @xps_maps: XXX: need comments on this one
14381444
*
1439-
* @rx_cpu_rmap: CPU reverse-mapping for RX completion interrupts,
1440-
* indexed by RX queue number. Assigned by driver.
1441-
* This must only be set if the ndo_rx_flow_steer
1442-
* operation is defined
1443-
*
14441445
* @trans_start: Time (in jiffies) of last Tx
14451446
* @watchdog_timeo: Represents the timeout that is used by
14461447
* the watchdog ( see dev_watchdog() )
14471448
* @watchdog_timer: List of timers
14481449
*
14491450
* @pcpu_refcnt: Number of references to this device
14501451
* @todo_list: Delayed register/unregister
1451-
* @index_hlist: Device index hash chain
14521452
* @link_watch_list: XXX: need comments on this one
14531453
*
14541454
* @reg_state: Register/unregister state machine
@@ -1515,6 +1515,8 @@ struct net_device {
15151515
unsigned long base_addr;
15161516
int irq;
15171517

1518+
atomic_t carrier_changes;
1519+
15181520
/*
15191521
* Some hardware also needs these fields (state,dev_list,
15201522
* napi_list,unreg_list,close_list) but they are not
@@ -1555,8 +1557,6 @@ struct net_device {
15551557
atomic_long_t rx_dropped;
15561558
atomic_long_t tx_dropped;
15571559

1558-
atomic_t carrier_changes;
1559-
15601560
#ifdef CONFIG_WIRELESS_EXT
15611561
const struct iw_handler_def * wireless_handlers;
15621562
struct iw_public_data * wireless_data;
@@ -1596,17 +1596,15 @@ struct net_device {
15961596
unsigned short dev_id;
15971597
unsigned short dev_port;
15981598
spinlock_t addr_list_lock;
1599+
unsigned char name_assign_type;
1600+
bool uc_promisc;
15991601
struct netdev_hw_addr_list uc;
16001602
struct netdev_hw_addr_list mc;
16011603
struct netdev_hw_addr_list dev_addrs;
16021604

16031605
#ifdef CONFIG_SYSFS
16041606
struct kset *queues_kset;
16051607
#endif
1606-
1607-
unsigned char name_assign_type;
1608-
1609-
bool uc_promisc;
16101608
unsigned int promiscuity;
16111609
unsigned int allmulti;
16121610

@@ -1653,7 +1651,10 @@ struct net_device {
16531651

16541652
struct netdev_queue __rcu *ingress_queue;
16551653
unsigned char broadcast[MAX_ADDR_LEN];
1656-
1654+
#ifdef CONFIG_RFS_ACCEL
1655+
struct cpu_rmap *rx_cpu_rmap;
1656+
#endif
1657+
struct hlist_node index_hlist;
16571658

16581659
/*
16591660
* Cache lines mostly used on transmit path
@@ -1664,13 +1665,11 @@ struct net_device {
16641665
struct Qdisc *qdisc;
16651666
unsigned long tx_queue_len;
16661667
spinlock_t tx_global_lock;
1668+
int watchdog_timeo;
16671669

16681670
#ifdef CONFIG_XPS
16691671
struct xps_dev_maps __rcu *xps_maps;
16701672
#endif
1671-
#ifdef CONFIG_RFS_ACCEL
1672-
struct cpu_rmap *rx_cpu_rmap;
1673-
#endif
16741673

16751674
/* These may be needed for future network-power-down code. */
16761675

@@ -1680,13 +1679,11 @@ struct net_device {
16801679
*/
16811680
unsigned long trans_start;
16821681

1683-
int watchdog_timeo;
16841682
struct timer_list watchdog_timer;
16851683

16861684
int __percpu *pcpu_refcnt;
16871685
struct list_head todo_list;
16881686

1689-
struct hlist_node index_hlist;
16901687
struct list_head link_watch_list;
16911688

16921689
enum { NETREG_UNINITIALIZED=0,
@@ -1751,7 +1748,6 @@ struct net_device {
17511748
#endif
17521749
struct phy_device *phydev;
17531750
struct lock_class_key *qdisc_tx_busylock;
1754-
struct pm_qos_request pm_qos_req;
17551751
};
17561752
#define to_net_dev(d) container_of(d, struct net_device, dev)
17571753

0 commit comments

Comments
 (0)