Skip to content

Commit 87eff2e

Browse files
edumazetdavem330
authored andcommitted
net: optimize napi_threaded_poll() vs RPS/RFS
We use napi_threaded_poll() in order to reduce our softirq dependency. We can add a followup of 821eba9 ("net: optimize napi_schedule_rps()") to further remove the need of firing NET_RX_SOFTIRQ whenever RPS/RFS are used. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a1aaee7 commit 87eff2e

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

include/linux/netdevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,7 +3194,10 @@ struct softnet_data {
31943194
#ifdef CONFIG_RPS
31953195
struct softnet_data *rps_ipi_list;
31963196
#endif
3197+
31973198
bool in_net_rx_action;
3199+
bool in_napi_threaded_poll;
3200+
31983201
#ifdef CONFIG_NET_FLOW_LIMIT
31993202
struct sd_flow_limit __rcu *flow_limit;
32003203
#endif

net/core/dev.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4603,10 +4603,10 @@ static void napi_schedule_rps(struct softnet_data *sd)
46034603
sd->rps_ipi_next = mysd->rps_ipi_list;
46044604
mysd->rps_ipi_list = sd;
46054605

4606-
/* If not called from net_rx_action()
4606+
/* If not called from net_rx_action() or napi_threaded_poll()
46074607
* we have to raise NET_RX_SOFTIRQ.
46084608
*/
4609-
if (!mysd->in_net_rx_action)
4609+
if (!mysd->in_net_rx_action && !mysd->in_napi_threaded_poll)
46104610
__raise_softirq_irqoff(NET_RX_SOFTIRQ);
46114611
return;
46124612
}
@@ -6631,11 +6631,19 @@ static int napi_threaded_poll(void *data)
66316631

66326632
local_bh_disable();
66336633
sd = this_cpu_ptr(&softnet_data);
6634+
sd->in_napi_threaded_poll = true;
66346635

66356636
have = netpoll_poll_lock(napi);
66366637
__napi_poll(napi, &repoll);
66376638
netpoll_poll_unlock(have);
66386639

6640+
sd->in_napi_threaded_poll = false;
6641+
barrier();
6642+
6643+
if (sd_has_rps_ipi_waiting(sd)) {
6644+
local_irq_disable();
6645+
net_rps_action_and_irq_enable(sd);
6646+
}
66396647
skb_defer_free_flush(sd);
66406648
local_bh_enable();
66416649

0 commit comments

Comments
 (0)