Skip to contentSkip to conversation

sfc: Use netdev refcount tracking in struct efx_async_filter_insertion

PATCH Applied YiFei Zhu 3 participants 3 messages Dec 19, 2024 – Dec 23, 2024

Subsystems (3)
lore
Share & tools
lore

YiFei Zhu

author
#0 lore raw

PATCH v3 1/1 sfc: Use netdev refcount tracking in struct efx_async_filter_insertion

I was debugging some netdev refcount issues in OpenOnload, and one of the places I was looking at was in the sfc driver. Only struct efx_async_filter_insertion was not using netdev refcount tracker, so add it here. GFP_ATOMIC because this code path is called by ndo_rx_flow_steer which holds RCU.

This patch should be a no-op if !CONFIG_NET_DEV_REFCNT_TRACKER

---
v1 -> v2:
- Documented the added field of @net_dev_tracker in the struct v2 -> v3:
- Separate req->net_dev assignment into its own line in efx_filter_rfs & efx_siena_filter_rfs

---
 drivers/net/ethernet/sfc/net_driver.h       | 2 ++
 drivers/net/ethernet/sfc/rx_common.c        | 5 +++--
 drivers/net/ethernet/sfc/siena/net_driver.h | 2 ++
 drivers/net/ethernet/sfc/siena/rx_common.c  | 5 +++--
 4 files changed, 10 insertions(+), 4 deletions(-)
drivers/net/ethernet/sfc/net_driver.h +2 -0
index 620ba6ef3514b..f70a7b7d6345c 100644
@@ -831,6 +831,7 @@ struct efx_arfs_rule {
 /**
  * struct efx_async_filter_insertion - Request to asynchronously insert a filter
  * @net_dev: Reference to the netdevice
+ * @net_dev_tracker: reference tracker entry for @net_dev
  * @spec: The filter to insert
  * @work: Workitem for this request
  * @rxq_index: Identifies the channel for which this request was made
@@ -838,6 +839,7 @@ struct efx_arfs_rule {
  */
 struct efx_async_filter_insertion {
 	struct net_device *net_dev;
+	netdevice_tracker net_dev_tracker;
 	struct efx_filter_spec spec;
 	struct work_struct work;
 	u16 rxq_index;
drivers/net/ethernet/sfc/rx_common.c +3 -2
index ab358fe13e1df..4cc83203e1880 100644
@@ -897,7 +897,7 @@ static void efx_filter_rfs_work(struct work_struct *data)
 
 	/* Release references */
 	clear_bit(slot_idx, &efx->rps_slot_map);
-	dev_put(req->net_dev);
+	netdev_put(req->net_dev, &req->net_dev_tracker);
 }
 
 int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
@@ -989,7 +989,8 @@ int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
 	}
 
 	/* Queue the request */
-	dev_hold(req->net_dev = net_dev);
+	req->net_dev = net_dev;
+	netdev_hold(req->net_dev, &req->net_dev_tracker, GFP_ATOMIC);
 	INIT_WORK(&req->work, efx_filter_rfs_work);
 	req->rxq_index = rxq_index;
 	req->flow_id = flow_id;
drivers/net/ethernet/sfc/siena/net_driver.h +2 -0
index 9785eff10607b..2be3bad3c9933 100644
@@ -753,6 +753,7 @@ struct efx_arfs_rule {
 /**
  * struct efx_async_filter_insertion - Request to asynchronously insert a filter
  * @net_dev: Reference to the netdevice
+ * @net_dev_tracker: reference tracker entry for @net_dev
  * @spec: The filter to insert
  * @work: Workitem for this request
  * @rxq_index: Identifies the channel for which this request was made
@@ -760,6 +761,7 @@ struct efx_arfs_rule {
  */
 struct efx_async_filter_insertion {
 	struct net_device *net_dev;
+	netdevice_tracker net_dev_tracker;
 	struct efx_filter_spec spec;
 	struct work_struct work;
 	u16 rxq_index;
drivers/net/ethernet/sfc/siena/rx_common.c +3 -2
index 082e35c6caaae..2839d0e0a9c16 100644
@@ -888,7 +888,7 @@ static void efx_filter_rfs_work(struct work_struct *data)
 
 	/* Release references */
 	clear_bit(slot_idx, &efx->rps_slot_map);
-	dev_put(req->net_dev);
+	netdev_put(req->net_dev, &req->net_dev_tracker);
 }
 
 int efx_siena_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
@@ -980,7 +980,8 @@ int efx_siena_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
 	}
 
 	/* Queue the request */
-	dev_hold(req->net_dev = net_dev);
+	req->net_dev = net_dev;
+	netdev_hold(req->net_dev, &req->net_dev_tracker, GFP_ATOMIC);
 	INIT_WORK(&req->work, efx_filter_rfs_work);
 	req->rxq_index = rxq_index;
 	req->flow_id = flow_id;
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
Reviewed-by on v3 1/1
#1 lore raw
Quoted 10 lines · YiFei Zhu

I was debugging some netdev refcount issues in OpenOnload, and one of the places I was looking at was in the sfc driver. Only struct efx_async_filter_insertion was not using netdev refcount tracker, so add it here. GFP_ATOMIC because this code path is called by ndo_rx_flow_steer which holds RCU.

This patch should be a no-op if !CONFIG_NET_DEV_REFCNT_TRACKER

Thanks !

#2 lore raw
In reply to YiFei Zhu
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Thu, 19 Dec 2024 17:30:04 +0000 you wrote:

I was debugging some netdev refcount issues in OpenOnload, and one of the places I was looking at was in the sfc driver. Only struct efx_async_filter_insertion was not using netdev refcount tracker, so add it here. GFP_ATOMIC because this code path is called by ndo_rx_flow_steer which holds RCU.

This patch should be a no-op if !CONFIG_NET_DEV_REFCNT_TRACKER

[...]

Here is the summary with links:
- [v3,net-next] sfc: Use netdev refcount tracking in struct efx_async_filter_insertion

    https://git.kernel.org/netdev/net-next/c/85101bda1387

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html