* [PATCH net-next v4] netdev-genl: Elide napi_id when not present
@ 2025-02-05 19:37 Joe Damato
2025-02-06 3:26 ` Samudrala, Sridhar
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Joe Damato @ 2025-02-05 19:37 UTC (permalink / raw)
To: netdev
Cc: pabeni, edumazet, sridhar.samudrala, Joe Damato, David S. Miller,
Jakub Kicinski, Simon Horman, Amritha Nambiar, Mina Almasry,
open list
There are at least two cases where napi_id may not present and the
napi_id should be elided:
1. Queues could be created, but napi_enable may not have been called
yet. In this case, there may be a NAPI but it may not have an ID and
output of a napi_id should be elided.
2. TX-only NAPIs currently do not have NAPI IDs. If a TX queue happens
to be linked with a TX-only NAPI, elide the NAPI ID from the netlink
output as a NAPI ID of 0 is not useful for users.
Signed-off-by: Joe Damato <jdamato@fastly.com>
---
v4:
- Fixed a typo in the NETDEV_QUEUE_TYPE_TX case (rxq should've been
txq).
v3: https://lore.kernel.org/netdev/20250204192724.199209-1-jdamato@fastly.com/
- Took Eric's suggested patch to refactor the code to use helpers,
which improves the code quality significantly.
v2: https://lore.kernel.org/netdev/20250203191714.155526-1-jdamato@fastly.com/
- Updated to elide NAPI IDs for RX queues which may have not called
napi_enable yet.
rfc: https://lore.kernel.org/lkml/20250128163038.429864-1-jdamato@fastly.com/
include/net/busy_poll.h | 5 +++++
net/core/netdev-genl.c | 13 +++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
index c39a426ebf52..741fa7754700 100644
--- a/include/net/busy_poll.h
+++ b/include/net/busy_poll.h
@@ -24,6 +24,11 @@
*/
#define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1))
+static inline bool napi_id_valid(unsigned int napi_id)
+{
+ return napi_id >= MIN_NAPI_ID;
+}
+
#define BUSY_POLL_BUDGET 8
#ifdef CONFIG_NET_RX_BUSY_POLL
diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index 715f85c6b62e..b5c4e42351e6 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -364,6 +364,13 @@ int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
+static int nla_put_napi_id(struct sk_buff *skb, const struct napi_struct *napi)
+{
+ if (napi && napi_id_valid(napi->napi_id))
+ return nla_put_u32(skb, NETDEV_A_QUEUE_NAPI_ID, napi->napi_id);
+ return 0;
+}
+
static int
netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
u32 q_idx, u32 q_type, const struct genl_info *info)
@@ -385,8 +392,7 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
switch (q_type) {
case NETDEV_QUEUE_TYPE_RX:
rxq = __netif_get_rx_queue(netdev, q_idx);
- if (rxq->napi && nla_put_u32(rsp, NETDEV_A_QUEUE_NAPI_ID,
- rxq->napi->napi_id))
+ if (nla_put_napi_id(rsp, rxq->napi))
goto nla_put_failure;
binding = rxq->mp_params.mp_priv;
@@ -397,8 +403,7 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
break;
case NETDEV_QUEUE_TYPE_TX:
txq = netdev_get_tx_queue(netdev, q_idx);
- if (txq->napi && nla_put_u32(rsp, NETDEV_A_QUEUE_NAPI_ID,
- txq->napi->napi_id))
+ if (nla_put_napi_id(rsp, txq->napi))
goto nla_put_failure;
}
base-commit: 0bea93fdbaf8675b7e8124bdcaf51497dcc8bcfa
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net-next v4] netdev-genl: Elide napi_id when not present
2025-02-05 19:37 [PATCH net-next v4] netdev-genl: Elide napi_id when not present Joe Damato
@ 2025-02-06 3:26 ` Samudrala, Sridhar
2025-02-06 9:02 ` Eric Dumazet
2025-02-07 1:14 ` Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Samudrala, Sridhar @ 2025-02-06 3:26 UTC (permalink / raw)
To: Joe Damato, netdev
Cc: pabeni, edumazet, David S. Miller, Jakub Kicinski, Simon Horman,
Amritha Nambiar, Mina Almasry, open list
On 2/5/2025 11:37 AM, Joe Damato wrote:
> There are at least two cases where napi_id may not present and the
> napi_id should be elided:
>
> 1. Queues could be created, but napi_enable may not have been called
> yet. In this case, there may be a NAPI but it may not have an ID and
> output of a napi_id should be elided.
>
> 2. TX-only NAPIs currently do not have NAPI IDs. If a TX queue happens
> to be linked with a TX-only NAPI, elide the NAPI ID from the netlink
> output as a NAPI ID of 0 is not useful for users.
>
> Signed-off-by: Joe Damato <jdamato@fastly.com>
Reviewed-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v4] netdev-genl: Elide napi_id when not present
2025-02-05 19:37 [PATCH net-next v4] netdev-genl: Elide napi_id when not present Joe Damato
2025-02-06 3:26 ` Samudrala, Sridhar
@ 2025-02-06 9:02 ` Eric Dumazet
2025-02-07 1:14 ` Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-02-06 9:02 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, pabeni, sridhar.samudrala, David S. Miller,
Jakub Kicinski, Simon Horman, Amritha Nambiar, Mina Almasry,
open list
On Wed, Feb 5, 2025 at 8:38 PM Joe Damato <jdamato@fastly.com> wrote:
>
> There are at least two cases where napi_id may not present and the
> napi_id should be elided:
>
> 1. Queues could be created, but napi_enable may not have been called
> yet. In this case, there may be a NAPI but it may not have an ID and
> output of a napi_id should be elided.
>
> 2. TX-only NAPIs currently do not have NAPI IDs. If a TX queue happens
> to be linked with a TX-only NAPI, elide the NAPI ID from the netlink
> output as a NAPI ID of 0 is not useful for users.
>
> Signed-off-by: Joe Damato <jdamato@fastly.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v4] netdev-genl: Elide napi_id when not present
2025-02-05 19:37 [PATCH net-next v4] netdev-genl: Elide napi_id when not present Joe Damato
2025-02-06 3:26 ` Samudrala, Sridhar
2025-02-06 9:02 ` Eric Dumazet
@ 2025-02-07 1:14 ` Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2025-02-07 1:14 UTC (permalink / raw)
To: Joe Damato
Cc: netdev, pabeni, edumazet, sridhar.samudrala, David S. Miller,
Simon Horman, Amritha Nambiar, Mina Almasry, open list
On Wed, 5 Feb 2025 19:37:47 +0000 Joe Damato wrote:
> There are at least two cases where napi_id may not present and the
> napi_id should be elided:
>
> 1. Queues could be created, but napi_enable may not have been called
> yet. In this case, there may be a NAPI but it may not have an ID and
> output of a napi_id should be elided.
>
> 2. TX-only NAPIs currently do not have NAPI IDs. If a TX queue happens
> to be linked with a TX-only NAPI, elide the NAPI ID from the netlink
> output as a NAPI ID of 0 is not useful for users.
>
> Signed-off-by: Joe Damato <jdamato@fastly.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-07 1:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 19:37 [PATCH net-next v4] netdev-genl: Elide napi_id when not present Joe Damato
2025-02-06 3:26 ` Samudrala, Sridhar
2025-02-06 9:02 ` Eric Dumazet
2025-02-07 1:14 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).