enic: add wq clean up budget
Subsystems (3)
PATCH 1/1 enic: add wq clean up budget
In case of tx clean up, we set '-1' as budget. This means clean up until wq is empty or till (1 << 32) pkts are cleaned. Under heavy load this will run for long time and cause
"watchdog: BUG: soft lockup - CPU#25 stuck for 21s!" warning.
This patch sets wq clean up budget to 256.
--- drivers/net/ethernet/cisco/enic/enic.h | 2 ++ drivers/net/ethernet/cisco/enic/enic_main.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +2 -0
@@ -43,6 +43,8 @@#define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX)#define ENIC_INTR_MAX (ENIC_CQ_MAX + 2) +#define ENIC_WQ_NAPI_BUDGET 256 +#define ENIC_AIC_LARGE_PKT_DIFF 3struct enic_msix_entry {
drivers/net/ethernet/cisco/enic/enic_main.c +2 -2
@@ -1500,7 +1500,7 @@ static int enic_poll(struct napi_struct *napi, int budget)unsigned int cq_wq =enic_cq_wq (enic,0 );unsigned int intr =enic_legacy_io_intr ();unsigned int rq_work_to_do = budget; -unsigned int wq_work_to_do =-1 ;/* no limit */ +unsigned int wq_work_to_do =ENIC_WQ_NAPI_BUDGET ;unsigned int work_done, rq_work_done =0 , wq_work_done;int err;
@@ -1598,7 +1598,7 @@ static int enic_poll_msix_wq(struct napi_struct *napi, int budget)struct vnic_wq *wq = &enic->wq[wq_index];unsigned int cq;unsigned int intr; -unsigned int wq_work_to_do =-1 ;/* clean all desc possible */ +unsigned int wq_work_to_do =ENIC_WQ_NAPI_BUDGET ;unsigned int wq_work_done;unsigned int wq_irq;
Signature · 1 line
2.15.1
David Miller
maintainerFrom: Govindarajulu Varadarajan <[email protected]>
Date: Tue, 5 Dec 2017 11:14:41 -0800
Quoted 8 lines
In case of tx clean up, we set '-1' as budget. This means clean up until wq is empty or till (1 << 32) pkts are cleaned. Under heavy load this will run for long time and cause
"watchdog: BUG: soft lockup - CPU#25 stuck for 21s!" warning.This patch sets wq clean up budget to 256.
Signed-off-by Govindarajulu Varadarajan <[email protected]>
This driver with all of it's indirection and layers upon layers of macros for queue processing is so difficult to read, and this can't be generating nice optimal code either...
Anyways, I was walking over the driver to see if the logic is contributing to this.
The limit you are proposing sounds unnecessary, nobody else I can see needs this, and that includes all of the most heavily used drivers under load.
If I had to guess I'd say that the problem is that the queue loop keeps sampling the head and tail pointers, where as it should just do that _once_ and only process that TX entries found in that snapshot and return to the poll() routine immedately afterwards.
Thanks.
Quoted 16 lines · David Miller
From: Govindarajulu Varadarajan <[email protected]>
Date: Tue, 5 Dec 2017 11:14:41 -0800Quoted 8 lines
In case of tx clean up, we set '-1' as budget. This means clean up until wq is empty or till (1 << 32) pkts are cleaned. Under heavy load this will run for long time and cause
"watchdog: BUG: soft lockup - CPU#25 stuck for 21s!" warning.This patch sets wq clean up budget to 256.
Signed-off-by Govindarajulu Varadarajan <[email protected]>This driver with all of it's indirection and layers upon layers of macros for queue processing is so difficult to read, and this can't be generating nice optimal code either...
Quoted 6 lines
Anyways, I was walking over the driver to see if the logic is contributing to this.
The limit you are proposing sounds unnecessary, nobody else I can see needs this, and that includes all of the most heavily used drivers under load.
I used 256 as the limit because most of the other drivers use it.
* mlx4 uses MLX4_EN_DEFAULT_TX_WORK as the tx budget in mlx4_en_process_tx_cq() Added in commit fbc6daf19745 ("net/mlx4_en: Ignore budget on TX napi polling")
* i40e&vf uses vsi->work_limit as tx budget in i40e_clean_tx_irq(), which is set to I40E_DEFAULT_IRQ_WORK. Added in commit
a619afe814453 ("i40e/i40evf: Add support for bulk free in Tx cleanup")
* ixgbe uses q_vector->tx.work_limit as tx budget in ixgbe_clean_tx_irq(), which is set to IXGBE_DEFAULT_TX_WORK. Added in commit 592245559e900 ("ixgbe: Change default Tx work limit size to 256 buffers")
Quoted 5 lines
If I had to guess I'd say that the problem is that the queue loop keeps sampling the head and tail pointers, where as it should just do that _once_ and only process that TX entries found in that snapshot and return to the
poll()routine immedately afterwards.
The only way to know the tail pointer at the time napi is scheduled is to read hw fetch_index register. This is discouraged by hw engineers.
We work around this by using color bit. Every cq entry has color bit. It is either 0 or 1. Hw flips the bit when it creates a new cq entry. So every new cq entry will have a different color bit than previous. We reach end of the queue when previous color bit is same as current cq entry's color. i.e hw did not flip the bit, so its not a new cq entry.
So enic driver cannot know the tail pointer at the time napi is scheduled, until we reach the tail pointer.
Quoted 48 lines · Govindarajulu Varadarajan
Quoted 16 lines · David Miller
From: Govindarajulu Varadarajan <[email protected]>
Date: Tue, 5 Dec 2017 11:14:41 -0800Quoted 8 lines
In case of tx clean up, we set '-1' as budget. This means clean up until wq is empty or till (1 << 32) pkts are cleaned. Under heavy load this will run for long time and cause
"watchdog: BUG: soft lockup - CPU#25 stuck for 21s!" warning.This patch sets wq clean up budget to 256.
Signed-off-by Govindarajulu Varadarajan <[email protected]>This driver with all of it's indirection and layers upon layers of macros for queue processing is so difficult to read, and this can't be generating nice optimal code either...
Quoted 6 lines
Anyways, I was walking over the driver to see if the logic is contributing to this.
The limit you are proposing sounds unnecessary, nobody else I can see needs this, and that includes all of the most heavily used drivers under load.
I used 256 as the limit because most of the other drivers use it.
* mlx4 uses
MLX4_EN_DEFAULT_TX_WORKas the tx budget inmlx4_en_process_tx_cq()Added in commitfbc6daf19745("net/mlx4_en: Ignore budget on TX napi
polling")* i40e&vf uses
vsi->work_limitas tx budget ini40e_clean_tx_irq(), which is set toI40E_DEFAULT_IRQ_WORK. Added in commit
a619afe814453("i40e/i40evf: Add support for bulk free in Tx cleanup")* ixgbe uses
q_vector->tx.work_limitas tx budget inixgbe_clean_tx_irq(), which is set toIXGBE_DEFAULT_TX_WORK. Added in commit592245559e900("ixgbe: Change default Tx work limit size to 256 buffers")Quoted 5 lines
If I had to guess I'd say that the problem is that the queue loop keeps sampling the head and tail pointers, where as it should just do that _once_ and only process that TX entries found in that snapshot and return to the
poll()routine immedately afterwards.The only way to know the tail pointer at the time napi is scheduled is to read hw
fetch_indexregister. This is discouraged by hw engineers.
Quoted 9 lines
We work around this by using color bit. Every cq entry has color bit. It is either 0 or 1. Hw flips the bit when it creates a new cq entry. So every new cq entry will have a different color bit than previous. We reach end of the queue when previous color bit is same as current cq entry's color. i.e hw did not flip the bit, so its not a new cq entry.
So enic driver cannot know the tail pointer at the time napi is scheduled, until we reach the tail pointer.
David,
How would you want us to fix this issue? Is doing an ioread on fetch_index for every poll our only option? (to get head and tail point once)
If 256 is not reasonable, will wq_budget equal to wq ring size be acceptable? At any point number of wq entries to be cleaned cannot be more than ring size.
Thanks
Govind
David Miller
maintainerFrom: Govindarajulu Varadarajan <[email protected]>
Date: Tue, 19 Dec 2017 16:37:14 -0800
Quoted 8 lines
How would you want us to fix this issue? Is doing an ioread on
fetch_indexfor every poll our only option? (to get head and tail point once)If 256 is not reasonable, will
wq_budgetequal to wq ring size be acceptable?
At any point number of wq entries to be cleaned cannot be more than ring size.
You can resubmit your orignal patch to increase things to 256 but realize that I still consider this driver terrible at layering, indirection, and how it does reclaim.