Message ID | 20200914172453.1833883-6-weiwan@google.com |
---|---|
State | RFC |
Delegated to: | David Miller |
Headers | show |
Series | implement kthread based napi poll | expand |
On Mon, Sep 14, 2020 at 10:26 AM Wei Wang <weiwan@google.com> wrote: > > From: Paolo Abeni <pabeni@redhat.com> > > This patch adds the missing part to handle RFS/RPS in the napi thread > handler and makes sure RPS/RFS works properly when using kthread to do > napi poll. > > Signed-off-by: Paolo Abeni <pabeni@redhat.com> > Signed-off-by: Wei Wang <weiwan@google.com> > --- With some more thoughts, I think this patch is not needed. RPS/RFS uses its own napi (sd->backlog) which currently does not have NAPI_STATE_THREADED set. So it is still being handled in softirq context by net_rx_action(). I will remove this patch in the next version if no one objects. > net/core/dev.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/net/core/dev.c b/net/core/dev.c > index be676c21bdc4..ab8af727058b 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -6820,6 +6820,7 @@ static int napi_thread_wait(struct napi_struct *napi) > static int napi_threaded_poll(void *data) > { > struct napi_struct *napi = data; > + struct softnet_data *sd; > void *have; > > while (!napi_thread_wait(napi)) { > @@ -6835,6 +6836,12 @@ static int napi_threaded_poll(void *data) > __kfree_skb_flush(); > local_bh_enable(); > > + sd = this_cpu_ptr(&softnet_data); > + if (sd_has_rps_ipi_waiting(sd)) { > + local_irq_disable(); > + net_rps_action_and_irq_enable(sd); > + } > + > if (!repoll) > break; > > -- > 2.28.0.618.gf4bc123cb7-goog >
On Sat, Sep 19, 2020 at 12:45 AM Wei Wang <weiwan@google.com> wrote: > > On Mon, Sep 14, 2020 at 10:26 AM Wei Wang <weiwan@google.com> wrote: > > > > From: Paolo Abeni <pabeni@redhat.com> > > > > This patch adds the missing part to handle RFS/RPS in the napi thread > > handler and makes sure RPS/RFS works properly when using kthread to do > > napi poll. > > > > Signed-off-by: Paolo Abeni <pabeni@redhat.com> > > Signed-off-by: Wei Wang <weiwan@google.com> > > --- > > With some more thoughts, I think this patch is not needed. RPS/RFS > uses its own napi (sd->backlog) which currently does not have > NAPI_STATE_THREADED set. So it is still being handled in softirq > context by net_rx_action(). > I will remove this patch in the next version if no one objects. The purpose of the patch was to make sure to kick the IPI I think we need it, otherwise RPS/RFS might add a lot of jitter. > > > > net/core/dev.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/net/core/dev.c b/net/core/dev.c > > index be676c21bdc4..ab8af727058b 100644 > > --- a/net/core/dev.c > > +++ b/net/core/dev.c > > @@ -6820,6 +6820,7 @@ static int napi_thread_wait(struct napi_struct *napi) > > static int napi_threaded_poll(void *data) > > { > > struct napi_struct *napi = data; > > + struct softnet_data *sd; > > void *have; > > > > while (!napi_thread_wait(napi)) { > > @@ -6835,6 +6836,12 @@ static int napi_threaded_poll(void *data) > > __kfree_skb_flush(); > > local_bh_enable(); > > > > + sd = this_cpu_ptr(&softnet_data); > > + if (sd_has_rps_ipi_waiting(sd)) { > > + local_irq_disable(); > > + net_rps_action_and_irq_enable(sd); > > + } > > + > > if (!repoll) > > break; > > > > -- > > 2.28.0.618.gf4bc123cb7-goog > >
diff --git a/net/core/dev.c b/net/core/dev.c index be676c21bdc4..ab8af727058b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6820,6 +6820,7 @@ static int napi_thread_wait(struct napi_struct *napi) static int napi_threaded_poll(void *data) { struct napi_struct *napi = data; + struct softnet_data *sd; void *have; while (!napi_thread_wait(napi)) { @@ -6835,6 +6836,12 @@ static int napi_threaded_poll(void *data) __kfree_skb_flush(); local_bh_enable(); + sd = this_cpu_ptr(&softnet_data); + if (sd_has_rps_ipi_waiting(sd)) { + local_irq_disable(); + net_rps_action_and_irq_enable(sd); + } + if (!repoll) break;