Message ID | 20250205001052.2590140-3-skhawaja@google.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Add support to do threaded napi busy poll | expand |
On Wed, Feb 05, 2025 at 12:10:50AM +0000, Samiullah Khawaja wrote: > Move multiple copies of same code snippet doing `gro_flush` and > `gro_normal_list` into a separate helper function. Like the other patch, this one could probably be sent on its own. I think if you want to include it in your series, that's fine, but I think factoring this out into helpers is good clean up. > Signed-off-by: Samiullah Khawaja <skhawaja@google.com> > --- > net/core/dev.c | 28 +++++++++++++--------------- > 1 file changed, 13 insertions(+), 15 deletions(-) > > diff --git a/net/core/dev.c b/net/core/dev.c > index 50fb234dd7a0..d5dcf9dd6225 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -6484,6 +6484,17 @@ static void skb_defer_free_flush(struct softnet_data *sd) > } > } > > +static void __napi_gro_flush_helper(struct napi_struct *napi) I wonder if this could be changed to take a boolean as a second arg then you could also use this helper in napi_complete_done in addition to the locations you've already cleaned up?
diff --git a/net/core/dev.c b/net/core/dev.c index 50fb234dd7a0..d5dcf9dd6225 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6484,6 +6484,17 @@ static void skb_defer_free_flush(struct softnet_data *sd) } } +static void __napi_gro_flush_helper(struct napi_struct *napi) +{ + if (napi->gro_bitmask) { + /* flush too old packets + * If HZ < 1000, flush all packets. + */ + napi_gro_flush(napi, HZ >= 1000); + } + gro_normal_list(napi); +} + #if defined(CONFIG_NET_RX_BUSY_POLL) static void __busy_poll_stop(struct napi_struct *napi, bool skip_schedule) @@ -6494,14 +6505,8 @@ static void __busy_poll_stop(struct napi_struct *napi, bool skip_schedule) return; } - if (napi->gro_bitmask) { - /* flush too old packets - * If HZ < 1000, flush all packets. - */ - napi_gro_flush(napi, HZ >= 1000); - } + __napi_gro_flush_helper(napi); - gro_normal_list(napi); clear_bit(NAPI_STATE_SCHED, &napi->state); } @@ -7170,14 +7175,7 @@ static int __napi_poll(struct napi_struct *n, bool *repoll) return work; } - if (n->gro_bitmask) { - /* flush too old packets - * If HZ < 1000, flush all packets. - */ - napi_gro_flush(n, HZ >= 1000); - } - - gro_normal_list(n); + __napi_gro_flush_helper(n); /* Some drivers may have called napi_schedule * prior to exhausting their budget.
Move multiple copies of same code snippet doing `gro_flush` and `gro_normal_list` into a separate helper function. Signed-off-by: Samiullah Khawaja <skhawaja@google.com> --- net/core/dev.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)