ixgbe: xsk: resolve the negative overflow of budget in ixgbe_xmit_zc
Subsystems (3)
PATCH v2 1/1 ixgbe: xsk: resolve the negative overflow of budget in ixgbe_xmit_zc
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in ixgbe_xmit_zc even when the budget of descs are thoroughly consumed.
Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in ixgbe_xmit_zc, it will always turn back and enter into the while() statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely, UINT_MAX. Finally, the ixgbe_xmit_zc returns true, showing 'we complete cleaning the budget'. That also means 'clean_complete = true' in ixgbe_poll.
The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in ixgbe_xmit_zc to tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.
It is apparently against our expectations. Please also see how ixgbe_clean_tx_irq() handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.
The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
---
1. use 'negative overflow' instead of 'underflow' (Willem)
2. add reviewed-by tag (Larysa)
3. target iwl-net branch (Larysa)
4. add the reason why the patch adds likely() (Larysa)
--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +3 -1
@@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)dma_addr_t dma;u32 cmd_type; -while (budget-- >0 ) { +while (likely (budget)) {if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;break ;
@@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) xdp_ring->next_to_use++;if (xdp_ring->next_to_use == xdp_ring->count) xdp_ring->next_to_use =0 ; + + budget--; }if (tx_desc) {
Signature · 1 line
2.41.3
Dear Jason,
Thank you for the improved version.
Am 26.07.25 um 09:03 schrieb Jason Xing:
Quoted 55 lines
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>---
1. use 'negative overflow' instead of 'underflow' (Willem)
2. add reviewed-by tag (Larysa)
3. target iwl-net branch (Larysa)
4. add the reason why the patch addslikely()(Larysa)--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +1
-1@@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)dma_addr_t dma;u32 cmd_type; -while (budget-- >0 ) { +while (likely (budget)) {if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;break ;
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) · line 440
Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +2
-0@@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) xdp_ring->next_to_use++;if (xdp_ring->next_to_use == xdp_ring->count) xdp_ring->next_to_use =0 ; + + budget--; }if (tx_desc) {
Is this just the smallest fix, and the rewrite to the more idiomatic for loop going to be done in a follow-up?
Kind regards,
Paul
Hi Paul,
Quoted 69 lines · Paul Menzel
Dear Jason,
Thank you for the improved version.
Am 26.07.25 um 09:03 schrieb Jason Xing:
Quoted 62 lines
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>---
1. use 'negative overflow' instead of 'underflow' (Willem)
2. add reviewed-by tag (Larysa)
3. target iwl-net branch (Larysa)
4. add the reason why the patch addslikely()(Larysa)--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +3
-1@@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)dma_addr_t dma;u32 cmd_type; -while (budget-- >0 ) { +while (likely (budget)) {if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;break ;@@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) xdp_ring->next_to_use++;if (xdp_ring->next_to_use == xdp_ring->count) xdp_ring->next_to_use =0 ; + + budget--; }
Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) · line 440
Quoted 1 line
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +0
-0if (tx_desc) {Reviewed-by Paul Menzel <[email protected]>Is this just the smallest fix, and the rewrite to the more idiomatic for loop going to be done in a follow-up?
Thanks for the review. But I'm not that sure if it's worth a follow-up patch. Or if anyone else also expects to see a 'for loop' version, I can send a V3 patch then. I have no strong opinion either way.
Thanks,
Jason
Simon Horman
reviewerQuoted 76 lines · Jason Xing
Hi Paul,
Quoted 73 lines · Paul Menzel
Dear Jason,
Thank you for the improved version.
Am 26.07.25 um 09:03 schrieb Jason Xing:
Quoted 55 lines
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>---
1. use 'negative overflow' instead of 'underflow' (Willem)
2. add reviewed-by tag (Larysa)
3. target iwl-net branch (Larysa)
4. add the reason why the patch addslikely()(Larysa)--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +1
-1@@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)dma_addr_t dma;u32 cmd_type; -while (budget-- >0 ) { +while (likely (budget)) {if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;break ;drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) · line 440
Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +2
-0@@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) xdp_ring->next_to_use++;if (xdp_ring->next_to_use == xdp_ring->count) xdp_ring->next_to_use =0 ; + + budget--; }if (tx_desc) {Reviewed-by Paul Menzel <[email protected]>
Quoted 6 lines
Quoted 2 lines
Is this just the smallest fix, and the rewrite to the more idiomatic for loop going to be done in a follow-up?
Thanks for the review. But I'm not that sure if it's worth a follow-up patch. Or if anyone else also expects to see a 'for loop' version, I can send a V3 patch then. I have no strong opinion either way.
I think we have iterated over this enough (pun intended). If this patch is correct then lets stick with this approach.
Hi Simon,
Quoted 78 lines · Simon Horman
Quoted 76 lines · Jason Xing
Hi Paul,
Quoted 73 lines · Paul Menzel
Dear Jason,
Thank you for the improved version.
Am 26.07.25 um 09:03 schrieb Jason Xing:
Quoted 55 lines
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>---
1. use 'negative overflow' instead of 'underflow' (Willem)
2. add reviewed-by tag (Larysa)
3. target iwl-net branch (Larysa)
4. add the reason why the patch addslikely()(Larysa)--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +1
-1@@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)dma_addr_t dma;u32 cmd_type; -while (budget-- >0 ) { +while (likely (budget)) {if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;break ;drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) · line 440
Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +2
-0@@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) xdp_ring->next_to_use++;if (xdp_ring->next_to_use == xdp_ring->count) xdp_ring->next_to_use =0 ; + + budget--; }if (tx_desc) {Reviewed-by Paul Menzel <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Is this just the smallest fix, and the rewrite to the more idiomatic for loop going to be done in a follow-up?
Thanks for the review. But I'm not that sure if it's worth a follow-up patch. Or if anyone else also expects to see a 'for loop' version, I can send a V3 patch then. I have no strong opinion either way.
I think we have iterated over this enough (pun intended).
Hhh, interesting.
Quoted 1 line
If this patch is correct then lets stick with this approach.
No problem. Tomorrow I will send the 'for loop' version :)
Thanks,
Jason
Simon Horman
reviewerQuoted 88 lines · Jason Xing
Hi Simon,
Quoted 85 lines · Simon Horman
Quoted 82 lines · Jason Xing
Hi Paul,
Quoted 69 lines · Paul Menzel
Dear Jason,
Thank you for the improved version.
Am 26.07.25 um 09:03 schrieb Jason Xing:
Quoted 62 lines
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>---
1. use 'negative overflow' instead of 'underflow' (Willem)
2. add reviewed-by tag (Larysa)
3. target iwl-net branch (Larysa)
4. add the reason why the patch addslikely()(Larysa)--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +3
-1@@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)dma_addr_t dma;u32 cmd_type; -while (budget-- >0 ) { +while (likely (budget)) {if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;break ;@@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) xdp_ring->next_to_use++;if (xdp_ring->next_to_use == xdp_ring->count) xdp_ring->next_to_use =0 ; + + budget--; }Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) · line 440
Quoted 1 line
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +0
-0if (tx_desc) {Reviewed-by Paul Menzel <[email protected]>Is this just the smallest fix, and the rewrite to the more idiomatic for loop going to be done in a follow-up?
Thanks for the review. But I'm not that sure if it's worth a follow-up patch. Or if anyone else also expects to see a 'for loop' version, I can send a V3 patch then. I have no strong opinion either way.
Quoted 7 lines
Quoted 1 line
I think we have iterated over this enough (pun intended).
Hhh, interesting.
Quoted 1 line
If this patch is correct then lets stick with this approach.
No problem. Tomorrow I will send the 'for loop' version :)
I meant, I think the while loop is fine.
But anything that is correct is fine by me :)
Quoted 92 lines · Simon Horman
Quoted 90 lines · Jason Xing
Hi Simon,
Quoted 86 lines · Simon Horman
Quoted 76 lines · Jason Xing
Hi Paul,
Quoted 73 lines · Paul Menzel
Dear Jason,
Thank you for the improved version.
Am 26.07.25 um 09:03 schrieb Jason Xing:
Quoted 55 lines
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>---
1. use 'negative overflow' instead of 'underflow' (Willem)
2. add reviewed-by tag (Larysa)
3. target iwl-net branch (Larysa)
4. add the reason why the patch addslikely()(Larysa)--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +1
-1@@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)dma_addr_t dma;u32 cmd_type; -while (budget-- >0 ) { +while (likely (budget)) {if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;break ;drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) · line 440
Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +2
-0@@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) xdp_ring->next_to_use++;if (xdp_ring->next_to_use == xdp_ring->count) xdp_ring->next_to_use =0 ; + + budget--; }if (tx_desc) {Reviewed-by Paul Menzel <[email protected]>Quoted 6 lines
Quoted 2 lines
Is this just the smallest fix, and the rewrite to the more idiomatic for loop going to be done in a follow-up?
Thanks for the review. But I'm not that sure if it's worth a follow-up patch. Or if anyone else also expects to see a 'for loop' version, I can send a V3 patch then. I have no strong opinion either way.
I think we have iterated over this enough (pun intended).
Quoted 8 lines
Quoted 5 lines
Hhh, interesting.
Quoted 1 line
If this patch is correct then lets stick with this approach.
No problem. Tomorrow I will send the 'for loop' version :)
I meant, I think the while loop is fine.
But anything that is correct is fine by me :)
Okay, great, then no more updates will be made unless other reviewers have opinions :)
Thanks,
Jason
Quoted 42 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jason Xing
Sent: Saturday, July 26, 2025 9:04 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Zaremba, Larysa <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Fijalkowski, Maciej <[email protected]>
Cc: [email protected]; [email protected]; Jason Xing <[email protected]>
Subject: [Intel-wired-lan] [PATCH v2 iwl-net] ixgbe: xsk: resolve the negative overflow of budget inixgbe_xmit_zcFrom: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.
Quoted 6 lines
The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>
Quoted 37 lines
---
[email protected]/
1. use 'negative overflow' instead of 'underflow' (Willem) 2. add reviewed-by tag (Larysa) 3. target iwl-net branch (Larysa) 4. add the reason why the patch addslikely()(Larysa)--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +1
-1@@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) dma_addr_t dma;u32 cmd_type; -while (budget-- >0 ) { +while (likely (budget)) {if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +2
-0break ;@@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) xdp_ring->next_to_use++;if (xdp_ring->next_to_use == xdp_ring->count) xdp_ring->next_to_use =0 ; + + budget--; }if (
tx_desc) {
--
2.41.3
Quoted 26 lines · Jason Xing
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.
Quoted 6 lines
The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>
Hi Tony,
Any update here? Thanks! I'm asking because I'm ready to send an afxdp patch series based on the patch :)
Thanks,
jason
Tony Nguyen
maintainerQuoted 30 lines · Jason Xing
Quoted 29 lines · Jason Xing
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Quoted 8 lines
Quoted 3 lines
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>Hi Tony,
Any update here? Thanks! I'm asking because I'm ready to send an afxdp patch series based on the patch :)
Hi Jason,
I have this slated to be part of my next net series. I do already have this patch applied/staged on the Intel tree [1] (dev-queue branch). You can base it on that and send the changes now; I'll ensure that this patch is merged before sending the other series.
Thanks,
Tony
[1] https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git/
Quoted 2 lines
Thanks,
jason
Quoted 50 lines · Tony Nguyen
Quoted 30 lines · Jason Xing
Quoted 29 lines · Jason Xing
From: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Quoted 8 lines
Quoted 3 lines
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>Hi Tony,
Any update here? Thanks! I'm asking because I'm ready to send an afxdp patch series based on the patch :)
Hi Jason,
I have this slated to be part of my next net series. I do already have this patch applied/staged on the Intel tree [1] (dev-queue branch). You can base it on that and send the changes now; I'll ensure that this patch is merged before sending the other series.
Quoted 4 lines
Thanks,
Tony[1] https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git/
Great, thanks for the pointer!
Thanks,
Jason
Singh, PriyaX
Tested-byQuoted 80 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jason Xing
Sent: Saturday, July 26, 2025 12:34 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Zaremba, Larysa <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Fijalkowski, Maciej <[email protected]>
Cc: [email protected]; [email protected]; Jason Xing <[email protected]>
Subject: [Intel-wired-lan] [PATCH v2 iwl-net] ixgbe: xsk: resolve the negative overflow of budget inixgbe_xmit_zcFrom: Jason Xing <[email protected]>
Resolve the budget negative overflow which leads to returning true in
ixgbe_xmit_zceven when the budget of descs are thoroughly consumed.Before this patch, when the budget is decreased to zero and finishes sending the last allowed desc in
ixgbe_xmit_zc, it will always turn back and enter into thewhile()statement to see if it should keep processing packets, but in the meantime it unexpectedly decreases the value again to 'unsigned int (0--)', namely,UINT_MAX. Finally, theixgbe_xmit_zcreturns true, showing 'we complete cleaning the budget'. That also means 'clean_complete= true' inixgbe_poll.The true theory behind this is if that budget number of descs are consumed, it implies that we might have more descs to be done. So we should return false in
ixgbe_xmit_zcto tell napi poll to find another chance to start polling to handle the rest of descs. On the contrary, returning true here means job done and we know we finish all the possible descs this time and we don't intend to start a new napi poll.It is apparently against our expectations. Please also see how
ixgbe_clean_tx_irq()handles the problem: it uses do..while() statement to make sure the budget can be decreased to zero at most and the negative overflow never happens.The patch adds 'likely' because we rarely would not hit the loop codition since the standard budget is 256.
Fixes 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support")Signed-off-by Jason Xing <[email protected]>Reviewed-by Larysa Zaremba <[email protected]>---
[email protected]/
1. use 'negative overflow' instead of 'underflow' (Willem) 2. add reviewed-by tag (Larysa) 3. target iwl-net branch (Larysa) 4. add the reason why the patch addslikely()(Larysa)--- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +1
-1@@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) dma_addr_t dma;u32 cmd_type; -while (budget-- >0 ) { +while (likely (budget)) {if (unlikely (!ixgbe_desc_unused (xdp_ring))) { work_done = false;drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +2
-0break ;@@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) xdp_ring->next_to_use++;if (xdp_ring->next_to_use == xdp_ring->count) xdp_ring->next_to_use =0 ; + + budget--; }
Quoted 3 lines
if (
tx_desc) {
--
2.41.3