Skip to contentSkip to conversation

fix napi return value

PATCH Applied Govindarajulu Varadarajan 3 participants 10 messages Jan 20, 2015 – Jan 25, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover fix napi return value

Since d75b1ade567ffab ("net: less interrupt masking in NAPI") we should return budget for napi repoll.

In enic, we return 0 when busy_poll is happening. Fix this by returning budget.

Looks like bnx2x needs this fix as well. On bnx2x I performed compile test only. I do not have hardware.

Govindarajulu Varadarajan (2):
enic: fix rx napi poll return value
bnx2x: fix napi poll return value for repoll

 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 4 ++--
 drivers/net/ethernet/cisco/enic/enic_main.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.2.2
#1 lore raw

PATCH 1/2 enic: fix rx napi poll return value

With the commit d75b1ade567ffab ("net: less interrupt masking in NAPI") napi repoll is done only when work_done == budget. When we are in busy_poll we return 0 in napi_poll. We should return budget.

---
 drivers/net/ethernet/cisco/enic/enic_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cisco/enic/enic_main.c +1 -1
index b29e027..e356afa 100644
@@ -1335,7 +1335,7 @@ static int enic_poll_msix_rq(struct napi_struct *napi, int budget)
 	int err;
 
 	if (!enic_poll_lock_napi(&enic->rq[rq]))
-		return work_done;
+		return budget;
 	/* Service RQ
 	 */
 
Signature · 1 line
2.2.2
maintainer Applied
#2 lore raw

Re: [PATCH net 1/2] enic: fix rx napi poll return value

From: Govindarajulu Varadarajan <[email protected]>
Date: Tue, 20 Jan 2015 18:46:15 +0530

Quoted 5 lines

With the commit d75b1ade567ffab ("net: less interrupt masking in NAPI") napi repoll is done only when work_done == budget. When we are in busy_poll we return 0 in napi_poll. We should return budget.

Applied.

#3 lore raw

PATCH 2/2 bnx2x: fix napi poll return value for repoll

In reply to Govindarajulu Varadarajan

With the commit d75b1ade567ffab ("net: less interrupt masking in NAPI") napi repoll is done only when work_done == budget. When in busy_poll is we return 0 in napi_poll. We should return budget. Also do not return workdone > budget.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +2 -2
index 1d1147c..ebcbe92 100644
@@ -3175,7 +3175,7 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
 		}
 #endif
 		if (!bnx2x_fp_lock_napi(fp))
-			return work_done;
+			return budget;
 
 		for_each_cos_in_tx_queue(fp, cos)
 			if (bnx2x_tx_queue_has_work(fp->txdata_ptr[cos]))
@@ -3187,7 +3187,7 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
 			/* must not complete if we consumed full budget */
 			if (work_done >= budget) {
 				bnx2x_fp_unlock_napi(fp);
-				break;
+				return budget;
 			}
 		}
 
Signature · 1 line
2.2.2
#4 lore raw

Re: [PATCH net 2/2] bnx2x: fix napi poll return value for repoll

Quoted 4 lines · Govindarajulu Varadarajan

With the commit d75b1ade567ffab ("net: less interrupt masking in NAPI") napi repoll is done only when work_done == budget. When in busy_poll is we return 0 in napi_poll. We should return budget. Also do not return workdone > budget.

I am not sure.

Quoted 10 lines
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +0 -0
index 1d1147c..ebcbe92 100644

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c static int bnx2x_poll(struct napi_struct *napi, int budget) · line 3178

Quoted 5 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -1
@@ -3175,7 +3175,7 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
 		}
 #endif
 		if (!bnx2x_fp_lock_napi(fp))
-			return work_done;
+			return budget;

For this one I am not sure.

Busy poll is not supposed to drain the whole queue.

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c static int bnx2x_poll(struct napi_struct *napi, int budget) · line 3190

Quoted 9 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -1
 		for_each_cos_in_tx_queue(fp, cos)
 			if (bnx2x_tx_queue_has_work(fp->txdata_ptr[cos]))
@@ -3187,7 +3187,7 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
 			/* must not complete if we consumed full budget */
 			if (work_done >= budget) {
 				bnx2x_fp_unlock_napi(fp);
-				break;
+				return budget;

This one looks fine.

Quoted 3 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +0 -0
 			}
 		}
 
#5 lore raw

Re: [PATCH net 2/2] bnx2x: fix napi poll return value for repoll

Quoted 11 lines · Eric Dumazet

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c static int bnx2x_poll(struct napi_struct *napi, int budget) · line 3190

Quoted 9 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -1
 		for_each_cos_in_tx_queue(fp, cos)
 			if (bnx2x_tx_queue_has_work(fp->txdata_ptr[cos]))
@@ -3187,7 +3187,7 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
 			/* must not complete if we consumed full budget */
 			if (work_done >= budget) {
 				bnx2x_fp_unlock_napi(fp);
-				break;
+				return budget;

This one looks fine.

But its not necessary, as here budget == work_done.

(work_done > budget) would be a bug from bnx2x_rx_int()

#6 lore raw

Re: [PATCH net 2/2] bnx2x: fix napi poll return value for repoll

Quoted 14 lines · Eric Dumazet
Quoted 11 lines · Eric Dumazet

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c static int bnx2x_poll(struct napi_struct *napi, int budget) · line 3190

Quoted 9 lines
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -1
 		for_each_cos_in_tx_queue(fp, cos)
 			if (bnx2x_tx_queue_has_work(fp->txdata_ptr[cos]))
@@ -3187,7 +3187,7 @@ static int bnx2x_poll(struct napi_struct *napi, int budget)
 			/* must not complete if we consumed full budget */
 			if (work_done >= budget) {
 				bnx2x_fp_unlock_napi(fp);
-				break;
+				return budget;

This one looks fine.

Quoted 4 lines

But its not necessary, as here budget == work_done.

(work_done > budget) would be a bug from bnx2x_rx_int()

Yes, I missed that one. This change here is not needed.

Thanks

#7 lore raw

Re: [PATCH net 2/2] bnx2x: fix napi poll return value for repoll

In reply to Eric Dumazet
Quoted 8 lines · Eric Dumazet
Quoted 4 lines · Govindarajulu Varadarajan

With the commit d75b1ade567ffab ("net: less interrupt masking in NAPI") napi repoll is done only when work_done == budget. When in busy_poll is we return 0 in napi_poll. We should return budget. Also do not return workdone > budget.

I am not sure.

This is based on f41281d02f8b94e136f78cb1b6a5d78182c222bd & 9dfa9a27b620640322588df399eb8f624b48d877

I do not know about bnx2x, but in enic driver, when busy_poll is enables rq clean is not happening. This is because, in napi_poll() when work_done < budget, we do not repoll. At this point, enic has disables rq intr and has not called napi_complete. Driver assumes that napi will repoll. Which does not happen.

Lot of drivers I have checked return full budget if they want to repoll. eg. mlx4_en_poll_rx_cq()

#8 lore raw

Re: [PATCH net 2/2] bnx2x: fix napi poll return value for repoll

Quoted 14 lines · Govindarajulu Varadarajan
Quoted 8 lines · Eric Dumazet
Quoted 4 lines · Govindarajulu Varadarajan

With the commit d75b1ade567ffab ("net: less interrupt masking in NAPI") napi repoll is done only when work_done == budget. When in busy_poll is we return 0 in napi_poll. We should return budget. Also do not return workdone > budget.

I am not sure.

This is based on f41281d02f8b94e136f78cb1b6a5d78182c222bd & 9dfa9a27b620640322588df399eb8f624b48d877

Quoted 8 lines

I do not know about bnx2x, but in enic driver, when busy_poll is enables rq clean is not happening. This is because, in napi_poll() when work_done < budget, we do not repoll. At this point, enic has disables rq intr and has not called napi_complete. Driver assumes that napi will repoll. Which does not happen.

Lot of drivers I have checked return full budget if they want to repoll. eg. mlx4_en_poll_rx_cq()

I was referring to the "workdone > budget" condition.

But yes, the fix about busy poll seems needed.

maintainer
#9 lore raw

Re: [PATCH net 2/2] bnx2x: fix napi poll return value for repoll

In reply to Govindarajulu Varadarajan

From: Govindarajulu Varadarajan <[email protected]>
Date: Tue, 20 Jan 2015 18:46:16 +0530

Quoted 5 lines

With the commit d75b1ade567ffab ("net: less interrupt masking in NAPI") napi repoll is done only when work_done == budget. When in busy_poll is we return 0 in napi_poll. We should return budget. Also do not return workdone > budget.

This seems like it needs some adjustments, please make those corrections and respin this patch.

Thanks.