Skip to content

Commit

Permalink
net: optimize napi_schedule_rps()
Browse files Browse the repository at this point in the history
Based on initial patch from Jason Xing.

Idea is to not raise NET_RX_SOFTIRQ from napi_schedule_rps()
when we queued a packet into another cpu backlog.

We can do this only in the context of us being called indirectly
from net_rx_action(), to have the guarantee our rps_ipi_list
will be processed before we exit from net_rx_action().

Link: https://lore.kernel.org/lkml/20230325152417.5403-1-kerneljasonxing@gmail.com/
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
Tested-by: Jason Xing <kerneljasonxing@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Eric Dumazet authored and Paolo Abeni committed Mar 30, 2023
1 parent c59647c commit 821eba9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4587,8 +4587,6 @@ static void trigger_rx_softirq(void *data)
*
* - If this is another cpu queue, link it to our rps_ipi_list,
* and make sure we will process rps_ipi_list from net_rx_action().
* As we do not know yet if we are called from net_rx_action(),
* we have to raise NET_RX_SOFTIRQ. This might change in the future.
*
* - If this is our own queue, NAPI schedule our backlog.
* Note that this also raises NET_RX_SOFTIRQ.
Expand All @@ -4602,7 +4600,11 @@ static void napi_schedule_rps(struct softnet_data *sd)
sd->rps_ipi_next = mysd->rps_ipi_list;
mysd->rps_ipi_list = sd;

__raise_softirq_irqoff(NET_RX_SOFTIRQ);
/* If not called from net_rx_action()
* we have to raise NET_RX_SOFTIRQ.
*/
if (!mysd->in_net_rx_action)
__raise_softirq_irqoff(NET_RX_SOFTIRQ);
return;
}
#endif /* CONFIG_RPS */
Expand Down

0 comments on commit 821eba9

Please sign in to comment.