net: extend busy polling support
Subsystems (24)
v2 cover net: extend busy polling support
This patch series extends busy polling range to tunnels devices, and adds busy polling generic support to all NAPI drivers.
No need to provide ndo_busy_poll() method and extra synchronization between ndo_busy_poll() and normal napi->poll() method. This was proven very difficult and bug prone.
mlx5 driver is changed to support busy polling using this new method, and a second mlx5 patch adds napi_complete_done() support and proper SNMP accounting.
bnx2x and mlx4 drivers are converted to new infrastructure, reducing kernel bloat and improving performance.
Latest patch, adding generic support, adds a new requirement :
-free_netdev() and netif_napi_del() must be called from process context.
Since this might not be the case in some drivers, we might have to either : fix the non conformant drivers (by disabling busy polling on them) or revert this last patch.
Eric Dumazet (14):
net: better skb->sender_cpu and skb->napi_id cohabitation
mlx4: mlx4_en_low_latency_recv() called with BH disabled
net: un-inline sk_busy_loop()
net: allow BH servicing in sk_busy_loop()
net: network drivers no longer need to implement ndo_busy_poll()
mlx5: add busy polling support
mlx5: support napi_complete_done()
bnx2x: remove bnx2x_low_latency_recv() support
mlx4: remove mlx4_en_low_latency_recv()
net: move skb_mark_napi_id() into core networking stack
net: add netif_tx_napi_add()
net: move napi_hash[] into read mostly section
net: napi_hash_del() returns a boolean status
net: provide generic busy polling to all NAPI drivers
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 1 - drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 113 ------------------ drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 50 +------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 7 -- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 - drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 - drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 +- drivers/net/ethernet/chelsio/cxgb4/sge.c | 2 - drivers/net/ethernet/cisco/enic/enic_main.c | 2 - drivers/net/ethernet/emulex/benet/be_main.c | 2 - .../net/ethernet/freescale/fs_enet/fs_enet-main.c | 2 +- drivers/net/ethernet/freescale/gianfar.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 1 - drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 1 - drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 1 - drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 3 - drivers/net/ethernet/mellanox/mlx4/en_cq.c | 10 +- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 17 --- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 40 ------- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 18 +-- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 126 --------------------- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 + drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 15 ++- drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 11 +- drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 3 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 4 +- drivers/net/ethernet/rocker/rocker.c | 2 +- drivers/net/ethernet/sfc/efx.c | 1 - drivers/net/ethernet/sfc/rx.c | 1 - drivers/net/ethernet/ti/cpsw.c | 2 +- drivers/net/ethernet/ti/netcp_core.c | 2 +- drivers/net/virtio_net.c | 3 - drivers/net/wireless/ath/wil6210/netdev.c | 2 +- include/linux/hashtable.h | 4 + include/linux/netdevice.h | 44 +++++-- include/linux/skbuff.h | 3 - include/net/busy_poll.h | 45 +------- net/core/dev.c | 116 +++++++++++++++---- 41 files changed, 171 insertions(+), 507 deletions(-)
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 1/14 net: better skb->sender_cpu and skb->napi_id cohabitation
skb->sender_cpu and skb->napi_id share a common storage, and we had various bugs about this.
We had to call skb_sender_cpu_clear() in some places to not leave a prior skb->napi_id and fool netdev_pick_tx()
As suggested by Alexei, we could split the space so that these errors can not happen.
0 value being reserved as the common (not initialized) value, let's reserve [1 .. NR_CPUS] range for valid sender_cpu, and [NR_CPUS+1 .. ~0U] for valid napi_id.
This will allow proper busy polling support over tunnels.
--- include/linux/skbuff.h | 3 --- net/core/dev.c | 33 ++++++++++++++++----------------- 2 files changed, 16 insertions(+), 20 deletions(-)
include/linux/skbuff.h +0 -3
@@ -1082,9 +1082,6 @@ static inline void skb_copy_hash(struct sk_buff *to, const struct sk_buff *from)static inline void skb_sender_cpu_clear (struct sk_buff *skb) { -#ifdef CONFIG_XPS - skb->sender_cpu =0 ; -#endif }#ifdef NET_SKBUFF_DATA_USES_OFFSET
net/core/dev.c +16 -17
@@ -182,7 +182,7 @@ EXPORT_SYMBOL(dev_base_lock);/* protects napi_hash addition/deletion and napi_gen_id */ static DEFINE_SPINLOCK (napi_hash_lock); -static unsigned int napi_gen_id; +static unsigned int napi_gen_id =NR_CPUS ; static DEFINE_HASHTABLE(napi_hash, 8);static seqcount_t devnet_rename_seq;
@@ -3021,7 +3021,9 @@ struct netdev_queue *netdev_pick_tx(struct net_device *dev,int queue_index =0 ;#ifdef CONFIG_XPS -if (skb->sender_cpu ==0 ) +u32 sender_cpu = skb->sender_cpu -1 ; + +if (sender_cpu >= (u32 )NR_CPUS ) skb->sender_cpu =raw_smp_processor_id () +1 ;#endif
@@ -4676,25 +4678,22 @@ EXPORT_SYMBOL_GPL(napi_by_id);void napi_hash_add (struct napi_struct *napi) { -if (!test_and_set_bit (NAPI_STATE_HASHED , &napi->state)) { +if (test_and_set_bit (NAPI_STATE_HASHED , &napi->state)) +return ; -spin_lock (&napi_hash_lock); +spin_lock (&napi_hash_lock); -/* 0 is not a valid id, we also skip an id that is taken -* we expect both events to be extremely rare -*/ - napi->napi_id =0 ; -while (!napi->napi_id) { - napi->napi_id = ++napi_gen_id; -if (napi_by_id (napi->napi_id)) - napi->napi_id =0 ; - } +/* 0..NR_CPUS+1 range is reserved for sender_cpu use */ +do { +if (unlikely (++napi_gen_id <NR_CPUS +1 )) + napi_gen_id =NR_CPUS +1 ; + }while (napi_by_id (napi_gen_id)); + napi->napi_id = napi_gen_id; -hlist_add_head_rcu (&napi->napi_hash_node, - &napi_hash[napi->napi_id %HASH_SIZE (napi_hash)]); +hlist_add_head_rcu (&napi->napi_hash_node, + &napi_hash[napi->napi_id %HASH_SIZE (napi_hash)]); -spin_unlock (&napi_hash_lock); - } +spin_unlock (&napi_hash_lock); }EXPORT_SYMBOL_GPL (napi_hash_add);
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 2/14 mlx4: mlx4_en_low_latency_recv() called with BH disabled
In reply to Eric Dumazetmlx4_en_low_latency_recv() is called with BH disabled, as other ndo_busy_poll() methods.
No need for spin_lock_bh()/spin_unlock_bh()
--- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +7 -5
@@ -660,11 +660,12 @@ static inline bool mlx4_en_cq_unlock_napi(struct mlx4_en_cq *cq)return rc; } -/* called from mlx4_en_low_latency_poll() */ +/* called from mlx4_en_low_latency_recv(), BH are disabled */ static inline bool mlx4_en_cq_lock_poll (struct mlx4_en_cq *cq) {int rc = true; -spin_lock_bh (&cq->poll_lock); + +spin_lock (&cq->poll_lock);if ((cq->state &MLX4_CQ_LOCKED )) {struct net_device *dev = cq->dev;struct mlx4_en_priv *priv =netdev_priv (dev);
@@ -676,7 +677,7 @@ static inline bool mlx4_en_cq_lock_poll(struct mlx4_en_cq *cq) }else /* preserve yield marks */ cq->state |=MLX4_EN_CQ_STATE_POLL ; -spin_unlock_bh (&cq->poll_lock); +spin_unlock (&cq->poll_lock);return rc; }
@@ -684,13 +685,14 @@ static inline bool mlx4_en_cq_lock_poll(struct mlx4_en_cq *cq)static inline bool mlx4_en_cq_unlock_poll (struct mlx4_en_cq *cq) {int rc = false; -spin_lock_bh (&cq->poll_lock); + +spin_lock (&cq->poll_lock);WARN_ON (cq->state & (MLX4_EN_CQ_STATE_NAPI ));if (cq->state &MLX4_EN_CQ_STATE_POLL_YIELD ) rc = true; cq->state =MLX4_EN_CQ_STATE_IDLE ; -spin_unlock_bh (&cq->poll_lock); +spin_unlock (&cq->poll_lock);return rc; }
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 3/14 net: un-inline sk_busy_loop()
In reply to Eric DumazetThere is really little gain from inlining this big function. We'll soon make it even bigger in following patches.
This means we no longer need to export napi_by_id()
--- include/linux/netdevice.h | 9 --------- include/net/busy_poll.h | 45 +----------------------------------------- net/core/dev.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 55 deletions(-)
include/linux/netdevice.h +0 -9
@@ -461,15 +461,6 @@ static inline void napi_complete(struct napi_struct *n) }/** -* napi_by_id - lookup a NAPI by napi_id -* @napi_id: hashed napi_id -* -* lookup @napi_id in napi_hash table -* must be called under rcu_read_lock() -*/ -struct napi_struct *napi_by_id (unsigned int napi_id); - -/** * napi_hash_add - add a NAPI to global hashtable * @napi: napi context *
include/net/busy_poll.h +1 -44
51 lines not on this page · raw message
net/core/dev.c +48 -2
68 lines not on this page · raw message
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 4/14 net: allow BH servicing in sk_busy_loop()
In reply to Eric DumazetInstead of blocking BH in whole sk_busy_loop(), block them only around ->ndo_busy_poll() calls.
This has many benefits.
1) allow tunneled traffic to use busy poll as well as native traffic. Tunnels handlers usually call netif_rx() and depend on net_rx_action() being run (from sofirq handler)
2) allow RFS/RPS being used (sending IPI to other cpus if needed)
3) use the 'lets burn cpu cycles' budget to do useful work (like TX completions, timers, RCU callbacks...)
4) reduce BH latencies, making busy poll a better citizen.
Tested:
Tested with SIT tunnel
lpaa5:~# echo 0 >/proc/sys/net/core/busy_read lpaa5:~# ./netperf -H 2002:af6:786::1 -t TCP_RR MIGRATED TCP REQUEST/RESPONSE TEST from ::0 (::) port 0 AF_INET6 to 2002:af6:786::1 () port 0 AF_INET6 : first burst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec
16384 87380 1 1 10.00 37373.93
16384 87380
Now enable busy poll on both hosts
lpaa5:~# echo 70 >/proc/sys/net/core/busy_read lpaa6:~# echo 70 >/proc/sys/net/core/busy_read
lpaa5:~# ./netperf -H 2002:af6:786::1 -t TCP_RR MIGRATED TCP REQUEST/RESPONSE TEST from ::0 (::) port 0 AF_INET6 to 2002:af6:786::1 () port 0 AF_INET6 : first burst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec
16384 87380 1 1 10.00 58314.77
16384 87380
--- net/core/dev.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
net/core/dev.c +7 -11
@@ -4684,11 +4684,7 @@ bool sk_busy_loop(struct sock *sk, int nonblock)struct napi_struct *napi;int rc = false; -/* -* rcu read lock for napi hash -* bh so we don't race with net_rx_action -*/ -rcu_read_lock_bh (); +rcu_read_lock (); napi =napi_by_id (sk->sk_napi_id);if (!napi)
@@ -4699,23 +4695,23 @@ bool sk_busy_loop(struct sock *sk, int nonblock) goto out;do { +local_bh_disable (); rc = ops->ndo_busy_poll (napi); +if (rc >0 ) +NET_ADD_STATS_BH (sock_net (sk), +LINUX_MIB_BUSYPOLLRXPACKETS , rc); +local_bh_enable ();if (rc ==LL_FLUSH_FAILED )break ;/* permanent failure */ -if (rc >0 ) -/* local bh are disabled so it is ok to use _BH */ -NET_ADD_STATS_BH (sock_net (sk), -LINUX_MIB_BUSYPOLLRXPACKETS , rc);cpu_relax (); - }while (!nonblock &&skb_queue_empty (&sk->sk_receive_queue) && !need_resched () && !busy_loop_timeout (end_time)); rc = !skb_queue_empty (&sk->sk_receive_queue); out: -rcu_read_unlock_bh (); +rcu_read_unlock ();return rc; }EXPORT_SYMBOL (sk_busy_loop);
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 5/14 net: network drivers no longer need to implement ndo_busy_poll()
In reply to Eric DumazetInstead of having to implement complex ndo_busy_poll() method, drivers can simply rely on NAPI poll logic.
Busy polling gains are mainly coming from polling itself, not on exact details on how we poll the device.
ndo_busy_poll() if implemented can avoid touching
napi state, but it adds extra synchronization between normal napi->poll() and busy poll handler, slowing down the common path (non busy polling) with extra atomic operations. In practice few drivers ever got busy poll because of the complexity.
We could go one step further, and make busy polling available for all NAPI drivers, but this would require that all netif_napi_del() calls are done in process context so that we can call synchronize_rcu().
Full audit would be required.
Before this is done, a driver still needs to call :
- skb_mark_napi_id() for each skb provided to the stack.
- napi_hash_add() and napi_hash_del() to allocate a napi_id per napi struct.
- Make sure RCU grace period is respected after napi_hash_del() before memory containing napi structure is freed.
Followup patch implements busy poll for mlx5 driver as an example.
--- net/core/dev.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
net/core/dev.c +20 -5
@@ -4677,10 +4677,11 @@ static struct napi_struct *napi_by_id(unsigned int napi_id) }#if defined(CONFIG_NET_RX_BUSY_POLL ) +#define BUSY_POLL_BUDGET 8bool sk_busy_loop (struct sock *sk,int nonblock) {unsigned long end_time = !nonblock ?sk_busy_loop_end_time (sk) :0 ; -const struct net_device_ops *ops; +int (*busy_poll)(struct napi_struct *dev);struct napi_struct *napi;int rc = false;
@@ -4690,13 +4691,27 @@ bool sk_busy_loop(struct sock *sk, int nonblock)if (!napi) goto out; - ops = napi->dev->netdev_ops; -if (!ops->ndo_busy_poll) - goto out; +/* Note: ndo_busy_poll method is optional in linux-4.5 */ + busy_poll = napi->dev->netdev_ops->ndo_busy_poll; do { + rc = 0; local_bh_disable(); - rc = ops->ndo_busy_poll(napi); + if (busy_poll) { + rc = busy_poll(napi); + } else if (napi_schedule_prep(napi)) { + void *have = netpoll_poll_lock(napi); + + if (test_bit(NAPI_STATE_SCHED, &napi->state)) { + rc = napi->poll(napi, BUSY_POLL_BUDGET); + trace_napi_poll(napi); + if (rc == BUSY_POLL_BUDGET) { + napi_complete_done(napi, rc); + napi_schedule(napi); + } + } + netpoll_poll_unlock(have); + } if (rc > 0) NET_ADD_STATS_BH(sock_net(sk), LINUX_MIB_BUSYPOLLRXPACKETS, rc);
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 6/14 mlx5: add busy polling support
In reply to Eric DumazetIt is now easy to add busy polling support to a NAPI driver, with very little impact on normal input path.
This patch serves as a reference implementation.
Note:
A followup patch will add proper napi_complete_done() in mlx5, so that LINUX_MIB_BUSYPOLLRXPACKETS snmp counter is properly handled.
Tested:
Normal TCP_RR results without busy polling :
lpk51:~# echo 0 >/proc/sys/net/core/busy_read lpk52:~# echo 0 >/proc/sys/net/core/busy_read
lpk51:~# ./netperf -H 192.168.4.52 -t TCP_RR -l 10 MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.4.52 () port 0 AF_INET : first burst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec
16384 87380 1 1 10.00 53509.49
16384 87380
Now enable busy polling :
lpk51:~# echo 70 >/proc/sys/net/core/busy_read lpk52:~# echo 70 >/proc/sys/net/core/busy_read
lpk51:~# ./netperf -H 192.168.4.52 -t TCP_RR -l 10 MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.4.52 () port 0 AF_INET : first burst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec
16384 87380 1 1 10.00 97530.92
16384 87380
--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 ++++++ drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 ++ 2 files changed, 8 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +6 -0
@@ -982,6 +982,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,mlx5e_build_channeltc_to_txq_map (priv, ix);netif_napi_add (netdev, &c->napi, mlx5e_napi_poll,64 ); +napi_hash_add (&c->napi); err =mlx5e_open_tx_cqs (c, cparam);if (err)
@@ -1020,6 +1021,7 @@ err_close_tx_cqs: err_napi_del:netif_napi_del (&c->napi); +napi_hash_del (&c->napi);kfree (c);return err;
@@ -1033,6 +1035,10 @@ static void mlx5e_close_channel(struct mlx5e_channel *c)mlx5e_close_cq (&c->rq.cq);mlx5e_close_tx_cqs (c);netif_napi_del (&c->napi); + +napi_hash_del (&c->napi); +synchronize_rcu (); +kfree (c); }
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +2 -0
@@ -33,6 +33,7 @@#include <linux/ip.h> #include <linux/ipv6.h> #include <linux/tcp.h> +#include <net/busy_poll.h> #include "en.h" static inline int mlx5e_alloc_rx_wqe(struct mlx5e_rq *rq,
@@ -242,6 +243,7 @@ bool mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget) wqe =mlx5_wq_ll_get_wqe (&rq->wq, wqe_counter); skb = rq->skb[wqe_counter];prefetch (skb->data); +skb_mark_napi_id (skb, cq->napi); rq->skb[wqe_counter] =NULL ; dma_unmap_single(rq->pdev,
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 7/14 mlx5: support napi_complete_done()
In reply to Eric DumazetA NAPI poll handler should return number of RX packets processed, instead of 0 / budget.
This allows proper busy poll accounting through LINUX_MIB_BUSYPOLLRXPACKETS SNMP counter.
napi_complete_done() allows /sys/class/net/ethX/gro_flush_timeout to be used for finer GRO aggregation control.
Tested:
Enabled busy polling, and checked TcpExtBusyPollRxPackets counter is increasing.
echo 70 >/proc/sys/net/core/busy_read
nstat >/dev/null
netperf -H target -t TCP_RR >/dev/null
nstat | grep TcpExtBusyPollRxPackets
TcpExtBusyPollRxPackets 490958 0.0
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 14 ++++++-------- drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c | 11 ++++++----- 3 files changed, 13 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -1
@@ -564,7 +564,7 @@ void mlx5e_completion_event(struct mlx5_core_cq *mcq);void mlx5e_cq_error_event (struct mlx5_core_cq *mcq,enum mlx5_event event);int mlx5e_napi_poll (struct napi_struct *napi,int budget);bool mlx5e_poll_tx_cq (struct mlx5e_cq *cq); -bool mlx5e_poll_rx_cq (struct mlx5e_cq *cq,int budget); +int mlx5e_poll_rx_cq (struct mlx5e_cq *cq,int budget);bool mlx5e_post_rx_wqes (struct mlx5e_rq *rq);struct mlx5_cqe64 *mlx5e_get_cqe (struct mlx5e_cq *cq);
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +6 -8
@@ -216,16 +216,16 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe, be16_to_cpu(cqe->vlan_info)); } -bool mlx5e_poll_rx_cq (struct mlx5e_cq *cq,int budget) +int mlx5e_poll_rx_cq (struct mlx5e_cq *cq,int budget) { struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq); -int i; +int work_done;/* avoid accessing cq (dma coherent memory) if not needed */ if (!test_and_clear_bit (MLX5E_CQ_HAS_CQES , &cq->flags)) -return false; +return 0 ; -for (i =0 ; i < budget; i++) { +for (work_done =0 ; work_done < budget; work_done++) {struct mlx5e_rx_wqe *wqe;struct mlx5_cqe64 *cqe;struct sk_buff *skb;
@@ -271,10 +271,8 @@ wq_ll_pop:/* ensure cq space is freed before enabling more cqes */ wmb (); -if (i == budget) { +if (work_done == budget)set_bit (MLX5E_CQ_HAS_CQES , &cq->flags); -return true; - } -return false; +return work_done; }
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c +6 -5
@@ -54,6 +54,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget) struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel, napi);bool busy = false; +int work_done;int i;clear_bit (MLX5E_CHANNEL_NAPI_SCHED , &c->flags);
@@ -61,26 +62,26 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)for (i =0 ; i < c->num_tc; i++) busy |=mlx5e_poll_tx_cq (&c->sq[i].cq); - busy |=mlx5e_poll_rx_cq (&c->rq.cq, budget); - + work_done =mlx5e_poll_rx_cq (&c->rq.cq, budget); + busy |= work_done == budget; busy |=mlx5e_post_rx_wqes (&c->rq);if (busy)return budget; -napi_complete (napi); +napi_complete_done (napi, work_done);/* avoid losing completion event during/after polling cqs */ if (test_bit (MLX5E_CHANNEL_NAPI_SCHED , &c->flags)) {napi_schedule (napi); -return 0 ; +return work_done; }for (i =0 ; i < c->num_tc; i++)mlx5e_cq_arm (&c->sq[i].cq);mlx5e_cq_arm (&c->rq.cq); -return 0 ; +return work_done; }void mlx5e_completion_event (struct mlx5_core_cq *mcq)
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 8/14 bnx2x: remove bnx2x_low_latency_recv() support
In reply to Eric DumazetSwitch to native NAPI polling, as this reduces overhead and complexity.
Normal path is faster, since one cmpxchg() is not anymore requested, and busy polling with the NAPI polling has same performance.
Tested:
lpk50:~# cat /proc/sys/net/core/busy_read 70 lpk50:~# nstat >/dev/null;./netperf -H lpk55 -t TCP_RR;nstat MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to lpk55.prod.google.com () port 0 AF_INET : first burst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec
16384 87380 1 1 10.00 40095.07
16384 87380
IpInReceives 401062 0.0 IpInDelivers 401062 0.0 IpOutRequests 401079 0.0 TcpActiveOpens 7 0.0 TcpPassiveOpens 3 0.0 TcpAttemptFails 3 0.0 TcpEstabResets 5 0.0 TcpInSegs 401036 0.0 TcpOutSegs 401052 0.0 TcpOutRsts 38 0.0 UdpInDatagrams 26 0.0 UdpOutDatagrams 27 0.0 Ip6OutNoRoutes 1 0.0 TcpExtDelayedACKs 1 0.0 TcpExtTCPPrequeued 98 0.0 TcpExtTCPDirectCopyFromPrequeue 98 0.0 TcpExtTCPHPHits 4 0.0 TcpExtTCPHPHitsToUser 98 0.0 TcpExtTCPPureAcks 5 0.0 TcpExtTCPHPAcks 101 0.0 TcpExtTCPAbortOnData 6 0.0 TcpExtBusyPollRxPackets 400832 0.0 TcpExtTCPOrigDataSent 400983 0.0 IpExtInOctets 21273867 0.0 IpExtOutOctets 21261254 0.0 IpExtInNoECTPkts 401064 0.0
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 113 ----------------------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 46 +-------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 7 -- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 - 4 files changed, 2 insertions(+), 167 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +0 -113
@@ -540,10 +540,6 @@ struct bnx2x_fastpath {struct napi_struct napi; -#ifdef CONFIG_NET_RX_BUSY_POLL -unsigned long busy_poll_state; -#endif -union host_hc_status_block status_blk;/* chip independent shortcuts into sb structure */ __le16 *sb_index_values;
@@ -617,115 +613,6 @@ struct bnx2x_fastpath {#define bnx2x_fp_stats (bp, fp) (&((bp)->fp_stats[(fp)->index]))#define bnx2x_fp_qstats (bp, fp) (&((bp)->fp_stats[(fp)->index].eth_q_stats)) -#ifdef CONFIG_NET_RX_BUSY_POLL - -enum bnx2x_fp_state { -BNX2X_STATE_FP_NAPI =BIT (0 ),/* NAPI handler owns the queue */ - -BNX2X_STATE_FP_NAPI_REQ_BIT =1 ,/* NAPI would like to own the queue */ -BNX2X_STATE_FP_NAPI_REQ =BIT (1 ), - -BNX2X_STATE_FP_POLL_BIT =2 , -BNX2X_STATE_FP_POLL =BIT (2 ),/* busy_poll owns the queue */ - -BNX2X_STATE_FP_DISABLE_BIT =3 ,/* queue is dismantled */ -}; - -static inline void bnx2x_fp_busy_poll_init (struct bnx2x_fastpath *fp) -{ -WRITE_ONCE (fp->busy_poll_state,0 ); -} - -/* called from the device poll routine to get ownership of a FP */ -static inline bool bnx2x_fp_lock_napi (struct bnx2x_fastpath *fp) -{ -unsigned long prev, old =READ_ONCE (fp->busy_poll_state); - -while (1 ) { -switch (old) { -case BNX2X_STATE_FP_POLL : -/* make sure bnx2x_fp_lock_poll() wont starve us */ -set_bit (BNX2X_STATE_FP_NAPI_REQ_BIT , - &fp->busy_poll_state); -/* fallthrough */ -case BNX2X_STATE_FP_POLL |BNX2X_STATE_FP_NAPI_REQ : -return false; -default : -break ; - } - prev =cmpxchg (&fp->busy_poll_state, old,BNX2X_STATE_FP_NAPI ); -if (unlikely (prev != old)) { - old = prev; -continue ; - } -return true; - } -} - -static inline void bnx2x_fp_unlock_napi (struct bnx2x_fastpath *fp) -{ -smp_wmb (); - fp->busy_poll_state =0 ; -} - -/* called from bnx2x_low_latency_poll() */ -static inline bool bnx2x_fp_lock_poll (struct bnx2x_fastpath *fp) -{ -return cmpxchg (&fp->busy_poll_state,0 ,BNX2X_STATE_FP_POLL ) ==0 ; -} - -static inline void bnx2x_fp_unlock_poll (struct bnx2x_fastpath *fp) -{ -smp_mb__before_atomic (); -clear_bit (BNX2X_STATE_FP_POLL_BIT , &fp->busy_poll_state); -} - -/* true if a socket is polling */ -static inline bool bnx2x_fp_ll_polling (struct bnx2x_fastpath *fp) -{ -return READ_ONCE (fp->busy_poll_state) &BNX2X_STATE_FP_POLL ; -} - -/* false if fp is currently owned */ -static inline bool bnx2x_fp_ll_disable (struct bnx2x_fastpath *fp) -{ -set_bit (BNX2X_STATE_FP_DISABLE_BIT , &fp->busy_poll_state); -return !bnx2x_fp_ll_polling (fp); - -} -#else -static inline void bnx2x_fp_busy_poll_init (struct bnx2x_fastpath *fp) -{ -} - -static inline bool bnx2x_fp_lock_napi (struct bnx2x_fastpath *fp) -{ -return true; -} - -static inline void bnx2x_fp_unlock_napi (struct bnx2x_fastpath *fp) -{ -} - -static inline bool bnx2x_fp_lock_poll (struct bnx2x_fastpath *fp) -{ -return false; -} - -static inline void bnx2x_fp_unlock_poll (struct bnx2x_fastpath *fp) -{ -} - -static inline bool bnx2x_fp_ll_polling (struct bnx2x_fastpath *fp) -{ -return false; -} -static inline bool bnx2x_fp_ll_disable (struct bnx2x_fastpath *fp) -{ -return true; -} -#endif /* CONFIG_NET_RX_BUSY_POLL */ -/* Use 2500 as a mini-jumbo MTU for FCoE */ #define BNX2X_FCOE_MINI_JUMBO_MTU 2500
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +2 -44
97 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +0 -7
@@ -570,13 +570,6 @@ int bnx2x_enable_msix(struct bnx2x *bp);int bnx2x_enable_msi (struct bnx2x *bp);/** -* bnx2x_low_latency_recv - LL callback -* -* @napi: napi structure -*/ -int bnx2x_low_latency_recv (struct napi_struct *napi); - -/** * bnx2x_alloc_mem_bp - allocate memories outsize main driver structure * * @bp: driver handle
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +0 -3
@@ -13004,9 +13004,6 @@ static const struct net_device_ops bnx2x_netdev_ops = { .ndo_fcoe_get_wwn = bnx2x_fcoe_get_wwn, #endif -#ifdef CONFIG_NET_RX_BUSY_POLL - .ndo_busy_poll = bnx2x_low_latency_recv, -#endif .ndo_get_phys_port_id = bnx2x_get_phys_port_id, .ndo_set_vf_link_state = bnx2x_set_vf_link_state, .ndo_features_check = bnx2x_features_check,
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 9/14 mlx4: remove mlx4_en_low_latency_recv()
In reply to Eric DumazetBusy polling can now be handled in generic NAPI poll infrastructure. This removes complexity and fast path overhead :
mlx4 used two spin_lock()/spin_unlock() pair per napi->poll() call in mlx4_en_cq_lock_napi()/mlx4_en_cq_unlock_napi()
Tested:
Without busy polling :
lpaa23:~# echo 0 >/proc/sys/net/core/busy_read lpaa24:~# echo 0 >/proc/sys/net/core/busy_read lpaa23:~# ./netperf -H lpaa24 -t TCP_RR MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to lpaa24.prod.google.com () port 0 AF_INET : first burst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec
16384 87380 1 1 10.00 47330.78
With busy polling :
lpaa23:~# echo 70 >/proc/sys/net/core/busy_read lpaa24:~# echo 70 >/proc/sys/net/core/busy_read lpaa23:~# ./netperf -H lpaa24 -t TCP_RR MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to lpaa24.prod.google.com () port 0 AF_INET : first burst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec
16384 87380 1 1 10.00 97643.55
--- drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 17 ---- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 40 -------- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 15 +-- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 128 ------------------------ 4 files changed, 2 insertions(+), 198 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +0 -17
@@ -337,11 +337,7 @@ static int mlx4_en_get_sset_count(struct net_device *dev, int sset)case ETH_SS_STATS :return bitmap_iterator_count (&it) + (priv->tx_ring_num *2 ) + -#ifdef CONFIG_NET_RX_BUSY_POLL - (priv->rx_ring_num *5 ); -#else (priv->rx_ring_num *2 ); -#endif case ETH_SS_TEST :return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags &MLX4_DEV_CAP_FLAG_UC_LOOPBACK ) *2 ;
@@ -408,11 +404,6 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,for (i =0 ; i < priv->rx_ring_num; i++) { data[index++] = priv->rx_ring[i]->packets; data[index++] = priv->rx_ring[i]->bytes; -#ifdef CONFIG_NET_RX_BUSY_POLL - data[index++] = priv->rx_ring[i]->yields; - data[index++] = priv->rx_ring[i]->misses; - data[index++] = priv->rx_ring[i]->cleaned; -#endif }spin_unlock_bh (&priv->stats_lock);
@@ -486,14 +477,6 @@ static void mlx4_en_get_strings(struct net_device *dev, "rx%d_packets", i);sprintf (data + (index++) *ETH_GSTRING_LEN ,"rx%d_bytes" , i); -#ifdef CONFIG_NET_RX_BUSY_POLL -sprintf (data + (index++) *ETH_GSTRING_LEN , -"rx%d_napi_yield" , i); -sprintf (data + (index++) *ETH_GSTRING_LEN , -"rx%d_misses" , i); -sprintf (data + (index++) *ETH_GSTRING_LEN , -"rx%d_cleaned" , i); -#endif }break ;case ETH_SS_PRIV_FLAGS :
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 -40
@@ -69,34 +69,6 @@ int mlx4_en_setup_tc(struct net_device *dev, u8 up)return 0 ; } -#ifdef CONFIG_NET_RX_BUSY_POLL -/* must be called with local_bh_disable()d */ -static int mlx4_en_low_latency_recv (struct napi_struct *napi) -{ - struct mlx4_en_cq *cq = container_of(napi, struct mlx4_en_cq, napi); -struct net_device *dev = cq->dev; -struct mlx4_en_priv *priv =netdev_priv (dev); -struct mlx4_en_rx_ring *rx_ring = priv->rx_ring[cq->ring]; -int done; - -if (!priv->port_up) -return LL_FLUSH_FAILED ; - -if (!mlx4_en_cq_lock_poll (cq)) -return LL_FLUSH_BUSY ; - - done =mlx4_en_process_rx_cq (dev, cq,4 ); -if (likely (done)) - rx_ring->cleaned += done; -else - rx_ring->misses++; - -mlx4_en_cq_unlock_poll (cq); - -return done; -} -#endif /* CONFIG_NET_RX_BUSY_POLL */ -#ifdef CONFIG_RFS_ACCEL struct mlx4_en_filter {
@@ -1561,8 +1533,6 @@ int mlx4_en_start_port(struct net_device *dev)for (i =0 ; i < priv->rx_ring_num; i++) { cq = priv->rx_cq[i]; -mlx4_en_cq_init_lock (cq); - err =mlx4_en_init_affinity_hint (priv, i);if (err) {en_err (priv,"Failed preparing IRQ affinity hint\n" );
@@ -1859,13 +1829,6 @@ void mlx4_en_stop_port(struct net_device *dev, int detach)for (i =0 ; i < priv->rx_ring_num; i++) {struct mlx4_en_cq *cq = priv->rx_cq[i]; -local_bh_disable (); -while (!mlx4_en_cq_lock_napi (cq)) { -pr_info ("CQ %d locked\n" , i); -mdelay (1 ); - } -local_bh_enable (); -napi_synchronize (&cq->napi);mlx4_en_deactivate_rx_ring (priv, priv->rx_ring[i]);mlx4_en_deactivate_cq (priv, cq);
@@ -2504,9 +2467,6 @@ static const struct net_device_ops mlx4_netdev_ops = {#ifdef CONFIG_RFS_ACCEL .ndo_rx_flow_steer = mlx4_en_filter_rfs, #endif -#ifdef CONFIG_NET_RX_BUSY_POLL - .ndo_busy_poll = mlx4_en_low_latency_recv, -#endif .ndo_get_phys_port_id = mlx4_en_get_phys_port_id, #ifdef CONFIG_MLX4_EN_VXLAN .ndo_add_vxlan_port = mlx4_en_add_vxlan_port,
drivers/net/ethernet/mellanox/mlx4/en_rx.c +2 -13
@@ -873,10 +873,8 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud* - TCP/IP (v4) * - without IP options * - not an IP fragment -* - no LLS polling in progress */ -if (!mlx4_en_cq_busy_polling (cq) && - (dev->features &NETIF_F_GRO )) { +if (dev->features &NETIF_F_GRO ) {struct sk_buff *gro_skb =napi_get_frags (&cq->napi);if (!gro_skb) goto next;
@@ -992,11 +990,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int budskb_mark_napi_id (skb, &cq->napi); -if (!mlx4_en_cq_busy_polling (cq)) -napi_gro_receive (&cq->napi, skb); -else -netif_receive_skb (skb); - +napi_gro_receive (&cq->napi, skb); next:for (nr =0 ; nr < priv->num_frags; nr++)mlx4_en_free_frag (priv, frags, nr);
@@ -1038,13 +1032,8 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)struct mlx4_en_priv *priv =netdev_priv (dev);int done; -if (!mlx4_en_cq_lock_napi (cq)) -return budget; - done =mlx4_en_process_rx_cq (dev, cq, budget); -mlx4_en_cq_unlock_napi (cq); -/* If we used up all the quota - we're probably not done yet... */ if (done == budget) {const struct cpumask *aff;
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +0 -128
146 lines not on this page · raw message
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 10/14 net: move skb_mark_napi_id() into core networking stack
In reply to Eric DumazetWe would like to automatically provide busy polling support to all NAPI drivers, without them having to implement anything.
skb_mark_napi_id() can be called from napi_gro_receive() and napi_get_frags().
Few drivers are still calling skb_mark_napi_id() because they use netif_receive_skb(). They should eventually call napi_gro_receive() instead. I will leave this to drivers maintainers.
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 1 - drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 -- drivers/net/ethernet/chelsio/cxgb4/sge.c | 1 - drivers/net/ethernet/emulex/benet/be_main.c | 1 - drivers/net/ethernet/intel/i40e/i40e_txrx.c | 1 - drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 1 - drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 3 --- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 1 - drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 2 +- drivers/net/ethernet/sfc/rx.c | 1 - drivers/net/virtio_net.c | 2 -- net/core/dev.c | 2 ++ 13 files changed, 4 insertions(+), 16 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +0 -1
@@ -2024,7 +2024,6 @@ read_again: skb->dev = netdev; skb->protocol =eth_type_trans (skb, netdev);skb_record_rx_queue (skb, channel->queue_index); -skb_mark_napi_id (skb, napi);napi_gro_receive (napi, skb);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +0 -2
@@ -1094,8 +1094,6 @@ reuse_rx:__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021Q ),le16_to_cpu (cqe_fp->vlan_tag)); -skb_mark_napi_id (skb, &fp->napi); -napi_gro_receive (&fp->napi, skb); next_rx: rx_buf->data =NULL ;
drivers/net/ethernet/chelsio/cxgb4/sge.c +0 -1
@@ -1864,7 +1864,6 @@ static void do_gro(struct sge_eth_rxq *rxq, const struct pkt_gl *gl, skb->truesize += skb->data_len; skb->ip_summed =CHECKSUM_UNNECESSARY ;skb_record_rx_queue (skb, rxq->rspq.idx); -skb_mark_napi_id (skb, &rxq->rspq.napi); pi =netdev_priv (skb->dev);if (pi->rxtstamp) cxgb4_sgetim_to_hwtstamp(adapter, skb_hwtstamps(skb),
drivers/net/ethernet/emulex/benet/be_main.c +0 -1
@@ -2184,7 +2184,6 @@ static void be_rx_compl_process_gro(struct be_rx_obj *rxo,skb_set_hash (skb, rxcp->rss_hash,PKT_HASH_TYPE_L3 ); skb->csum_level = rxcp->tunneled; -skb_mark_napi_id (skb, napi);if (rxcp->vlanf)__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021Q ), rxcp->vlan_tag);
drivers/net/ethernet/intel/i40e/i40e_txrx.c +0 -1
@@ -1632,7 +1632,6 @@ static int i40e_clean_rx_irq_ps(struct i40e_ring *rx_ring, int budget) continue; }#endif -skb_mark_napi_id (skb, &rx_ring->q_vector->napi);i40e_receive_skb (rx_ring, skb, vlan_tag); rx_desc->wb.qword1.status_error_len =0 ;
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +0 -1
@@ -1090,7 +1090,6 @@ static int i40e_clean_rx_irq_ps(struct i40e_ring *rx_ring, int budget) continue; }#endif -skb_mark_napi_id (skb, &rx_ring->q_vector->napi);i40e_receive_skb (rx_ring, skb, vlan_tag); rx_desc->wb.qword1.status_error_len =0 ;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -1
@@ -1659,6 +1659,7 @@ static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring,static void ixgbe_rx_skb (struct ixgbe_q_vector *q_vector,struct sk_buff *skb) { +skb_mark_napi_id (skb, &q_vector->napi);if (ixgbe_qv_busy_polling (q_vector))netif_receive_skb (skb);else
@@ -2123,7 +2124,6 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, }#endif /* IXGBE_FCOE */ -skb_mark_napi_id (skb, &q_vector->napi);ixgbe_rx_skb (q_vector, skb);/* update budget accounting */
drivers/net/ethernet/mellanox/mlx4/en_rx.c +0 -3
@@ -925,7 +925,6 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud PKT_HASH_TYPE_L3);skb_record_rx_queue (gro_skb, cq->ring); -skb_mark_napi_id (gro_skb, &cq->napi);if (ring->hwtstamp_rx_filter ==HWTSTAMP_FILTER_ALL ) { timestamp =mlx4_en_get_cqe_ts (cqe);
@@ -988,8 +987,6 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud timestamp); } -skb_mark_napi_id (skb, &cq->napi); -napi_gro_receive (&cq->napi, skb); next:for (nr =0 ; nr < priv->num_frags; nr++)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +0 -1
@@ -243,7 +243,6 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget) wqe =mlx5_wq_ll_get_wqe (&rq->wq, wqe_counter); skb = rq->skb[wqe_counter];prefetch (skb->data); -skb_mark_napi_id (skb, cq->napi); rq->skb[wqe_counter] =NULL ; dma_unmap_single(rq->pdev,
drivers/net/ethernet/myricom/myri10ge/myri10ge.c +1 -1
@@ -1488,7 +1488,6 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum) }myri10ge_vlan_rx (mgp->dev, va, skb);skb_record_rx_queue (skb, ss - &mgp->ss[0 ]); -skb_mark_napi_id (skb, &ss->napi);if (polling) {int hlen;
@@ -1506,6 +1505,7 @@ myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum) skb->data_len -= hlen; skb->tail += hlen; skb->protocol =eth_type_trans (skb, dev); +skb_mark_napi_id (skb, &ss->napi);netif_receive_skb (skb); }else
drivers/net/ethernet/sfc/rx.c +0 -1
@@ -463,7 +463,6 @@ efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf,skb_record_rx_queue (skb, channel->rx_queue.core_index); -skb_mark_napi_id (skb, &channel->napi_str); gro_result =napi_gro_frags (napi);if (gro_result !=GRO_DROP ) channel->irq_mod_score +=2 ;
drivers/net/virtio_net.c +0 -2
@@ -516,8 +516,6 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,skb_shinfo (skb)->gso_segs =0 ; } -skb_mark_napi_id (skb, &rq->napi); -napi_gro_receive (&rq->napi, skb);return ;
net/core/dev.c +2 -0
@@ -4356,6 +4356,7 @@ static gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb)gro_result_t napi_gro_receive (struct napi_struct *napi,struct sk_buff *skb) { +skb_mark_napi_id (skb, napi);trace_napi_gro_receive_entry (skb);skb_gro_reset_offset (skb);
@@ -4390,6 +4391,7 @@ struct sk_buff *napi_get_frags(struct napi_struct *napi)if (!skb) { skb =napi_alloc_skb (napi,GRO_MAX_HEAD ); napi->skb = skb; +skb_mark_napi_id (skb, napi); }return skb; }
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 11/14 net: add netif_tx_napi_add()
In reply to Eric Dumazetnetif_tx_napi_add() is a variant of netif_napi_add()
It should be used by drivers that use a napi structure to exclusively poll TX.
We do not want to add this kind of napi in napi_hash[] in following patches, adding generic busy polling to all NAPI drivers.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++-- .../net/ethernet/freescale/fs_enet/fs_enet-main.c | 2 +- drivers/net/ethernet/freescale/gianfar.c | 4 ++-- drivers/net/ethernet/mellanox/mlx4/en_cq.c | 4 ++-- drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 4 ++-- drivers/net/ethernet/rocker/rocker.c | 2 +- drivers/net/ethernet/ti/cpsw.c | 2 +- drivers/net/ethernet/ti/netcp_core.c | 2 +- drivers/net/wireless/ath/wil6210/netdev.c | 2 +- include/linux/netdevice.h | 23 +++++++++++++++++++++- net/core/dev.c | 3 ++- 12 files changed, 38 insertions(+), 16 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +1 -1
@@ -1216,7 +1216,7 @@ static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,/* Initialize SW view of the ring */ spin_lock_init (&ring->lock); ring->priv = priv; -netif_napi_add (priv->netdev, &ring->napi, bcm_sysport_tx_poll,64 ); +netif_tx_napi_add (priv->netdev, &ring->napi, bcm_sysport_tx_poll,64 ); ring->index = index; ring->size = size; ring->alloc_size = ring->size;
drivers/net/ethernet/broadcom/genet/bcmgenet.c +2 -2
@@ -2041,11 +2041,11 @@ static void bcmgenet_init_tx_napi(struct bcmgenet_priv *priv)for (i =0 ; i < priv->hw_params->tx_queues; ++i) { ring = &priv->tx_rings[i]; -netif_napi_add (priv->dev, &ring->napi, bcmgenet_tx_poll,64 ); +netif_tx_napi_add (priv->dev, &ring->napi, bcmgenet_tx_poll,64 ); } ring = &priv->tx_rings[DESC_INDEX ]; -netif_napi_add (priv->dev, &ring->napi, bcmgenet_tx_poll,64 ); +netif_tx_napi_add (priv->dev, &ring->napi, bcmgenet_tx_poll,64 ); }static void bcmgenet_enable_tx_napi (struct bcmgenet_priv *priv)
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +1 -1
@@ -1050,7 +1050,7 @@ static int fs_enet_probe(struct platform_device *ofdev) ndev->netdev_ops = &fs_enet_netdev_ops; ndev->watchdog_timeo =2 *HZ ;netif_napi_add (ndev, &fep->napi, fs_enet_rx_napi, fpi->napi_weight); -netif_napi_add (ndev, &fep->napi_tx, fs_enet_tx_napi,2 ); +netif_tx_napi_add (ndev, &fep->napi_tx, fs_enet_tx_napi,2 ); ndev->ethtool_ops = &fs_ethtool_ops;
drivers/net/ethernet/freescale/gianfar.c +2 -2
@@ -1347,12 +1347,12 @@ static int gfar_probe(struct platform_device *ofdev)if (priv->poll_mode ==GFAR_SQ_POLLING ) {netif_napi_add (dev, &priv->gfargrp[i].napi_rx, gfar_poll_rx_sq,GFAR_DEV_WEIGHT ); -netif_napi_add (dev, &priv->gfargrp[i].napi_tx, +netif_tx_napi_add (dev, &priv->gfargrp[i].napi_tx, gfar_poll_tx_sq,2 ); }else {netif_napi_add (dev, &priv->gfargrp[i].napi_rx, gfar_poll_rx,GFAR_DEV_WEIGHT ); -netif_napi_add (dev, &priv->gfargrp[i].napi_tx, +netif_tx_napi_add (dev, &priv->gfargrp[i].napi_tx, gfar_poll_tx,2 ); } }
drivers/net/ethernet/mellanox/mlx4/en_cq.c +2 -2
@@ -156,8 +156,8 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, cq->mcq.event = mlx4_en_cq_event;if (cq->is_tx) { -netif_napi_add (cq->dev, &cq->napi, mlx4_en_poll_tx_cq, -NAPI_POLL_WEIGHT ); +netif_tx_napi_add (cq->dev, &cq->napi, mlx4_en_poll_tx_cq, +NAPI_POLL_WEIGHT ); }else {netif_napi_add (cq->dev, &cq->napi, mlx4_en_poll_rx_cq,64 );napi_hash_add (&cq->napi);
drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c +2 -2
@@ -1604,7 +1604,7 @@ int qlcnic_82xx_napi_add(struct qlcnic_adapter *adapter,if (qlcnic_check_multi_tx (adapter) && !adapter->ahw->diag_test) {for (ring =0 ; ring < adapter->drv_tx_rings; ring++) { tx_ring = &adapter->tx_ring[ring]; -netif_napi_add (netdev, &tx_ring->napi, qlcnic_tx_poll, +netif_tx_napi_add (netdev, &tx_ring->napi, qlcnic_tx_poll,NAPI_POLL_WEIGHT ); } }
@@ -2135,7 +2135,7 @@ int qlcnic_83xx_napi_add(struct qlcnic_adapter *adapter, !(adapter->flags & QLCNIC_TX_INTR_SHARED)) {for (ring =0 ; ring < adapter->drv_tx_rings; ring++) { tx_ring = &adapter->tx_ring[ring]; -netif_napi_add (netdev, &tx_ring->napi, +netif_tx_napi_add (netdev, &tx_ring->napi, qlcnic_83xx_msix_tx_poll,NAPI_POLL_WEIGHT ); }
drivers/net/ethernet/rocker/rocker.c +1 -1
@@ -4998,7 +4998,7 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number) dev->netdev_ops = &rocker_port_netdev_ops; dev->ethtool_ops = &rocker_port_ethtool_ops; dev->switchdev_ops = &rocker_port_switchdev_ops; -netif_napi_add (dev, &rocker_port->napi_tx, rocker_port_poll_tx, +netif_tx_napi_add (dev, &rocker_port->napi_tx, rocker_port_poll_tx,NAPI_POLL_WEIGHT );netif_napi_add (dev, &rocker_port->napi_rx, rocker_port_poll_rx,NAPI_POLL_WEIGHT );
drivers/net/ethernet/ti/cpsw.c +1 -1
@@ -2469,7 +2469,7 @@ static int cpsw_probe(struct platform_device *pdev) ndev->netdev_ops = &cpsw_netdev_ops; ndev->ethtool_ops = &cpsw_ethtool_ops;netif_napi_add (ndev, &priv->napi_rx, cpsw_rx_poll,CPSW_POLL_WEIGHT ); -netif_napi_add (ndev, &priv->napi_tx, cpsw_tx_poll,CPSW_POLL_WEIGHT ); +netif_tx_napi_add (ndev, &priv->napi_tx, cpsw_tx_poll,CPSW_POLL_WEIGHT );/* register the network device */ SET_NETDEV_DEV (ndev, &pdev->dev);
drivers/net/ethernet/ti/netcp_core.c +1 -1
@@ -1990,7 +1990,7 @@ static int netcp_create_interface(struct netcp_device *netcp_device,/* NAPI register */ netif_napi_add (ndev, &netcp->rx_napi, netcp_rx_poll,NETCP_NAPI_WEIGHT ); -netif_napi_add (ndev, &netcp->tx_napi, netcp_tx_poll,NETCP_NAPI_WEIGHT ); +netif_tx_napi_add (ndev, &netcp->tx_napi, netcp_tx_poll,NETCP_NAPI_WEIGHT );/* Register the network device */ ndev->dev_id =0 ;
drivers/net/wireless/ath/wil6210/netdev.c +1 -1
@@ -183,7 +183,7 @@ void *wil_if_alloc(struct device *dev)netif_napi_add (ndev, &wil->napi_rx, wil6210_netdev_poll_rx,WIL6210_NAPI_BUDGET ); -netif_napi_add (ndev, &wil->napi_tx, wil6210_netdev_poll_tx, +netif_tx_napi_add (ndev, &wil->napi_tx, wil6210_netdev_poll_tx,WIL6210_NAPI_BUDGET );netif_tx_stop_all_queues (ndev);
include/linux/netdevice.h +22 -1
@@ -326,7 +326,8 @@ enum {NAPI_STATE_SCHED ,/* Poll is scheduled */ NAPI_STATE_DISABLE ,/* Disable pending */ NAPI_STATE_NPSVC ,/* Netpoll - don't dequeue from poll_list */ - NAPI_STATE_HASHED, /* In NAPI hash */ +NAPI_STATE_HASHED ,/* In NAPI hash (busy polling possible) */ + NAPI_STATE_NO_BUSY_POLL,/* Do not add in napi_hash, no busy polling */ }; enum gro_result {
@@ -1939,6 +1940,26 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi, int (*poll)(struct napi_struct *, int), int weight);/** +* netif_tx_napi_add - initialize a napi context +* @dev: network device +* @napi: napi context +* @poll: polling function +* @weight: default weight +* +* This variant of netif_napi_add() should be used from drivers using NAPI +* to exclusively poll a TX queue. +* This will avoid we add it into napi_hash[], thus polluting this hash table. +*/ +static inline void netif_tx_napi_add (struct net_device *dev, +struct napi_struct *napi, +int (*poll)(struct napi_struct *,int ), +int weight) +{ +set_bit (NAPI_STATE_NO_BUSY_POLL , &napi->state); +netif_napi_add (dev, napi, poll, weight); +} + +/** * netif_napi_del - remove a napi context * @napi: napi context *
net/core/dev.c +2 -1
@@ -4737,7 +4737,8 @@ EXPORT_SYMBOL(sk_busy_loop);void napi_hash_add (struct napi_struct *napi) { -if (test_and_set_bit (NAPI_STATE_HASHED , &napi->state)) +if (test_bit (NAPI_STATE_NO_BUSY_POLL , &napi->state) || +test_and_set_bit (NAPI_STATE_HASHED , &napi->state))return ;spin_lock (&napi_hash_lock);
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 12/14 net: move napi_hash[] into read mostly section
In reply to Eric DumazetWe do not often add/delete a napi context.
Moving napi_hash[] into read mostly section avoids potential false sharing.
--- include/linux/hashtable.h | 4 ++++ net/core/dev.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
include/linux/hashtable.h +4 -0
@@ -16,6 +16,10 @@struct hlist_head name[1 << (bits)] = \ { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT } +#define DEFINE_READ_MOSTLY_HASHTABLE (name, bits) \ + struct hlist_head name[1 << (bits)] __read_mostly = \ + { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT } +#define DECLARE_HASHTABLE (name, bits) \ struct hlist_head name[1 << (bits)]
net/core/dev.c +1 -1
@@ -184,7 +184,7 @@ EXPORT_SYMBOL(dev_base_lock);static DEFINE_SPINLOCK (napi_hash_lock);static unsigned int napi_gen_id =NR_CPUS ; -static DEFINE_HASHTABLE(napi_hash, 8); +static DEFINE_READ_MOSTLY_HASHTABLE(napi_hash, 8);static seqcount_t devnet_rename_seq;
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 13/14 net: napi_hash_del() returns a boolean status
In reply to Eric Dumazetnapi_hash_del() will soon be used from both drivers (if they want) or core networking stack.
Callers are responsibles to ensure an RCU grace period is respected before freeing napi structure : napi_hash_del() can signal if this RCU grace period is needed or not.
--- include/linux/netdevice.h | 5 +++-- net/core/dev.c | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-)
include/linux/netdevice.h +3 -2
@@ -474,9 +474,10 @@ void napi_hash_add(struct napi_struct *napi);* @napi: napi context * * Warning: caller must observe rcu grace period -* before freeing memory containing @napi +* before freeing memory containing @napi, if +* this function returns true. */ -void napi_hash_del (struct napi_struct *napi); +bool napi_hash_del (struct napi_struct *napi);/** * napi_disable - prevent NAPI from scheduling
net/core/dev.c +7 -3
@@ -4760,14 +4760,18 @@ EXPORT_SYMBOL_GPL(napi_hash_add);/* Warning : caller is responsible to make sure rcu grace period * is respected before freeing memory containing @napi */ -void napi_hash_del (struct napi_struct *napi) +bool napi_hash_del (struct napi_struct *napi) { +bool rcu_sync_needed = false; +spin_lock (&napi_hash_lock); -if (test_and_clear_bit (NAPI_STATE_HASHED , &napi->state)) +if (test_and_clear_bit (NAPI_STATE_HASHED , &napi->state)) { + rcu_sync_needed = true;hlist_del_rcu (&napi->napi_hash_node); - + }spin_unlock (&napi_hash_lock); +return rcu_sync_needed; }EXPORT_SYMBOL_GPL (napi_hash_del);
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 14/14 net: provide generic busy polling to all NAPI drivers
In reply to Eric DumazetNAPI drivers no longer need to observe a particular protocol to benefit from busy polling (CONFIG_NET_RX_BUSY_POLL=y)
napi_hash_add() and napi_hash_del() are automatically called from core networking stack, respectively from netif_napi_add() and netif_napi_del()
This patch depends on free_netdev() and netif_napi_del() being called from process context, which seems to be the norm.
Drivers might still prefer to call napi_hash_del() on their own, since they might combine all the rcu grace periods into a single one, knowing their NAPI structures lifetime, while core networking stack has no idea of a possible combining.
Once this patch proves to not bring serious regressions, we will cleanup drivers to either remove napi_hash_del() or provide appropriate rcu grace periods combining.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 2 -- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 -- drivers/net/ethernet/chelsio/cxgb4/sge.c | 1 - drivers/net/ethernet/cisco/enic/enic_main.c | 2 -- drivers/net/ethernet/emulex/benet/be_main.c | 1 - drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 1 - drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 3 --- drivers/net/ethernet/mellanox/mlx4/en_cq.c | 6 ++---- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 - drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 1 - drivers/net/ethernet/sfc/efx.c | 1 - drivers/net/virtio_net.c | 1 - include/linux/netdevice.h | 7 +++++++ net/core/dev.c | 7 +++++++ 14 files changed, 16 insertions(+), 20 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +0 -2
@@ -46,7 +46,6 @@ static void bnx2x_add_all_napi_cnic(struct bnx2x *bp)for_each_rx_queue_cnic (bp, i) {netif_napi_add (bp->dev, &bnx2x_fp (bp, i, napi), bnx2x_poll,NAPI_POLL_WEIGHT ); -napi_hash_add (&bnx2x_fp (bp, i, napi)); } }
@@ -58,7 +57,6 @@ static void bnx2x_add_all_napi(struct bnx2x *bp)for_each_eth_queue (bp, i) {netif_napi_add (bp->dev, &bnx2x_fp (bp, i, napi), bnx2x_poll,NAPI_POLL_WEIGHT ); -napi_hash_add (&bnx2x_fp (bp, i, napi)); } }
drivers/net/ethernet/broadcom/bnxt/bnxt.c +0 -2
@@ -4227,12 +4227,10 @@ static void bnxt_init_napi(struct bnxt *bp) bnapi = bp->bnapi[i];netif_napi_add (bp->dev, &bnapi->napi, bnxt_poll,64 ); -napi_hash_add (&bnapi->napi); } }else { bnapi = bp->bnapi[0 ];netif_napi_add (bp->dev, &bnapi->napi, bnxt_poll,64 ); -napi_hash_add (&bnapi->napi); } }
drivers/net/ethernet/chelsio/cxgb4/sge.c +0 -1
@@ -2527,7 +2527,6 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq, goto err;netif_napi_add (dev, &iq->napi, napi_rx_handler,64 ); -napi_hash_add (&iq->napi); iq->cur_desc = iq->desc; iq->cidx =0 ; iq->gen =1 ;
drivers/net/ethernet/cisco/enic/enic_main.c +0 -2
@@ -2458,13 +2458,11 @@ static int enic_dev_init(struct enic *enic)switch (vnic_dev_get_intr_mode (enic->vdev)) {default :netif_napi_add (netdev, &enic->napi[0 ], enic_poll,64 ); -napi_hash_add (&enic->napi[0 ]);break ;case VNIC_DEV_INTR_MODE_MSIX :for (i =0 ; i < enic->rq_count; i++) {netif_napi_add (netdev, &enic->napi[i], enic_poll_msix_rq,NAPI_POLL_WEIGHT ); -napi_hash_add (&enic->napi[i]); }for (i =0 ; i < enic->wq_count; i++) netif_napi_add(netdev, &enic->napi[enic_cq_wq(enic, i)],
drivers/net/ethernet/emulex/benet/be_main.c +0 -1
@@ -2630,7 +2630,6 @@ static int be_evt_queues_create(struct be_adapter *adapter) eqo->affinity_mask);netif_napi_add (adapter->netdev, &eqo->napi, be_poll,BE_NAPI_WEIGHT ); -napi_hash_add (&eqo->napi); }return 0 ; }
drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c +0 -1
@@ -844,7 +844,6 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,/* initialize NAPI */ netif_napi_add (adapter->netdev, &q_vector->napi, ixgbe_poll,64 ); -napi_hash_add (&q_vector->napi);#ifdef CONFIG_NET_RX_BUSY_POLL /* initialize busy poll */
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +0 -3
@@ -2483,9 +2483,6 @@ static int ixgbevf_alloc_q_vectors(struct ixgbevf_adapter *adapter) q_vector->v_idx = q_idx;netif_napi_add (adapter->netdev, &q_vector->napi, ixgbevf_poll,64 ); -#ifdef CONFIG_NET_RX_BUSY_POLL -napi_hash_add (&q_vector->napi); -#endif adapter->q_vector[q_idx] = q_vector; }
drivers/net/ethernet/mellanox/mlx4/en_cq.c +2 -4
@@ -155,13 +155,11 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, cq->mcq.comp = cq->is_tx ? mlx4_en_tx_irq : mlx4_en_rx_irq; cq->mcq.event = mlx4_en_cq_event; -if (cq->is_tx) { +if (cq->is_tx)netif_tx_napi_add (cq->dev, &cq->napi, mlx4_en_poll_tx_cq,NAPI_POLL_WEIGHT ); - }else { +else netif_napi_add (cq->dev, &cq->napi, mlx4_en_poll_rx_cq,64 ); -napi_hash_add (&cq->napi); - }napi_enable (&cq->napi);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +0 -1
@@ -982,7 +982,6 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,mlx5e_build_channeltc_to_txq_map (priv, ix);netif_napi_add (netdev, &c->napi, mlx5e_napi_poll,64 ); -napi_hash_add (&c->napi); err =mlx5e_open_tx_cqs (c, cparam);if (err)
drivers/net/ethernet/myricom/myri10ge/myri10ge.c +0 -1
@@ -3814,7 +3814,6 @@ static int myri10ge_alloc_slices(struct myri10ge_priv *mgp) ss->dev = mgp->dev;netif_napi_add (ss->dev, &ss->napi, myri10ge_poll, myri10ge_napi_weight); -napi_hash_add (&ss->napi); }return 0 ; abort:
drivers/net/ethernet/sfc/efx.c +0 -1
@@ -2059,7 +2059,6 @@ static void efx_init_napi_channel(struct efx_channel *channel) channel->napi_dev = efx->net_dev;netif_napi_add (channel->napi_dev, &channel->napi_str, efx_poll, napi_weight); -napi_hash_add (&channel->napi_str);efx_channel_busy_poll_init (channel); }
drivers/net/virtio_net.c +0 -1
@@ -1610,7 +1610,6 @@ static int virtnet_alloc_queues(struct virtnet_info *vi) vi->rq[i].pages =NULL ;netif_napi_add (vi->dev, &vi->rq[i].napi, virtnet_poll, napi_weight); -napi_hash_add (&vi->rq[i].napi);sg_init_table (vi->rq[i].sg,ARRAY_SIZE (vi->rq[i].sg));ewma_pkt_len_init (&vi->rq[i].mrg_avg_pkt_len);
include/linux/netdevice.h +7 -0
@@ -466,6 +466,9 @@ static inline void napi_complete(struct napi_struct *n)* @napi: napi context * * generate a new napi_id and store a @napi under it in napi_hash +* Used for busy polling (CONFIG_NET_RX_BUSY_POLL) +* Note: This is normally automatically done from netif_napi_add(), +* so might disappear in a future linux version. */ void napi_hash_add (struct napi_struct *napi);
@@ -476,6 +479,10 @@ void napi_hash_add(struct napi_struct *napi);* Warning: caller must observe rcu grace period * before freeing memory containing @napi, if * this function returns true. +* Note: core networking stack automatically calls it +* from netif_napi_del() +* Drivers might want to call this helper to combine all +* the needed rcu grace periods into a single one. */ bool napi_hash_del (struct napi_struct *napi);
net/core/dev.c +7 -0
@@ -4807,6 +4807,7 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi, napi->poll_owner =-1 ;#endif set_bit (NAPI_STATE_SCHED , &napi->state); +napi_hash_add (napi); }EXPORT_SYMBOL (netif_napi_add);
@@ -4826,8 +4827,12 @@ void napi_disable(struct napi_struct *n) }EXPORT_SYMBOL (napi_disable); +/* Must be called in process context */ void netif_napi_del (struct napi_struct *napi) { +might_sleep (); +if (napi_hash_del (napi)) +synchronize_net ();list_del_init (&napi->dev_list);napi_free_frags (napi);
@@ -7227,11 +7232,13 @@ EXPORT_SYMBOL(alloc_netdev_mqs);* This function does the last stage of destroying an allocated device * interface. The reference to the device object is released. * If this is the last reference then it will be freed. +* Must be called in process context. */ void free_netdev (struct net_device *dev) {struct napi_struct *p, *n; +might_sleep ();netif_free_tx_queues (dev);#ifdef CONFIG_SYSFS kvfree (dev->_rx);
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
From: Eric Dumazet <[email protected]>
Date: Wed, 18 Nov 2015 06:30:49 -0800
Quoted 14 lines
This patch series extends busy polling range to tunnels devices, and adds busy polling generic support to all NAPI drivers.
No need to provide
ndo_busy_poll()method and extra synchronization betweenndo_busy_poll()and normalnapi->poll()method. This was proven very difficult and bug prone.mlx5 driver is changed to support busy polling using this new method, and a second mlx5 patch adds
napi_complete_done()support and proper SNMP accounting.bnx2x and mlx4 drivers are converted to new infrastructure, reducing kernel bloat and improving performance.
Quoted 7 lines
Latest patch, adding generic support, adds a new requirement :
-free_netdev() and
netif_napi_del()must be called from process context.Since this might not be the case in some drivers, we might have to either : fix the non conformant drivers (by disabling busy polling on them) or revert this last patch.
I like this series a lot, and hope we can fix any fallout quickly and painlessly.
Applied to net-next.
Quoted 5 lines · David Miller
From: Eric Dumazet <[email protected]>
Date: Wed, 18 Nov 2015 06:30:49 -0800I like this series a lot, and hope we can fix any fallout quickly and painlessly. Applied to net-next.
Hi Dave,
If you don't mind, next time we would be happy to get > 36h from the initial post till patches
to the mlx4/5 drivers are applied, specifically when we have new maintainers that have to catch
up, I know they should be learning to run fast on such cases... we also didn't see a note from you
that the net-next / 4.5 window is open, so people here were under wrong impression that that race
haven't been started.. anyway, could you please push that to your public git?
Or.
Quoted 7 lines · David Miller
ers (by disabling busy polling on them)
Quoted 1 line
or revert this last patch.
I like this series a lot, and hope we can fix any fallout quickly and painlessly.
Applied to net-next.
Thanks David. Could you push your tree so that we can start the testing phase on more drivers ?
Thanks !
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Thu, 19 Nov 2015 08:53:52 -0800
Quoted 11 lines · David Miller
Quoted 7 lines
ers (by disabling busy polling on them)
Quoted 1 line
or revert this last patch.
I like this series a lot, and hope we can fix any fallout quickly and painlessly.
Applied to net-next.
Thanks David. Could you push your tree so that we can start the testing phase on more drivers ?
Done :)