diff mbox series

[RFC,bpf-next,4/7] netdevice: introduce busy-poll setsockopt for AF_XDP

Message ID 1556786363-28743-5-git-send-email-magnus.karlsson@intel.com
State RFC
Delegated to: BPF Maintainers
Headers show
Series busy poll support for AF_XDP sockets | expand

Commit Message

Magnus Karlsson May 2, 2019, 8:39 a.m. UTC
This patch introduces a new setsockopt that enables busy-poll for XDP
sockets. It is called XDP_BUSY_POLL_BATCH_SIZE and takes batch size as
an argument. A value between 1 and NAPI_WEIGHT (64) will turn it on, 0
will turn it off and any other value will return an error. There is
also a corresponding getsockopt implementation.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 include/uapi/linux/if_xdp.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Samudrala, Sridhar May 3, 2019, 12:13 a.m. UTC | #1
On 5/2/2019 1:39 AM, Magnus Karlsson wrote:
> This patch introduces a new setsockopt that enables busy-poll for XDP
> sockets. It is called XDP_BUSY_POLL_BATCH_SIZE and takes batch size as
> an argument. A value between 1 and NAPI_WEIGHT (64) will turn it on, 0
> will turn it off and any other value will return an error. There is
> also a corresponding getsockopt implementation.

I think this socket option should also allow specifying a timeout value 
when using blocking poll() calls.
OR can we use SO_BUSY_POLL to specify this timeout value?

> 
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
>   include/uapi/linux/if_xdp.h | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/include/uapi/linux/if_xdp.h b/include/uapi/linux/if_xdp.h
> index caed8b1..be28a78 100644
> --- a/include/uapi/linux/if_xdp.h
> +++ b/include/uapi/linux/if_xdp.h
> @@ -46,6 +46,7 @@ struct xdp_mmap_offsets {
>   #define XDP_UMEM_FILL_RING		5
>   #define XDP_UMEM_COMPLETION_RING	6
>   #define XDP_STATISTICS			7
> +#define XDP_BUSY_POLL_BATCH_SIZE	8
>   
>   struct xdp_umem_reg {
>   	__u64 addr; /* Start of packet data area */
>
Magnus Karlsson May 3, 2019, 6:35 a.m. UTC | #2
On Fri, May 3, 2019 at 2:26 AM Samudrala, Sridhar
<sridhar.samudrala@intel.com> wrote:
>
>
>
> On 5/2/2019 1:39 AM, Magnus Karlsson wrote:
> > This patch introduces a new setsockopt that enables busy-poll for XDP
> > sockets. It is called XDP_BUSY_POLL_BATCH_SIZE and takes batch size as
> > an argument. A value between 1 and NAPI_WEIGHT (64) will turn it on, 0
> > will turn it off and any other value will return an error. There is
> > also a corresponding getsockopt implementation.
>
> I think this socket option should also allow specifying a timeout value
> when using blocking poll() calls.
> OR can we use SO_BUSY_POLL to specify this timeout value?

I think you are correct in that we need to be able to specify the
timeout. The current approach of always having a timeout of zero was
optimized for the high throughput case. But Ilias and others often
talk about using AF_XDP for time sensitive networking, and in that
case spinning in the kernel (for a max period of the timeout) waiting
for a packet would provide better latency. And with a configurable
value, we could support both cases, so why not.

I will add the timeout value to the new setsockopt I introduced, so it
will take both a batch size and a timeout value. I will also call it
something else since it should not have batch_size in its name
anymore.

Thanks: Magnus

> >
> > Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> > ---
> >   include/uapi/linux/if_xdp.h | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/include/uapi/linux/if_xdp.h b/include/uapi/linux/if_xdp.h
> > index caed8b1..be28a78 100644
> > --- a/include/uapi/linux/if_xdp.h
> > +++ b/include/uapi/linux/if_xdp.h
> > @@ -46,6 +46,7 @@ struct xdp_mmap_offsets {
> >   #define XDP_UMEM_FILL_RING          5
> >   #define XDP_UMEM_COMPLETION_RING    6
> >   #define XDP_STATISTICS                      7
> > +#define XDP_BUSY_POLL_BATCH_SIZE     8
> >
> >   struct xdp_umem_reg {
> >       __u64 addr; /* Start of packet data area */
> >
diff mbox series

Patch

diff --git a/include/uapi/linux/if_xdp.h b/include/uapi/linux/if_xdp.h
index caed8b1..be28a78 100644
--- a/include/uapi/linux/if_xdp.h
+++ b/include/uapi/linux/if_xdp.h
@@ -46,6 +46,7 @@  struct xdp_mmap_offsets {
 #define XDP_UMEM_FILL_RING		5
 #define XDP_UMEM_COMPLETION_RING	6
 #define XDP_STATISTICS			7
+#define XDP_BUSY_POLL_BATCH_SIZE	8
 
 struct xdp_umem_reg {
 	__u64 addr; /* Start of packet data area */