[PATCH net-next] net: remove support for per driver ndo_busy_poll()

Subsystems: networking drivers, networking [general], the rest

STALE3497d

6 messages, 3 authors, 2017-02-03 · open the first message on its own page

[PATCH net-next] net: remove support for per driver ndo_busy_poll()

From: Eric Dumazet <hidden>
Date: 2017-02-03 02:43:31

From: Eric Dumazet <edumazet@google.com>

We added generic support for busy polling in NAPI layer in linux-4.5

No network driver uses ndo_busy_poll() anymore, we can get rid
of the pointer in struct net_device_ops, and its use in sk_busy_loop()

Saves NETIF_F_BUSY_POLL features bit.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---

This patch makes sense only if all prior ones are merged.

Thanks !

 include/linux/netdev_features.h |    2 --
 include/linux/netdevice.h       |    3 ---
 net/core/dev.c                  |   15 ---------------
 net/core/ethtool.c              |    1 -
 4 files changed, 21 deletions(-)
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 9c6c8ef2e9e704513cc4272b0a3ee2fec6809d46..9a0419594e842ca00a5ecfca53823b38bad207bb 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -71,7 +71,6 @@ enum {
 	NETIF_F_HW_VLAN_STAG_RX_BIT,	/* Receive VLAN STAG HW acceleration */
 	NETIF_F_HW_VLAN_STAG_FILTER_BIT,/* Receive filtering on VLAN STAGs */
 	NETIF_F_HW_L2FW_DOFFLOAD_BIT,	/* Allow L2 Forwarding in Hardware */
-	NETIF_F_BUSY_POLL_BIT,		/* Busy poll */
 
 	NETIF_F_HW_TC_BIT,		/* Offload TC infrastructure */
 
@@ -134,7 +133,6 @@ enum {
 #define NETIF_F_HW_VLAN_STAG_RX	__NETIF_F(HW_VLAN_STAG_RX)
 #define NETIF_F_HW_VLAN_STAG_TX	__NETIF_F(HW_VLAN_STAG_TX)
 #define NETIF_F_HW_L2FW_DOFFLOAD	__NETIF_F(HW_L2FW_DOFFLOAD)
-#define NETIF_F_BUSY_POLL	__NETIF_F(BUSY_POLL)
 #define NETIF_F_HW_TC		__NETIF_F(HW_TC)
 
 #define for_each_netdev_feature(mask_addr, bit)	\
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f3878fbe7786854c2028055cf6d0a52a20762d6e..6f18b509fb2f473029561d85646713c149df49ac 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1185,9 +1185,6 @@ struct net_device_ops {
 						     struct netpoll_info *info);
 	void			(*ndo_netpoll_cleanup)(struct net_device *dev);
 #endif
-#ifdef CONFIG_NET_RX_BUSY_POLL
-	int			(*ndo_busy_poll)(struct napi_struct *dev);
-#endif
 	int			(*ndo_set_vf_mac)(struct net_device *dev,
 						  int queue, u8 *mac);
 	int			(*ndo_set_vf_vlan)(struct net_device *dev,
diff --git a/net/core/dev.c b/net/core/dev.c
index 727b6fda0e8c6497ee42dc6d3065e326e9192c21..4cde8bfb9bab449b83890192a7e28a423b319e23 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4978,7 +4978,6 @@ bool sk_busy_loop(struct sock *sk, int nonblock)
 {
 	unsigned long end_time = !nonblock ? sk_busy_loop_end_time(sk) : 0;
 	int (*napi_poll)(struct napi_struct *napi, int budget);
-	int (*busy_poll)(struct napi_struct *dev);
 	void *have_poll_lock = NULL;
 	struct napi_struct *napi;
 	int rc;
@@ -4993,17 +4992,10 @@ bool sk_busy_loop(struct sock *sk, int nonblock)
 	if (!napi)
 		goto out;
 
-	/* Note: ndo_busy_poll method is optional in linux-4.5 */
-	busy_poll = napi->dev->netdev_ops->ndo_busy_poll;
-
 	preempt_disable();
 	for (;;) {
 		rc = 0;
 		local_bh_disable();
-		if (busy_poll) {
-			rc = busy_poll(napi);
-			goto count;
-		}
 		if (!napi_poll) {
 			unsigned long val = READ_ONCE(napi->state);
 
@@ -6956,13 +6948,6 @@ static netdev_features_t netdev_fix_features(struct net_device *dev,
 		features &= ~dev->gso_partial_features;
 	}
 
-#ifdef CONFIG_NET_RX_BUSY_POLL
-	if (dev->netdev_ops->ndo_busy_poll)
-		features |= NETIF_F_BUSY_POLL;
-	else
-#endif
-		features &= ~NETIF_F_BUSY_POLL;
-
 	return features;
 }
 
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 6b3eee0834a0663d3c48ae42a34e3bdd032fa5f9..d5f412b3093d4b3ccef40d4808bedf353f483594 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -102,7 +102,6 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
 	[NETIF_F_RXFCS_BIT] =            "rx-fcs",
 	[NETIF_F_RXALL_BIT] =            "rx-all",
 	[NETIF_F_HW_L2FW_DOFFLOAD_BIT] = "l2-fwd-offload",
-	[NETIF_F_BUSY_POLL_BIT] =        "busy-poll",
 	[NETIF_F_HW_TC_BIT] =		 "hw-tc-offload",
 };
 

Re: [PATCH net-next] net: remove support for per driver ndo_busy_poll()

From: kbuild test robot <hidden>
Date: 2017-02-03 03:17:07

Hi Eric,

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Eric-Dumazet/net-remove-support-for-per-driver-ndo_busy_poll/20170203-104846
config: x86_64-rhel (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):
quoted
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:3982:2: error: unknown field 'ndo_busy_poll' specified in initializer
     .ndo_busy_poll  = ixgbevf_busy_poll_recv,
     ^
quoted
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:3982:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .ndo_busy_poll  = ixgbevf_busy_poll_recv,
                       ^~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c:3982:20: note: (near initialization for 'ixgbevf_netdev_ops.ndo_poll_controller')
   cc1: some warnings being treated as errors
--
quoted
drivers/net/ethernet/sfc/efx.c:2406:2: error: unknown field 'ndo_busy_poll' specified in initializer
     .ndo_busy_poll  = efx_busy_poll,
     ^
quoted
drivers/net/ethernet/sfc/efx.c:2406:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .ndo_busy_poll  = efx_busy_poll,
                       ^~~~~~~~~~~~~
   drivers/net/ethernet/sfc/efx.c:2406:20: note: (near initialization for 'efx_netdev_ops.ndo_fcoe_enable')
   cc1: some warnings being treated as errors

vim +/ndo_busy_poll +3982 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

c12db769 drivers/net/ixgbevf/ixgbevf_main.c                Stephen Hemminger 2011-06-09  3976  	.ndo_set_mac_address	= ixgbevf_set_mac,
c12db769 drivers/net/ixgbevf/ixgbevf_main.c                Stephen Hemminger 2011-06-09  3977  	.ndo_change_mtu		= ixgbevf_change_mtu,
c12db769 drivers/net/ixgbevf/ixgbevf_main.c                Stephen Hemminger 2011-06-09  3978  	.ndo_tx_timeout		= ixgbevf_tx_timeout,
c12db769 drivers/net/ixgbevf/ixgbevf_main.c                Stephen Hemminger 2011-06-09  3979  	.ndo_vlan_rx_add_vid	= ixgbevf_vlan_rx_add_vid,
c12db769 drivers/net/ixgbevf/ixgbevf_main.c                Stephen Hemminger 2011-06-09  3980  	.ndo_vlan_rx_kill_vid	= ixgbevf_vlan_rx_kill_vid,
c777cdfa drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c Jacob Keller      2013-09-21  3981  #ifdef CONFIG_NET_RX_BUSY_POLL
c777cdfa drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c Jacob Keller      2013-09-21 @3982  	.ndo_busy_poll		= ixgbevf_busy_poll_recv,
c777cdfa drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c Jacob Keller      2013-09-21  3983  #endif
688ff32d drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c Emil Tantilov     2014-11-08  3984  #ifdef CONFIG_NET_POLL_CONTROLLER
688ff32d drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c Emil Tantilov     2014-11-08  3985  	.ndo_poll_controller	= ixgbevf_netpoll,

:::::: The code at line 3982 was first introduced by commit
:::::: c777cdfa4e69548f45078165d17828dd6711120f ixgbevf: implement CONFIG_NET_RX_BUSY_POLL

:::::: TO: Jacob Keller [off-list ref]
:::::: CC: Jeff Kirsher [off-list ref]

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Re: [PATCH net-next] net: remove support for per driver ndo_busy_poll()

From: David Miller <davem@davemloft.net>
Date: 2017-02-03 22:18:22

From: Eric Dumazet <redacted>
Date: Thu, 02 Feb 2017 18:43:28 -0800
From: Eric Dumazet <edumazet@google.com>

We added generic support for busy polling in NAPI layer in linux-4.5

No network driver uses ndo_busy_poll() anymore, we can get rid
of the pointer in struct net_device_ops, and its use in sk_busy_loop()

Saves NETIF_F_BUSY_POLL features bit.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied.

Re: [PATCH net-next] net: remove support for per driver ndo_busy_poll()

From: David Miller <davem@davemloft.net>
Date: 2017-02-03 22:28:55

From: David Miller <davem@davemloft.net>
Date: Fri, 03 Feb 2017 17:18:20 -0500 (EST)
From: Eric Dumazet <redacted>
Date: Thu, 02 Feb 2017 18:43:28 -0800
quoted
From: Eric Dumazet <edumazet@google.com>

We added generic support for busy polling in NAPI layer in linux-4.5

No network driver uses ndo_busy_poll() anymore, we can get rid
of the pointer in struct net_device_ops, and its use in sk_busy_loop()

Saves NETIF_F_BUSY_POLL features bit.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied.
Actually, one more driver needs converting, "enic".

I did a quick and dirty conversion:

====================
From 7a655c6324a8968ea2f027bf3660c87c42ac3de4 Mon Sep 17 00:00:00 2001
From: "David S. Miller" <davem@davemloft.net>
Date: Fri, 3 Feb 2017 17:28:21 -0500
Subject: [PATCH] enic: Remove local ndo_busy_poll() implementation.

We do polling generically these days.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/ethernet/cisco/enic/enic_main.c | 66 ++----------------------
 drivers/net/ethernet/cisco/enic/vnic_rq.h   | 78 -----------------------------
 2 files changed, 5 insertions(+), 139 deletions(-)
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 91e42be..c009f6d 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -43,10 +43,8 @@
 #ifdef CONFIG_RFS_ACCEL
 #include <linux/cpu_rmap.h>
 #endif
-#ifdef CONFIG_NET_RX_BUSY_POLL
-#include <net/busy_poll.h>
-#endif
 #include <linux/crash_dump.h>
+#include <net/busy_poll.h>
 
 #include "cq_enet_desc.h"
 #include "vnic_dev.h"
@@ -1191,8 +1189,7 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
 			__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci);
 
 		skb_mark_napi_id(skb, &enic->napi[rq->index]);
-		if (enic_poll_busy_polling(rq) ||
-		    !(netdev->features & NETIF_F_GRO))
+		if (!(netdev->features & NETIF_F_GRO))
 			netif_receive_skb(skb);
 		else
 			napi_gro_receive(&enic->napi[q_number], skb);
@@ -1296,15 +1293,6 @@ static int enic_poll(struct napi_struct *napi, int budget)
 	wq_work_done = vnic_cq_service(&enic->cq[cq_wq], wq_work_to_do,
 				       enic_wq_service, NULL);
 
-	if (!enic_poll_lock_napi(&enic->rq[cq_rq])) {
-		if (wq_work_done > 0)
-			vnic_intr_return_credits(&enic->intr[intr],
-						 wq_work_done,
-						 0 /* dont unmask intr */,
-						 0 /* dont reset intr timer */);
-		return budget;
-	}
-
 	if (budget > 0)
 		rq_work_done = vnic_cq_service(&enic->cq[cq_rq],
 			rq_work_to_do, enic_rq_service, NULL);
@@ -1323,7 +1311,6 @@ static int enic_poll(struct napi_struct *napi, int budget)
 			0 /* don't reset intr timer */);
 
 	err = vnic_rq_fill(&enic->rq[0], enic_rq_alloc_buf);
-	enic_poll_unlock_napi(&enic->rq[cq_rq], napi);
 
 	/* Buffer allocation failed. Stay in polling
 	 * mode so we can try to fill the ring again.
@@ -1390,34 +1377,6 @@ static void enic_set_rx_cpu_rmap(struct enic *enic)
 
 #endif /* CONFIG_RFS_ACCEL */
 
-#ifdef CONFIG_NET_RX_BUSY_POLL
-static int enic_busy_poll(struct napi_struct *napi)
-{
-	struct net_device *netdev = napi->dev;
-	struct enic *enic = netdev_priv(netdev);
-	unsigned int rq = (napi - &enic->napi[0]);
-	unsigned int cq = enic_cq_rq(enic, rq);
-	unsigned int intr = enic_msix_rq_intr(enic, rq);
-	unsigned int work_to_do = -1; /* clean all pkts possible */
-	unsigned int work_done;
-
-	if (!enic_poll_lock_poll(&enic->rq[rq]))
-		return LL_FLUSH_BUSY;
-	work_done = vnic_cq_service(&enic->cq[cq], work_to_do,
-				    enic_rq_service, NULL);
-
-	if (work_done > 0)
-		vnic_intr_return_credits(&enic->intr[intr],
-					 work_done, 0, 0);
-	vnic_rq_fill(&enic->rq[rq], enic_rq_alloc_buf);
-	if (enic->rx_coalesce_setting.use_adaptive_rx_coalesce)
-		enic_calc_int_moderation(enic, &enic->rq[rq]);
-	enic_poll_unlock_poll(&enic->rq[rq]);
-
-	return work_done;
-}
-#endif /* CONFIG_NET_RX_BUSY_POLL */
-
 static int enic_poll_msix_wq(struct napi_struct *napi, int budget)
 {
 	struct net_device *netdev = napi->dev;
@@ -1459,8 +1418,6 @@ static int enic_poll_msix_rq(struct napi_struct *napi, int budget)
 	unsigned int work_done = 0;
 	int err;
 
-	if (!enic_poll_lock_napi(&enic->rq[rq]))
-		return budget;
 	/* Service RQ
 	 */
 
@@ -1493,7 +1450,6 @@ static int enic_poll_msix_rq(struct napi_struct *napi, int budget)
 		 */
 		enic_calc_int_moderation(enic, &enic->rq[rq]);
 
-	enic_poll_unlock_napi(&enic->rq[rq], napi);
 	if (work_done < work_to_do) {
 
 		/* Some work done, but not enough to stay in polling,
@@ -1751,10 +1707,9 @@ static int enic_open(struct net_device *netdev)
 
 	netif_tx_wake_all_queues(netdev);
 
-	for (i = 0; i < enic->rq_count; i++) {
-		enic_busy_poll_init_lock(&enic->rq[i]);
+	for (i = 0; i < enic->rq_count; i++)
 		napi_enable(&enic->napi[i]);
-	}
+
 	if (vnic_dev_get_intr_mode(enic->vdev) == VNIC_DEV_INTR_MODE_MSIX)
 		for (i = 0; i < enic->wq_count; i++)
 			napi_enable(&enic->napi[enic_cq_wq(enic, i)]);
@@ -1798,13 +1753,8 @@ static int enic_stop(struct net_device *netdev)
 
 	enic_dev_disable(enic);
 
-	for (i = 0; i < enic->rq_count; i++) {
+	for (i = 0; i < enic->rq_count; i++)
 		napi_disable(&enic->napi[i]);
-		local_bh_disable();
-		while (!enic_poll_lock_napi(&enic->rq[i]))
-			mdelay(1);
-		local_bh_enable();
-	}
 
 	netif_carrier_off(netdev);
 	netif_tx_disable(netdev);
@@ -2335,9 +2285,6 @@ static const struct net_device_ops enic_netdev_dynamic_ops = {
 #ifdef CONFIG_RFS_ACCEL
 	.ndo_rx_flow_steer	= enic_rx_flow_steer,
 #endif
-#ifdef CONFIG_NET_RX_BUSY_POLL
-	.ndo_busy_poll		= enic_busy_poll,
-#endif
 };
 
 static const struct net_device_ops enic_netdev_ops = {
@@ -2361,9 +2308,6 @@ static const struct net_device_ops enic_netdev_ops = {
 #ifdef CONFIG_RFS_ACCEL
 	.ndo_rx_flow_steer	= enic_rx_flow_steer,
 #endif
-#ifdef CONFIG_NET_RX_BUSY_POLL
-	.ndo_busy_poll		= enic_busy_poll,
-#endif
 };
 
 static void enic_dev_deinit(struct enic *enic)
diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.h b/drivers/net/ethernet/cisco/enic/vnic_rq.h
index b9c82f1..0413103 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_rq.h
+++ b/drivers/net/ethernet/cisco/enic/vnic_rq.h
@@ -92,9 +92,6 @@ struct vnic_rq {
 	struct vnic_rq_buf *to_clean;
 	void *os_buf_head;
 	unsigned int pkts_outstanding;
-#ifdef CONFIG_NET_RX_BUSY_POLL
-	atomic_t bpoll_state;
-#endif /* CONFIG_NET_RX_BUSY_POLL */
 };
 
 static inline unsigned int vnic_rq_desc_avail(struct vnic_rq *rq)
@@ -207,81 +204,6 @@ static inline int vnic_rq_fill(struct vnic_rq *rq,
 	return 0;
 }
 
-#ifdef CONFIG_NET_RX_BUSY_POLL
-static inline void enic_busy_poll_init_lock(struct vnic_rq *rq)
-{
-	atomic_set(&rq->bpoll_state, ENIC_POLL_STATE_IDLE);
-}
-
-static inline bool enic_poll_lock_napi(struct vnic_rq *rq)
-{
-	int rc = atomic_cmpxchg(&rq->bpoll_state, ENIC_POLL_STATE_IDLE,
-				ENIC_POLL_STATE_NAPI);
-
-	return (rc == ENIC_POLL_STATE_IDLE);
-}
-
-static inline void enic_poll_unlock_napi(struct vnic_rq *rq,
-					 struct napi_struct *napi)
-{
-	WARN_ON(atomic_read(&rq->bpoll_state) != ENIC_POLL_STATE_NAPI);
-	napi_gro_flush(napi, false);
-	atomic_set(&rq->bpoll_state, ENIC_POLL_STATE_IDLE);
-}
-
-static inline bool enic_poll_lock_poll(struct vnic_rq *rq)
-{
-	int rc = atomic_cmpxchg(&rq->bpoll_state, ENIC_POLL_STATE_IDLE,
-				ENIC_POLL_STATE_POLL);
-
-	return (rc == ENIC_POLL_STATE_IDLE);
-}
-
-
-static inline void enic_poll_unlock_poll(struct vnic_rq *rq)
-{
-	WARN_ON(atomic_read(&rq->bpoll_state) != ENIC_POLL_STATE_POLL);
-	atomic_set(&rq->bpoll_state, ENIC_POLL_STATE_IDLE);
-}
-
-static inline bool enic_poll_busy_polling(struct vnic_rq *rq)
-{
-	return atomic_read(&rq->bpoll_state) & ENIC_POLL_STATE_POLL;
-}
-
-#else
-
-static inline void enic_busy_poll_init_lock(struct vnic_rq *rq)
-{
-}
-
-static inline bool enic_poll_lock_napi(struct vnic_rq *rq)
-{
-	return true;
-}
-
-static inline bool enic_poll_unlock_napi(struct vnic_rq *rq,
-					 struct napi_struct *napi)
-{
-	return false;
-}
-
-static inline bool enic_poll_lock_poll(struct vnic_rq *rq)
-{
-	return false;
-}
-
-static inline bool enic_poll_unlock_poll(struct vnic_rq *rq)
-{
-	return false;
-}
-
-static inline bool enic_poll_ll_polling(struct vnic_rq *rq)
-{
-	return false;
-}
-#endif /* CONFIG_NET_RX_BUSY_POLL */
-
 void vnic_rq_free(struct vnic_rq *rq);
 int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int index,
 	unsigned int desc_count, unsigned int desc_size);
-- 
2.4.11

Re: [PATCH net-next] net: remove support for per driver ndo_busy_poll()

From: Eric Dumazet <hidden>
Date: 2017-02-03 23:04:56

On Fri, 2017-02-03 at 17:18 -0500, David Miller wrote:
From: Eric Dumazet <redacted>
Date: Thu, 02 Feb 2017 18:43:28 -0800
quoted
From: Eric Dumazet <edumazet@google.com>

We added generic support for busy polling in NAPI layer in linux-4.5

No network driver uses ndo_busy_poll() anymore, we can get rid
of the pointer in struct net_device_ops, and its use in sk_busy_loop()

Saves NETIF_F_BUSY_POLL features bit.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied.
Nice ! Thanks !

Re: [PATCH net-next] net: remove support for per driver ndo_busy_poll()

From: Eric Dumazet <hidden>
Date: 2017-02-03 23:07:03

On Fri, 2017-02-03 at 17:28 -0500, David Miller wrote:
Actually, one more driver needs converting, "enic".

I did a quick and dirty conversion:

====================
From 7a655c6324a8968ea2f027bf3660c87c42ac3de4 Mon Sep 17 00:00:00 2001
From: "David S. Miller" <davem@davemloft.net>
Date: Fri, 3 Feb 2017 17:28:21 -0500
Subject: [PATCH] enic: Remove local ndo_busy_poll() implementation.

We do polling generically these days.

Signed-off-by: David S. Miller <davem@davemloft.net>
Oh sorry about that. Looks fine, thanks a lot !
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help