Skip to contentSkip to conversation

atl1c: move tx cleanup processing out of interrupt

PATCH Superseded Gatis Peisenieks 2 participants 3 messages Apr 2, 2021

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 atl1c: move tx cleanup processing out of interrupt

Tx queue cleanup happens in interrupt handler on same core as rx queue processing. Both can take considerable amount of processing in high packet-per-second scenarios.

Sending big amounts of packets can stall the rx processing which is unfair and also can lead to to out-of-memory condition since __dev_kfree_skb_irq queues the skbs for later kfree in softirq which is not allowed to happen with heavy load in interrupt handler.

This puts tx cleanup in its own napi and enables threaded napi to allow the rx/tx queue processing to happen on different cores.

The ability to sustain equal amounts of tx/rx traffic increased:
from 280Kpps to 1130Kpps on Threadripper 3960X with upcoming Mikrotik 10/25G NIC, from 520Kpps to 850Kpps on Intel i3-3320 with Mikrotik RB44Ge adapter.

---
 drivers/net/ethernet/atheros/atl1c/atl1c.h    |  2 +
 .../net/ethernet/atheros/atl1c/atl1c_main.c   | 43 +++++++++++++++++--
 2 files changed, 41 insertions(+), 4 deletions(-)
drivers/net/ethernet/atheros/atl1c/atl1c.h +2 -0
index a0562a90fb6d..4404fa44d719 100644
@@ -506,6 +506,7 @@ struct atl1c_adapter {
 	struct net_device   *netdev;
 	struct pci_dev      *pdev;
 	struct napi_struct  napi;
+	struct napi_struct  tx_napi;
 	struct page         *rx_page;
 	unsigned int	    rx_page_offset;
 	unsigned int	    rx_frag_size;
@@ -529,6 +530,7 @@ struct atl1c_adapter {
 	u16 link_duplex;
 
 	spinlock_t mdio_lock;
+	spinlock_t irq_mask_lock;
 	atomic_t irq_sem;
 
 	struct work_struct common_task;
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +39 -4

110 lines not on this page · raw message

Signature · 7 lines
2.28.0
---

Resending the patch with threaded napi which does the trick as suggested by Eric Dumazet.

Regards,
Gatis
#1 lore raw
Quoted 54 lines · Gatis Peisenieks

Tx queue cleanup happens in interrupt handler on same core as rx queue processing. Both can take considerable amount of processing in high packet-per-second scenarios.

Sending big amounts of packets can stall the rx processing which is unfair and also can lead to to out-of-memory condition since __dev_kfree_skb_irq queues the skbs for later kfree in softirq which is not allowed to happen with heavy load in interrupt handler.

This puts tx cleanup in its own napi and enables threaded napi to allow the rx/tx queue processing to happen on different cores.

The ability to sustain equal amounts of tx/rx traffic increased:
from 280Kpps to 1130Kpps on Threadripper 3960X with upcoming Mikrotik 10/25G NIC, from 520Kpps to 850Kpps on Intel i3-3320 with Mikrotik RB44Ge adapter.

---
 drivers/net/ethernet/atheros/atl1c/atl1c.h    |  2 + .../net/ethernet/atheros/atl1c/atl1c_main.c   | 43 +++++++++++++++++--

 2 files changed, 41 insertions(+), 4 deletions(-)
drivers/net/ethernet/atheros/atl1c/atl1c.h +2 -0
index a0562a90fb6d..4404fa44d719 100644
@@ -506,6 +506,7 @@ struct atl1c_adapter {
      struct net_device   *netdev;
      struct pci_dev      *pdev;
      struct napi_struct  napi;
+    struct napi_struct  tx_napi;
      struct page         *rx_page;
      unsigned int        rx_page_offset;
      unsigned int        rx_frag_size;
@@ -529,6 +530,7 @@ struct atl1c_adapter {
      u16 link_duplex;
 
      spinlock_t mdio_lock;
+    spinlock_t irq_mask_lock;
      atomic_t irq_sem;
 
      struct work_struct common_task;
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +1 -0
index 3f65f2b370c5..f51b28e8b6dc 100644
@@ -813,6 +813,7 @@ static int atl1c_sw_init(struct atl1c_adapter *adapter)
      atl1c_set_rxbufsize(adapter, adapter->netdev);
      atomic_set(&adapter->irq_sem, 1);
      spin_lock_init(&adapter->mdio_lock);
+    spin_lock_init(&adapter->irq_mask_lock);
      set_bit(__AT_DOWN, &adapter->flags);
 
      return 0;

drivers/net/ethernet/atheros/atl1c/atl1c_main.c static inline void atl1c_clear_phy_int(struct atl1c_adapter *adapter) · line 1535

Quoted 6 lines
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +1 -1
@@ -1530,7 +1531,7 @@ static inline void atl1c_clear_phy_int(struct atl1c_adapter *adapter)
      spin_unlock(&adapter->mdio_lock);
  }
 
-static bool atl1c_clean_tx_irq(struct atl1c_adapter *adapter,
+static unsigned atl1c_clean_tx_irq(struct atl1c_adapter *adapter,
                  enum atl1c_trans_queue type)

This v2 is much better, thanks.

You might rename this atl1c_clean_tx_irq(), because it is now not run under hard irqs ?

Maybe merge atl1c_clean_tx_irq() and atl1c_clean_tx() into a single function ?

#2 lore raw
In reply to Gatis Peisenieks
Quoted 3 lines · Gatis Peisenieks

Tx queue cleanup happens in interrupt handler on same core as rx queue processing. Both can take considerable amount of processing in high packet-per-second scenarios.

...

Quoted 5 lines
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +0 -0
@@ -2504,6 +2537,7 @@ static int atl1c_init_netdev(struct net_device *netdev, struct pci_dev *pdev)
                  NETIF_F_TSO6;

     netdev->features =    netdev->hw_features    | NETIF_F_HW_VLAN_CTAG_TX;
+    netdev->threaded = true;

Shouldn't it use dev_set_threaded() ?

Quoted 11 lines

     return 0;
 }

drivers/net/ethernet/atheros/atl1c/atl1c_main.c +1 -0
@@ -2588,6 +2622,7 @@ static int atl1c_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
      adapter->mii.phy_id_mask = 0x1f;
      adapter->mii.reg_num_mask = MDIO_CTRL_REG_MASK;
      netif_napi_add(netdev, &adapter->napi, atl1c_clean, 64);
+    netif_napi_add(netdev, &adapter->tx_napi, atl1c_clean_tx, 64);
      timer_setup(&adapter->phy_config_timer, atl1c_phy_config, 0);
      /* setup the private structure */
      err = atl1c_sw_init(adapter);