diff mbox series

[net-next,v2,08/15] net: page_pool: add nlspec for basic access to page pools

Message ID 20231121000048.789613-9-kuba@kernel.org (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: page_pool: add netlink-based introspection | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 17 this patch: 17
netdev/cc_maintainers warning 2 maintainers not CCed: lorenzo@kernel.org sdf@google.com
netdev/build_clang fail Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 17 this patch: 17
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 58 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jakub Kicinski Nov. 21, 2023, midnight UTC
Add a Netlink spec in YAML for getting very basic information
about page pools.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 Documentation/netlink/specs/netdev.yaml | 46 +++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

Comments

Willem de Bruijn Nov. 21, 2023, 6:24 p.m. UTC | #1
Jakub Kicinski wrote:
> Add a Netlink spec in YAML for getting very basic information
> about page pools.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  Documentation/netlink/specs/netdev.yaml | 46 +++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
> 
> diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
> index 14511b13f305..84ca3c2ab872 100644
> --- a/Documentation/netlink/specs/netdev.yaml
> +++ b/Documentation/netlink/specs/netdev.yaml
> @@ -86,6 +86,34 @@ name: netdev
>               See Documentation/networking/xdp-rx-metadata.rst for more details.
>          type: u64
>          enum: xdp-rx-metadata
> +  -
> +    name: page-pool
> +    attributes:
> +      -
> +        name: id
> +        doc: Unique ID of a Page Pool instance.
> +        type: uint
> +        checks:
> +          min: 1
> +          max: u32-max
> +      -
> +        name: ifindex
> +        doc: |
> +          ifindex of the netdev to which the pool belongs.
> +          May be reported as 0 if the page pool was allocated for a netdev
> +          which got destroyed already (page pools may outlast their netdevs
> +          because they wait for all memory to be returned).
> +        type: u32
> +        checks:
> +          min: 1
> +          max: s32-max
> +      -
> +        name: napi-id
> +        doc: Id of NAPI using this Page Pool instance.
> +        type: uint
> +        checks:
> +          min: 1
> +          max: u32-max

Do you want to introduce a separate ID for page pools? That brings some
issues regarding network namespace isolation.

As a user API, it is also possible (and intuitive?) to refer to a
page_pool by (namespacified) ifindex plus netdev_rx_queue index,
or napi_id.

In fairness, napi_id is also global, not per netns.

By iterating over "for_each_netdev(net, ..", dump already limits
output to pools in the same netns and get only reports pools that
match the netns.

So it's only a minor matter of visible numbering, and perhaps
superfluous new id.

No technical comments to this series. Looks solid to me.
Jakub Kicinski Nov. 21, 2023, 8:37 p.m. UTC | #2
On Tue, 21 Nov 2023 13:24:07 -0500 Willem de Bruijn wrote:
> Do you want to introduce a separate ID for page pools? That brings some
> issues regarding network namespace isolation.
> 
> As a user API, it is also possible (and intuitive?) to refer to a
> page_pool by (namespacified) ifindex plus netdev_rx_queue index,
> or napi_id.

That does not work for "destroyed" pools. In general, there is
no natural key for a page pool I can think of.

> In fairness, napi_id is also global, not per netns.
> 
> By iterating over "for_each_netdev(net, ..", dump already limits
> output to pools in the same netns and get only reports pools that
> match the netns.
> 
> So it's only a minor matter of visible numbering, and perhaps
> superfluous new id.

The IDs are not stable. Any reconfiguration of a device will create
a new page pool and therefore assign a new ID. So applications can't
hold onto the ID long term.

That said the only use case for exposing the ID right now is to
implement do/GET (since there is no other unique key). And manual debug
with drgn, but that doesn't require uAPI. So if you prefer strongly
I can drop the ID from the uAPI and do/GET support.
Willem de Bruijn Nov. 21, 2023, 9:33 p.m. UTC | #3
Jakub Kicinski wrote:
> On Tue, 21 Nov 2023 13:24:07 -0500 Willem de Bruijn wrote:
> > Do you want to introduce a separate ID for page pools? That brings some
> > issues regarding network namespace isolation.
> > 
> > As a user API, it is also possible (and intuitive?) to refer to a
> > page_pool by (namespacified) ifindex plus netdev_rx_queue index,
> > or napi_id.
> 
> That does not work for "destroyed" pools. In general, there is
> no natural key for a page pool I can think of.

Pools for destroyed devices are attached to the loopback device.
If the netns is also destroyed, would it make sense to attach
them to the loopback device in the init namespace?

> > In fairness, napi_id is also global, not per netns.
> > 
> > By iterating over "for_each_netdev(net, ..", dump already limits
> > output to pools in the same netns and get only reports pools that
> > match the netns.
> > 
> > So it's only a minor matter of visible numbering, and perhaps
> > superfluous new id.
> 
> The IDs are not stable. Any reconfiguration of a device will create
> a new page pool and therefore assign a new ID. So applications can't
> hold onto the ID long term.
> 
> That said the only use case for exposing the ID right now is to
> implement do/GET (since there is no other unique key). And manual debug
> with drgn, but that doesn't require uAPI. So if you prefer strongly
> I can drop the ID from the uAPI and do/GET support.

No, this is fine. I just wanted to make sure that the alternative api
and netns details were considered beforehand, since it's uapi.
Jakub Kicinski Nov. 21, 2023, 10 p.m. UTC | #4
On Tue, 21 Nov 2023 16:33:25 -0500 Willem de Bruijn wrote:
> > That does not work for "destroyed" pools. In general, there is
> > no natural key for a page pool I can think of.  
> 
> Pools for destroyed devices are attached to the loopback device.
> If the netns is also destroyed, would it make sense to attach
> them to the loopback device in the init namespace?

I remember discussing this somewhere in person... netconf?
I opted for only exposing the cases which are obvious now,
we can extend the API later, once we get some production experience.

> > The IDs are not stable. Any reconfiguration of a device will create
> > a new page pool and therefore assign a new ID. So applications can't
> > hold onto the ID long term.
> > 
> > That said the only use case for exposing the ID right now is to
> > implement do/GET (since there is no other unique key). And manual debug
> > with drgn, but that doesn't require uAPI. So if you prefer strongly
> > I can drop the ID from the uAPI and do/GET support.  
> 
> No, this is fine. I just wanted to make sure that the alternative api
> and netns details were considered beforehand, since it's uapi.

Okay, let me ditch it for now, in the interest of making progress..
It's easily added later.
David Ahern Nov. 21, 2023, 10:49 p.m. UTC | #5
On 11/21/23 2:00 PM, Jakub Kicinski wrote:
> On Tue, 21 Nov 2023 16:33:25 -0500 Willem de Bruijn wrote:
>>> That does not work for "destroyed" pools. In general, there is
>>> no natural key for a page pool I can think of.  
>>
>> Pools for destroyed devices are attached to the loopback device.
>> If the netns is also destroyed, would it make sense to attach
>> them to the loopback device in the init namespace?
> 
> I remember discussing this somewhere in person... netconf?

I asked why not blackhole_dev for just that problem.
Jakub Kicinski Nov. 21, 2023, 11:42 p.m. UTC | #6
On Tue, 21 Nov 2023 14:49:31 -0800 David Ahern wrote:
> > I remember discussing this somewhere in person... netconf?  
> 
> I asked why not blackhole_dev for just that problem.

Ack, but I don't see myself blabbering about the hidden objects
on that sub-thread now.
diff mbox series

Patch

diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
index 14511b13f305..84ca3c2ab872 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -86,6 +86,34 @@  name: netdev
              See Documentation/networking/xdp-rx-metadata.rst for more details.
         type: u64
         enum: xdp-rx-metadata
+  -
+    name: page-pool
+    attributes:
+      -
+        name: id
+        doc: Unique ID of a Page Pool instance.
+        type: uint
+        checks:
+          min: 1
+          max: u32-max
+      -
+        name: ifindex
+        doc: |
+          ifindex of the netdev to which the pool belongs.
+          May be reported as 0 if the page pool was allocated for a netdev
+          which got destroyed already (page pools may outlast their netdevs
+          because they wait for all memory to be returned).
+        type: u32
+        checks:
+          min: 1
+          max: s32-max
+      -
+        name: napi-id
+        doc: Id of NAPI using this Page Pool instance.
+        type: uint
+        checks:
+          min: 1
+          max: u32-max
 
 operations:
   list:
@@ -120,6 +148,24 @@  name: netdev
       doc: Notification about device configuration being changed.
       notify: dev-get
       mcgrp: mgmt
+    -
+      name: page-pool-get
+      doc: |
+        Get / dump information about Page Pools.
+        (Only Page Pools associated with a net_device can be listed.)
+      attribute-set: page-pool
+      do:
+        request:
+          attributes:
+            - id
+        reply: &pp-reply
+          attributes:
+            - id
+            - ifindex
+            - napi-id
+      dump:
+        reply: *pp-reply
+      config-cond: page-pool
 
 mcast-groups:
   list: