Subject: Re: [PATCH net-next 1/3] Add support to set napi threaded for individual napi

From: Stanislav Fomichev <[email-masked]>
Date: Thu, 2 Jan 2025 13:15:22 -0800

On 01/02, Samiullah Khawaja wrote:
> A net device has a threaded sysctl that can be used to enable threaded
> napi polling on all of the NAPI contexts under that device. Allow
> enabling threaded napi polling at individual napi level using netlink.
> 
> Add a new netlink operation `napi-set-threaded` that takes napi `id` and
> `threaded` attributes. This will enable the threaded polling on napi
> context.
> 
> Tested using following command in qemu/virtio-net:
> ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
>   --do napi-set-threaded       --json '{"id": 513, "threaded": 1}'
> 
> Signed-off-by: Samiullah Khawaja <[email-masked]>
> Reviewed-by: Willem de Bruijn <[email-masked]>
> ---
>  Documentation/netlink/specs/netdev.yaml | 19 +++++++++++++
>  include/linux/netdevice.h               |  9 ++++++
>  include/uapi/linux/netdev.h             |  2 ++
>  net/core/dev.c                          | 26 +++++++++++++++++
>  net/core/netdev-genl-gen.c              | 13 +++++++++
>  net/core/netdev-genl-gen.h              |  2 ++
>  net/core/netdev-genl.c                  | 37 +++++++++++++++++++++++++
>  tools/include/uapi/linux/netdev.h       |  2 ++
>  8 files changed, 110 insertions(+)
> 
> diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
> index cbb544bd6c84..aac343af7246 100644
> --- a/Documentation/netlink/specs/netdev.yaml
> +++ b/Documentation/netlink/specs/netdev.yaml
> @@ -268,6 +268,14 @@ attribute-sets:
>          doc: The timeout, in nanoseconds, of how long to suspend irq
>               processing, if event polling finds events
>          type: uint
> +      -
> +        name: threaded
> +        doc: Whether the napi is configured to operate in threaded polling
> +             mode. If this is set to `1` then the NAPI context operates
> +             in threaded polling mode.
> +        type: u32
> +        checks:
> +          max: 1
>    -
>      name: queue
>      attributes:
> @@ -659,6 +667,7 @@ operations:
>              - defer-hard-irqs
>              - gro-flush-timeout
>              - irq-suspend-timeout
> +            - threaded
>        dump:
>          request:
>            attributes:
> @@ -711,6 +720,16 @@ operations:
>              - defer-hard-irqs
>              - gro-flush-timeout
>              - irq-suspend-timeout
> +    -
> +      name: napi-set-threaded
> +      doc: Set threaded napi mode on this napi.
> +      attribute-set: napi
> +      flags: [ admin-perm ]
> +      do:
> +        request:
> +          attributes:
> +            - id
> +            - threaded

Any reason we need a separate op to enable/disable? Why not piggyback
on napi_set?

Maybe also move 'threaded' flag to persistent napi config?