* [PATCH 5.15] gve: Fixes for napi_poll when budget is 0
@ 2024-11-26 19:19 Ziwei Xiao
2024-11-26 19:56 ` Sasha Levin
2024-12-02 9:46 ` Greg KH
0 siblings, 2 replies; 5+ messages in thread
From: Ziwei Xiao @ 2024-11-26 19:19 UTC (permalink / raw)
To: stable; +Cc: gregkh, sashal, pkaligineedi, hramamurthy, ziweixiao
Netpoll will explicitly pass the polling call with a budget of 0 to
indicate it's clearing the Tx path only. For the gve_rx_poll and
gve_xdp_poll, they were mistakenly taking the 0 budget as the indication
to do all the work. Add check to avoid the rx path and xdp path being
called when budget is 0. And also avoid napi_complete_done being called
when budget is 0 for netpoll.
The original fix was merged here:
https://lore.kernel.org/r/20231114004144.2022268-1-ziweixiao@google.com
Resend it since the original one was not cleanly applied to 5.15 kernel.
Fixes: f5cedc84a30d ("gve: Add transmit and receive support")
Signed-off-by: Ziwei Xiao <ziweixiao@google.com>
Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com>
Signed-off-by: Praveen Kaligineedi <pkaligineedi@google.com>
---
drivers/net/ethernet/google/gve/gve_main.c | 7 +++++++
drivers/net/ethernet/google/gve/gve_rx.c | 4 ----
drivers/net/ethernet/google/gve/gve_tx.c | 4 ----
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index bf8a4a7c43f7..c3f1959533a8 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -198,6 +198,10 @@ static int gve_napi_poll(struct napi_struct *napi, int budget)
if (block->tx)
reschedule |= gve_tx_poll(block, budget);
+
+ if (!budget)
+ return 0;
+
if (block->rx)
reschedule |= gve_rx_poll(block, budget);
@@ -246,6 +250,9 @@ static int gve_napi_poll_dqo(struct napi_struct *napi, int budget)
if (block->tx)
reschedule |= gve_tx_poll_dqo(block, /*do_clean=*/true);
+ if (!budget)
+ return 0;
+
if (block->rx) {
work_done = gve_rx_poll_dqo(block, budget);
reschedule |= work_done == budget;
diff --git a/drivers/net/ethernet/google/gve/gve_rx.c b/drivers/net/ethernet/google/gve/gve_rx.c
index 94941d4e4744..368e0e770178 100644
--- a/drivers/net/ethernet/google/gve/gve_rx.c
+++ b/drivers/net/ethernet/google/gve/gve_rx.c
@@ -599,10 +599,6 @@ bool gve_rx_poll(struct gve_notify_block *block, int budget)
feat = block->napi.dev->features;
- /* If budget is 0, do all the work */
- if (budget == 0)
- budget = INT_MAX;
-
if (budget > 0)
repoll |= gve_clean_rx_done(rx, budget, feat);
else
diff --git a/drivers/net/ethernet/google/gve/gve_tx.c b/drivers/net/ethernet/google/gve/gve_tx.c
index 665ac795a1ad..d56b8356f1f3 100644
--- a/drivers/net/ethernet/google/gve/gve_tx.c
+++ b/drivers/net/ethernet/google/gve/gve_tx.c
@@ -691,10 +691,6 @@ bool gve_tx_poll(struct gve_notify_block *block, int budget)
u32 nic_done;
u32 to_do;
- /* If budget is 0, do all the work */
- if (budget == 0)
- budget = INT_MAX;
-
/* Find out how much work there is to be done */
tx->last_nic_done = gve_tx_load_event_counter(priv, tx);
nic_done = be32_to_cpu(tx->last_nic_done);
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 5.15] gve: Fixes for napi_poll when budget is 0 2024-11-26 19:19 [PATCH 5.15] gve: Fixes for napi_poll when budget is 0 Ziwei Xiao @ 2024-11-26 19:56 ` Sasha Levin 2024-12-02 9:46 ` Greg KH 1 sibling, 0 replies; 5+ messages in thread From: Sasha Levin @ 2024-11-26 19:56 UTC (permalink / raw) To: stable; +Cc: Ziwei Xiao, Sasha Levin [ Sasha's backport helper bot ] Hi, Found matching upstream commit: 278a370c1766060d2144d6cf0b06c101e1043b6d Status in newer kernel trees: 6.12.y | Present (exact SHA1) 6.11.y | Present (exact SHA1) 6.6.y | Present (different SHA1: ff33be9cecee) 6.1.y | Not found 5.15.y | Not found Note: The patch differs from the upstream commit: --- --- - 2024-11-26 14:50:20.798246719 -0500 +++ /tmp/tmp.FS9IuZXyCo 2024-11-26 14:50:20.790552177 -0500 @@ -1,40 +1,33 @@ -Netpoll will explicilty pass the polling call with a budget of 0 to -indicate it's clearing the Tx path only. For the gve_rx_poll and -gve_xdp_poll, they were mistakenly taking the 0 budget as the indication -to do all the work. Add check to avoid the rx path and xdp path being -called when budget is 0. And also avoid napi_complete_done being called -when budget is 0 for netpoll. +The original fix was merged here: +https://lore.kernel.org/r/20231114004144.2022268-1-ziweixiao@google.com +Resend it since the original one was not cleanly applied to 5.15 kernel. Fixes: f5cedc84a30d ("gve: Add transmit and receive support") Signed-off-by: Ziwei Xiao <ziweixiao@google.com> -Link: https://lore.kernel.org/r/20231114004144.2022268-1-ziweixiao@google.com -Signed-off-by: Jakub Kicinski <kuba@kernel.org> +Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com> +Signed-off-by: Praveen Kaligineedi <pkaligineedi@google.com> --- - drivers/net/ethernet/google/gve/gve_main.c | 8 +++++++- + drivers/net/ethernet/google/gve/gve_main.c | 7 +++++++ drivers/net/ethernet/google/gve/gve_rx.c | 4 ---- drivers/net/ethernet/google/gve/gve_tx.c | 4 ---- - 3 files changed, 7 insertions(+), 9 deletions(-) + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c -index 276f996f95dcc..2d42e733837b0 100644 +index bf8a4a7c43f7..c3f1959533a8 100644 --- a/drivers/net/ethernet/google/gve/gve_main.c +++ b/drivers/net/ethernet/google/gve/gve_main.c -@@ -254,10 +254,13 @@ static int gve_napi_poll(struct napi_struct *napi, int budget) - if (block->tx) { - if (block->tx->q_num < priv->tx_cfg.num_queues) - reschedule |= gve_tx_poll(block, budget); -- else -+ else if (budget) - reschedule |= gve_xdp_poll(block, budget); - } +@@ -198,6 +198,10 @@ static int gve_napi_poll(struct napi_struct *napi, int budget) + if (block->tx) + reschedule |= gve_tx_poll(block, budget); ++ + if (!budget) + return 0; + - if (block->rx) { - work_done = gve_rx_poll(block, budget); - reschedule |= work_done == budget; -@@ -298,6 +301,9 @@ static int gve_napi_poll_dqo(struct napi_struct *napi, int budget) + if (block->rx) + reschedule |= gve_rx_poll(block, budget); + +@@ -246,6 +250,9 @@ static int gve_napi_poll_dqo(struct napi_struct *napi, int budget) if (block->tx) reschedule |= gve_tx_poll_dqo(block, /*do_clean=*/true); @@ -45,10 +38,10 @@ work_done = gve_rx_poll_dqo(block, budget); reschedule |= work_done == budget; diff --git a/drivers/net/ethernet/google/gve/gve_rx.c b/drivers/net/ethernet/google/gve/gve_rx.c -index e84a066aa1a40..73655347902d2 100644 +index 94941d4e4744..368e0e770178 100644 --- a/drivers/net/ethernet/google/gve/gve_rx.c +++ b/drivers/net/ethernet/google/gve/gve_rx.c -@@ -1007,10 +1007,6 @@ int gve_rx_poll(struct gve_notify_block *block, int budget) +@@ -599,10 +599,6 @@ bool gve_rx_poll(struct gve_notify_block *block, int budget) feat = block->napi.dev->features; @@ -57,14 +50,14 @@ - budget = INT_MAX; - if (budget > 0) - work_done = gve_clean_rx_done(rx, budget, feat); - + repoll |= gve_clean_rx_done(rx, budget, feat); + else diff --git a/drivers/net/ethernet/google/gve/gve_tx.c b/drivers/net/ethernet/google/gve/gve_tx.c -index 6957a865cff37..9f6ffc4a54f0b 100644 +index 665ac795a1ad..d56b8356f1f3 100644 --- a/drivers/net/ethernet/google/gve/gve_tx.c +++ b/drivers/net/ethernet/google/gve/gve_tx.c -@@ -925,10 +925,6 @@ bool gve_xdp_poll(struct gve_notify_block *block, int budget) - bool repoll; +@@ -691,10 +691,6 @@ bool gve_tx_poll(struct gve_notify_block *block, int budget) + u32 nic_done; u32 to_do; - /* If budget is 0, do all the work */ @@ -72,5 +65,8 @@ - budget = INT_MAX; - /* Find out how much work there is to be done */ - nic_done = gve_tx_load_event_counter(priv, tx); - to_do = min_t(u32, (nic_done - tx->done), budget); + tx->last_nic_done = gve_tx_load_event_counter(priv, tx); + nic_done = be32_to_cpu(tx->last_nic_done); +-- +2.47.0.338.g60cca15819-goog + --- Results of testing on various branches: | Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-5.15.y | Success | Success | ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 5.15] gve: Fixes for napi_poll when budget is 0 2024-11-26 19:19 [PATCH 5.15] gve: Fixes for napi_poll when budget is 0 Ziwei Xiao 2024-11-26 19:56 ` Sasha Levin @ 2024-12-02 9:46 ` Greg KH 2024-12-09 18:46 ` Ziwei Xiao 1 sibling, 1 reply; 5+ messages in thread From: Greg KH @ 2024-12-02 9:46 UTC (permalink / raw) To: Ziwei Xiao; +Cc: stable, sashal, pkaligineedi, hramamurthy On Tue, Nov 26, 2024 at 07:19:22PM +0000, Ziwei Xiao wrote: > Netpoll will explicitly pass the polling call with a budget of 0 to > indicate it's clearing the Tx path only. For the gve_rx_poll and > gve_xdp_poll, they were mistakenly taking the 0 budget as the indication > to do all the work. Add check to avoid the rx path and xdp path being > called when budget is 0. And also avoid napi_complete_done being called > when budget is 0 for netpoll. > > The original fix was merged here: > https://lore.kernel.org/r/20231114004144.2022268-1-ziweixiao@google.com > Resend it since the original one was not cleanly applied to 5.15 kernel. > > Fixes: f5cedc84a30d ("gve: Add transmit and receive support") > Signed-off-by: Ziwei Xiao <ziweixiao@google.com> > Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com> > Signed-off-by: Praveen Kaligineedi <pkaligineedi@google.com> > --- No git id? :( ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 5.15] gve: Fixes for napi_poll when budget is 0 2024-12-02 9:46 ` Greg KH @ 2024-12-09 18:46 ` Ziwei Xiao 2024-12-09 21:15 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Ziwei Xiao @ 2024-12-09 18:46 UTC (permalink / raw) To: Greg KH; +Cc: stable, sashal, pkaligineedi, hramamurthy On Mon, Dec 2, 2024 at 1:46 AM Greg KH <gregkh@linuxfoundation.org> wrote: > > On Tue, Nov 26, 2024 at 07:19:22PM +0000, Ziwei Xiao wrote: > > Netpoll will explicitly pass the polling call with a budget of 0 to > > indicate it's clearing the Tx path only. For the gve_rx_poll and > > gve_xdp_poll, they were mistakenly taking the 0 budget as the indication > > to do all the work. Add check to avoid the rx path and xdp path being > > called when budget is 0. And also avoid napi_complete_done being called > > when budget is 0 for netpoll. > > > > The original fix was merged here: > > https://lore.kernel.org/r/20231114004144.2022268-1-ziweixiao@google.com > > Resend it since the original one was not cleanly applied to 5.15 kernel. > > > > Fixes: f5cedc84a30d ("gve: Add transmit and receive support") > > Signed-off-by: Ziwei Xiao <ziweixiao@google.com> > > Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com> > > Signed-off-by: Praveen Kaligineedi <pkaligineedi@google.com> > > --- > > No git id? :( Sorry for missing that. Here is the commit id: commit 278a370c1766 upstream. Do I need to resend a V2 to contain the above line? Thank you! ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 5.15] gve: Fixes for napi_poll when budget is 0 2024-12-09 18:46 ` Ziwei Xiao @ 2024-12-09 21:15 ` Greg KH 0 siblings, 0 replies; 5+ messages in thread From: Greg KH @ 2024-12-09 21:15 UTC (permalink / raw) To: Ziwei Xiao; +Cc: stable, sashal, pkaligineedi, hramamurthy On Mon, Dec 09, 2024 at 10:46:58AM -0800, Ziwei Xiao wrote: > On Mon, Dec 2, 2024 at 1:46 AM Greg KH <gregkh@linuxfoundation.org> wrote: > > > > On Tue, Nov 26, 2024 at 07:19:22PM +0000, Ziwei Xiao wrote: > > > Netpoll will explicitly pass the polling call with a budget of 0 to > > > indicate it's clearing the Tx path only. For the gve_rx_poll and > > > gve_xdp_poll, they were mistakenly taking the 0 budget as the indication > > > to do all the work. Add check to avoid the rx path and xdp path being > > > called when budget is 0. And also avoid napi_complete_done being called > > > when budget is 0 for netpoll. > > > > > > The original fix was merged here: > > > https://lore.kernel.org/r/20231114004144.2022268-1-ziweixiao@google.com > > > Resend it since the original one was not cleanly applied to 5.15 kernel. > > > > > > Fixes: f5cedc84a30d ("gve: Add transmit and receive support") > > > Signed-off-by: Ziwei Xiao <ziweixiao@google.com> > > > Reviewed-by: Praveen Kaligineedi <pkaligineedi@google.com> > > > Signed-off-by: Praveen Kaligineedi <pkaligineedi@google.com> > > > --- > > > > No git id? :( > > Sorry for missing that. Here is the commit id: > > commit 278a370c1766 upstream. > > Do I need to resend a V2 to contain the above line? Thank you! > Yes please. thanks, greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-09 21:16 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-11-26 19:19 [PATCH 5.15] gve: Fixes for napi_poll when budget is 0 Ziwei Xiao 2024-11-26 19:56 ` Sasha Levin 2024-12-02 9:46 ` Greg KH 2024-12-09 18:46 ` Ziwei Xiao 2024-12-09 21:15 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox