atl1c: move tx cleanup processing out of interrupt
Subsystems (3)
PATCH v4 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 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. Also as the first in-driver user of dev_set_threaded API, need to add EXPORT_SYMBOL for it.
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.
---
changes since v3:
- made scripts/checkpatch.pl happy (commit message line wrap + missing comment on spinlock)
- moved the new intr_mask_lock to be besides the intr_mask it protects so they are more likely to be on same cacheline
changes since v2:
- addressed comments from Eric Dumazet
- added EXPORT_SYMBOL for dev_set_threaded
Sorry for reposting, noticed that scripts/checkpatch.pl was not happy.
--- drivers/net/ethernet/atheros/atl1c/atl1c.h | 2 + .../net/ethernet/atheros/atl1c/atl1c_main.c | 44 ++++++++++++++----- net/core/dev.c | 1 + 3 files changed, 37 insertions(+), 10 deletions(-)
drivers/net/ethernet/atheros/atl1c/atl1c.h +2 -0
@@ -367,6 +367,7 @@ struct atl1c_hw {u16 phy_id1;u16 phy_id2; +spinlock_t intr_mask_lock;/* protect the intr_mask */ u32 intr_mask;u8 preamble_len;
@@ -506,6 +507,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;
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +34 -10
113 lines not on this page · raw message
net/core/dev.c +1 -0
@@ -6789,6 +6789,7 @@ int dev_set_threaded(struct net_device *dev, bool threaded)return err; } +EXPORT_SYMBOL (dev_set_threaded);void netif_napi_add (struct net_device *dev,struct napi_struct *napi,int (*poll)(struct napi_struct *,int ),int weight)
Signature · 1 line
2.31.1
David Miller
maintainerFrom: Gatis Peisenieks <[email protected]>
Date: Tue, 06 Apr 2021 17:49:32 +0300
Quoted 34 lines
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 out-of-memory condition since__dev_kfree_skb_irqqueues 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. Also as the first
in-driver user ofdev_set_threadedAPI, need to addEXPORT_SYMBOLfor it.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.Signed-off-by Gatis Peisenieks <[email protected]>---
changes since v3:
- madescripts/checkpatch.plhappy (commit message line wrap + missing comment on spinlock)
- moved the newintr_mask_lockto be besides theintr_maskit protects so they are more likely to be on same cacheline
changes since v2:
- addressed comments from Eric Dumazet
- addedEXPORT_SYMBOLfordev_set_threaded
Quoted 1 line
Sorry for reposting, noticed that
scripts/checkpatch.plwas not happy.
This does not apply to 'net', did you mean 'net-next'? If so, please indicate this clearly in the Subject line as per convention.
Thank you.
Quoted 9 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 out-of-memory condition since
__dev_kfree_skb_irqqueues the skbs for later kfree in softirq which is not allowed to happen with heavy load in interrupt handler.
[ ... ]
net/core/dev.c int dev_set_threaded(struct net_device *dev, bool threaded) · line 6795
Quoted 12 lines
net/core/dev.c +1
-0@@ -6789,6 +6789,7 @@ int dev_set_threaded(struct net_device *dev, bool threaded) return err; } +EXPORT_SYMBOL (dev_set_threaded); void netif_napi_add(struct net_device *dev, struct napi_struct *napi, int (*poll)(struct napi_struct *, int), int weight)
This has already been done in net-next
Please base your patch on top of net-next, this can not be backported to old versions anyway, without some amount of pain.
Quoted 24 lines · Eric Dumazet
Quoted 9 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 out-of-memory condition since
__dev_kfree_skb_irqqueues the skbs for later kfree in softirq which is not allowed to happen with heavy load in interrupt handler.[ ... ]
Quoted 11 lines
net/core/dev.c +1
-0@@ -6789,6 +6789,7 @@ int dev_set_threaded(struct net_device *dev, bool threaded) return err; } +EXPORT_SYMBOL (dev_set_threaded);
Quoted 7 lines
Quoted 2 lines
net/core/dev.c +0
-0void netif_napi_add(struct net_device *dev, struct napi_struct *napi,int (*poll)(struct
napi_struct*, int), int weight)This has already been done in net-next
Please base your patch on top of net-next, this can not be backported to old versions anyway, without some amount of pain.
Thank you Eric, for heads up, the v5 patch sent for net-next in response to David Miller comment already does that.