net: stmmac: Performance improvements in Multi-Queue
Subsystems (4)
cover net: stmmac: Performance improvements in Multi-Queue
Tested in XGMAC2 and GMAC5. I guess 1/3 can be backported but besides being a kind of "not that small" refactoring it's also for a scenario that no-one complained yet ... Advice ?
Jose Abreu (3):
net: stmmac: Fix NAPI poll in TX path when in multi-queue
net: stmmac: dwmac4: Also use TBU interrupt to clean TX path
net: stmmac: dwxgmac2: Also use TBU interrupt to clean TX path
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 24 ++--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 4 +- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 8 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 5 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 112 ++++++++++++--------- 5 files changed, 77 insertions(+), 76 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 net: stmmac: Fix NAPI poll in TX path when in multi-queue
Commit 8fce33317023 introduced the concept of NAPI per-channel and independent cleaning of TX path.
This is currently breaking performance in some cases. The scenario happens when all packets are being received in Queue 0 but the TX is performed in Queue != 0.
Fix this by using different NAPI instances per each TX and RX queue, as suggested by Florian.
--- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 5 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 112 ++++++++++++---------- 2 files changed, 64 insertions(+), 53 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +2 -3
@@ -78,11 +78,10 @@ struct stmmac_rx_queue { };struct stmmac_channel { -struct napi_struct napi____cacheline_aligned_in_smp ; +struct napi_struct rx_napi____cacheline_aligned_in_smp ; +struct napi_struct tx_napi____cacheline_aligned_in_smp ;struct stmmac_priv *priv_data;u32 index; -int has_rx; -int has_tx; };struct stmmac_tc_entry {
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +62 -50
181 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH net-next 1/3] net: stmmac: Fix NAPI poll in TX path when in multi-queue
Quoted 17 lines · Jose Abreu
Commit
8fce33317023introduced the concept of NAPI per-channel and independent cleaning of TX path.This is currently breaking performance in some cases. The scenario happens when all packets are being received in Queue 0 but the TX is performed in Queue != 0.
Fix this by using different NAPI instances per each TX and RX queue, as suggested by Florian.
Signed-off-by Jose Abreu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Joao Pinto <[email protected]>Cc David S. Miller <[email protected]>Cc Giuseppe Cavallaro <[email protected]>Cc Alexandre Torgue <[email protected]>---
[snip]
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) · line 3552
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3
-2-if (work_done < budget &&napi_complete_done (napi, work_done)) { -int stat; + priv->xstats.napi_poll++; + work_done =stmmac_tx_clean (priv, budget, chan); +if (work_done < budget &&napi_complete_done (napi, work_done))
You should not be bounding your TX queue against the NAPI budge, it should run unbound and clean as much as it can, which could be the entire ring size if that is how many packets you pushed between interrupts. That could be the cause of poor performance as well.
Signature · 1 line
Florian
Re: [PATCH net-next 1/3] net: stmmac: Fix NAPI poll in TX path when in multi-queue
Quoted 25 lines · Florian Fainelli
Quoted 17 lines · Jose Abreu
Commit
8fce33317023introduced the concept of NAPI per-channel and independent cleaning of TX path.This is currently breaking performance in some cases. The scenario happens when all packets are being received in Queue 0 but the TX is performed in Queue != 0.
Fix this by using different NAPI instances per each TX and RX queue, as suggested by Florian.
Signed-off-by Jose Abreu <[email protected]>Cc Florian Fainelli <[email protected]>Cc Joao Pinto <[email protected]>Cc David S. Miller <[email protected]>Cc Giuseppe Cavallaro <[email protected]>Cc Alexandre Torgue <[email protected]>---
[snip]
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-2-if (work_done < budget &&napi_complete_done (napi, work_done)) { -int stat; + priv->xstats.napi_poll++;
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) · line 3552
Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-0+ work_done =stmmac_tx_clean (priv, budget, chan); +if (work_done < budget &&napi_complete_done (napi, work_done))You should not be bounding your TX queue against the NAPI budge, it should run unbound and clean as much as it can, which could be the entire ring size if that is how many packets you pushed between interrupts. That could be the cause of poor performance as well.
Won't returning the budget value cause this napi_poll routine to be called again, where the driver can continue to clean TX packets? I thought this just gives other drivers the opportunity to run their napi_poll routines in between so as not to be starved.
Thanks,
Tom
Quoted 1 line
PATCH 2/3 net: stmmac: dwmac4: Also use TBU interrupt to clean TX path
In reply to Jose AbreuTBU interrupt is a normal interrupt and can be used to trigger the cleaning of TX path. Lets check if it's active in DMA interrupt handler.
While at it, refactor a little bit the function:
- Don't check if RI is enabled because at function exit we will only clear the interrupts that are enabled so, no event will be missed.
In my tests with GMAC5 this increased performance.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +7 -17
@@ -124,9 +124,9 @@ void dwmac4_disable_dma_irq(void __iomem *ioaddr, u32 chan)int dwmac4_dma_interrupt (void __iomem *ioaddr,struct stmmac_extra_stats *x,u32 chan) { -int ret =0 ; -u32 intr_status =readl (ioaddr +DMA_CHAN_STATUS (chan)); +u32 intr_en =readl (ioaddr +DMA_CHAN_INTR_ENA (chan)); +int ret =0 ;/* ABNORMAL interrupts */ if (unlikely (intr_status &DMA_CHAN_STATUS_AIS )) {
@@ -151,16 +151,11 @@ int dwmac4_dma_interrupt(void __iomem *ioaddr,if (likely (intr_status &DMA_CHAN_STATUS_NIS )) { x->normal_irq_n++;if (likely (intr_status &DMA_CHAN_STATUS_RI )) { -u32 value; - - value =readl (ioaddr +DMA_CHAN_INTR_ENA (chan)); -/* to schedule NAPI on real RIE event. */ -if (likely (value &DMA_CHAN_INTR_ENA_RIE )) { - x->rx_normal_irq_n++; - ret |= handle_rx; - } + x->rx_normal_irq_n++; + ret |= handle_rx; } -if (likely (intr_status &DMA_CHAN_STATUS_TI )) { +if (likely (intr_status & (DMA_CHAN_STATUS_TI | +DMA_CHAN_STATUS_TBU ))) { x->tx_normal_irq_n++; ret |= handle_tx; }
@@ -168,12 +163,7 @@ int dwmac4_dma_interrupt(void __iomem *ioaddr, x->rx_early_irq++; } -/* Clear the interrupt by writing a logic 1 to the chanX interrupt -* status [21-0] expect reserved bits [5-3] -*/ -writel ((intr_status &0x3fffc7 ), - ioaddr +DMA_CHAN_STATUS (chan)); - +writel (intr_status & intr_en, ioaddr +DMA_CHAN_STATUS (chan));return ret; }
Signature · 1 line
2.7.4
PATCH 3/3 net: stmmac: dwxgmac2: Also use TBU interrupt to clean TX path
In reply to Jose AbreuTBU interrupt is a normal interrupt and can be used to trigger the cleaning of TX path. Lets check if it's active in DMA interrupt handler.
While at it, refactor a little bit the function:
- Don't check if RI is enabled because at function exit we will only clear the interrupts that are enabled so, no event will be missed.
In my tests withe XGMAC2 this increased performance.
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 4 +++- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +3 -1
@@ -193,9 +193,10 @@#define XGMAC_AIE BIT(14)#define XGMAC_RBUE BIT(7)#define XGMAC_RIE BIT(6) +#define XGMAC_TBUE BIT(2)#define XGMAC_TIE BIT(0)#define XGMAC_DMA_INT_DEFAULT_EN (XGMAC_NIE | XGMAC_AIE | XGMAC_RBUE | \ - XGMAC_RIE | XGMAC_TIE) + XGMAC_RIE | XGMAC_TBUE | XGMAC_TIE)#define XGMAC_DMA_CH_Rx_WATCHDOG (x) (0x0000313c + (0x80 * (x)))#define XGMAC_RWT GENMASK(7, 0)#define XGMAC_DMA_CH_STATUS (x) (0x00003160 + (0x80 * (x)))
@@ -204,6 +205,7 @@#define XGMAC_FBE BIT(12)#define XGMAC_RBU BIT(7)#define XGMAC_RI BIT(6) +#define XGMAC_TBU BIT(2)#define XGMAC_TPS BIT(1)#define XGMAC_TI BIT(0)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +3 -5
@@ -283,12 +283,10 @@ static int dwxgmac2_dma_interrupt(void __iomem *ioaddr, x->normal_irq_n++;if (likely (intr_status &XGMAC_RI )) { -if (likely (intr_en &XGMAC_RIE )) { - x->rx_normal_irq_n++; - ret |= handle_rx; - } + x->rx_normal_irq_n++; + ret |= handle_rx; } -if (likely (intr_status &XGMAC_TI )) { +if (likely (intr_status & (XGMAC_TI |XGMAC_TBU ))) { x->tx_normal_irq_n++; ret |= handle_tx; }
Signature · 1 line
2.7.4