netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf v2] xsk: inherit need_wakeup flag for shared sockets
@ 2022-09-20 11:58 Jalal Mostafa
  2022-09-20 13:34 ` Magnus Karlsson
  0 siblings, 1 reply; 5+ messages in thread
From: Jalal Mostafa @ 2022-09-20 11:58 UTC (permalink / raw)
  To: magnus.karlsson, netdev, bpf
  Cc: bjorn, magnus.karlsson, maciej.fijalkowski, jonathan.lemon, davem,
	edumazet, kuba, pabeni, daniel, linux-kernel, jalal.mostafa

The flag for need_wakeup is not set for xsks with `XDP_SHARED_UMEM`
flag and of different queue ids and/or devices. They should inherit
the flag from the first socket buffer pool since no flags can be
specified once `XDP_SHARED_UMEM` is specified. The issue is fixed
by creating a new function `xp_create_and_assign_umem_shared` to
create xsk_buff_pool for xsks with the shared umem flag set.

Fixes: b5aea28dca134 ("xsk: Add shared umem support between queue ids")
Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
---
 include/net/xsk_buff_pool.h | 2 +-
 net/xdp/xsk.c               | 4 ++--
 net/xdp/xsk_buff_pool.c     | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h
index 647722e847b4..f787c3f524b0 100644
--- a/include/net/xsk_buff_pool.h
+++ b/include/net/xsk_buff_pool.h
@@ -95,7 +95,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,
 						struct xdp_umem *umem);
 int xp_assign_dev(struct xsk_buff_pool *pool, struct net_device *dev,
 		  u16 queue_id, u16 flags);
-int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
+int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
 			 struct net_device *dev, u16 queue_id);
 int xp_alloc_tx_descs(struct xsk_buff_pool *pool, struct xdp_sock *xs);
 void xp_destroy(struct xsk_buff_pool *pool);
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 5b4ce6ba1bc7..7bada4e8460b 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -954,8 +954,8 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
 				goto out_unlock;
 			}
 
-			err = xp_assign_dev_shared(xs->pool, umem_xs->umem,
-						   dev, qid);
+			err = xp_assign_dev_shared(xs->pool, umem_xs, dev,
+						   qid);
 			if (err) {
 				xp_destroy(xs->pool);
 				xs->pool = NULL;
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index a71a8c6edf55..ed6c71826d31 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -212,17 +212,18 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
 	return err;
 }
 
-int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
+int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
 			 struct net_device *dev, u16 queue_id)
 {
 	u16 flags;
+	struct xdp_umem *umem = umem_xs->umem;
 
 	/* One fill and completion ring required for each queue id. */
 	if (!pool->fq || !pool->cq)
 		return -EINVAL;
 
 	flags = umem->zc ? XDP_ZEROCOPY : XDP_COPY;
-	if (pool->uses_need_wakeup)
+	if (umem_xs->pool->uses_need_wakeup)
 		flags |= XDP_USE_NEED_WAKEUP;
 
 	return xp_assign_dev(pool, dev, queue_id, flags);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf v2] xsk: inherit need_wakeup flag for shared sockets
  2022-09-20 11:58 [PATCH bpf v2] xsk: inherit need_wakeup flag for shared sockets Jalal Mostafa
@ 2022-09-20 13:34 ` Magnus Karlsson
  2022-09-21 12:16   ` Maciej Fijalkowski
  0 siblings, 1 reply; 5+ messages in thread
From: Magnus Karlsson @ 2022-09-20 13:34 UTC (permalink / raw)
  To: Jalal Mostafa
  Cc: netdev, bpf, bjorn, magnus.karlsson, maciej.fijalkowski,
	jonathan.lemon, davem, edumazet, kuba, pabeni, daniel,
	linux-kernel, jalal.mostafa

On Tue, Sep 20, 2022 at 1:58 PM Jalal Mostafa
<jalal.a.mostapha@gmail.com> wrote:
>
> The flag for need_wakeup is not set for xsks with `XDP_SHARED_UMEM`
> flag and of different queue ids and/or devices. They should inherit
> the flag from the first socket buffer pool since no flags can be
> specified once `XDP_SHARED_UMEM` is specified. The issue is fixed
> by creating a new function `xp_create_and_assign_umem_shared` to
> create xsk_buff_pool for xsks with the shared umem flag set.

Thanks!

Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>

> Fixes: b5aea28dca134 ("xsk: Add shared umem support between queue ids")
> Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
> ---
>  include/net/xsk_buff_pool.h | 2 +-
>  net/xdp/xsk.c               | 4 ++--
>  net/xdp/xsk_buff_pool.c     | 5 +++--
>  3 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h
> index 647722e847b4..f787c3f524b0 100644
> --- a/include/net/xsk_buff_pool.h
> +++ b/include/net/xsk_buff_pool.h
> @@ -95,7 +95,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,
>                                                 struct xdp_umem *umem);
>  int xp_assign_dev(struct xsk_buff_pool *pool, struct net_device *dev,
>                   u16 queue_id, u16 flags);
> -int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
> +int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
>                          struct net_device *dev, u16 queue_id);
>  int xp_alloc_tx_descs(struct xsk_buff_pool *pool, struct xdp_sock *xs);
>  void xp_destroy(struct xsk_buff_pool *pool);
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 5b4ce6ba1bc7..7bada4e8460b 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -954,8 +954,8 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
>                                 goto out_unlock;
>                         }
>
> -                       err = xp_assign_dev_shared(xs->pool, umem_xs->umem,
> -                                                  dev, qid);
> +                       err = xp_assign_dev_shared(xs->pool, umem_xs, dev,
> +                                                  qid);
>                         if (err) {
>                                 xp_destroy(xs->pool);
>                                 xs->pool = NULL;
> diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
> index a71a8c6edf55..ed6c71826d31 100644
> --- a/net/xdp/xsk_buff_pool.c
> +++ b/net/xdp/xsk_buff_pool.c
> @@ -212,17 +212,18 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
>         return err;
>  }
>
> -int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
> +int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
>                          struct net_device *dev, u16 queue_id)
>  {
>         u16 flags;
> +       struct xdp_umem *umem = umem_xs->umem;
>
>         /* One fill and completion ring required for each queue id. */
>         if (!pool->fq || !pool->cq)
>                 return -EINVAL;
>
>         flags = umem->zc ? XDP_ZEROCOPY : XDP_COPY;
> -       if (pool->uses_need_wakeup)
> +       if (umem_xs->pool->uses_need_wakeup)
>                 flags |= XDP_USE_NEED_WAKEUP;
>
>         return xp_assign_dev(pool, dev, queue_id, flags);
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf v2] xsk: inherit need_wakeup flag for shared sockets
  2022-09-20 13:34 ` Magnus Karlsson
@ 2022-09-21 12:16   ` Maciej Fijalkowski
  2022-09-21 13:57     ` [PATCH bpf v3] " Jalal Mostafa
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej Fijalkowski @ 2022-09-21 12:16 UTC (permalink / raw)
  To: Magnus Karlsson
  Cc: Jalal Mostafa, netdev, bpf, bjorn, magnus.karlsson,
	jonathan.lemon, davem, edumazet, kuba, pabeni, daniel,
	linux-kernel, jalal.mostafa

On Tue, Sep 20, 2022 at 03:34:19PM +0200, Magnus Karlsson wrote:
> On Tue, Sep 20, 2022 at 1:58 PM Jalal Mostafa
> <jalal.a.mostapha@gmail.com> wrote:
> >
> > The flag for need_wakeup is not set for xsks with `XDP_SHARED_UMEM`
> > flag and of different queue ids and/or devices. They should inherit
> > the flag from the first socket buffer pool since no flags can be
> > specified once `XDP_SHARED_UMEM` is specified. The issue is fixed
> > by creating a new function `xp_create_and_assign_umem_shared` to
> > create xsk_buff_pool for xsks with the shared umem flag set.

Hi Jalal,

Please update commit msg and remove reference to the new function that you
were creating on v1.

> 
> Thanks!
> 
> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
> 
> > Fixes: b5aea28dca134 ("xsk: Add shared umem support between queue ids")
> > Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
> > ---
> >  include/net/xsk_buff_pool.h | 2 +-
> >  net/xdp/xsk.c               | 4 ++--
> >  net/xdp/xsk_buff_pool.c     | 5 +++--
> >  3 files changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h
> > index 647722e847b4..f787c3f524b0 100644
> > --- a/include/net/xsk_buff_pool.h
> > +++ b/include/net/xsk_buff_pool.h
> > @@ -95,7 +95,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,
> >                                                 struct xdp_umem *umem);
> >  int xp_assign_dev(struct xsk_buff_pool *pool, struct net_device *dev,
> >                   u16 queue_id, u16 flags);
> > -int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
> > +int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
> >                          struct net_device *dev, u16 queue_id);
> >  int xp_alloc_tx_descs(struct xsk_buff_pool *pool, struct xdp_sock *xs);
> >  void xp_destroy(struct xsk_buff_pool *pool);
> > diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> > index 5b4ce6ba1bc7..7bada4e8460b 100644
> > --- a/net/xdp/xsk.c
> > +++ b/net/xdp/xsk.c
> > @@ -954,8 +954,8 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
> >                                 goto out_unlock;
> >                         }
> >
> > -                       err = xp_assign_dev_shared(xs->pool, umem_xs->umem,
> > -                                                  dev, qid);
> > +                       err = xp_assign_dev_shared(xs->pool, umem_xs, dev,
> > +                                                  qid);
> >                         if (err) {
> >                                 xp_destroy(xs->pool);
> >                                 xs->pool = NULL;
> > diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
> > index a71a8c6edf55..ed6c71826d31 100644
> > --- a/net/xdp/xsk_buff_pool.c
> > +++ b/net/xdp/xsk_buff_pool.c
> > @@ -212,17 +212,18 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
> >         return err;
> >  }
> >
> > -int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
> > +int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
> >                          struct net_device *dev, u16 queue_id)
> >  {
> >         u16 flags;
> > +       struct xdp_umem *umem = umem_xs->umem;
> >
> >         /* One fill and completion ring required for each queue id. */
> >         if (!pool->fq || !pool->cq)
> >                 return -EINVAL;
> >
> >         flags = umem->zc ? XDP_ZEROCOPY : XDP_COPY;
> > -       if (pool->uses_need_wakeup)
> > +       if (umem_xs->pool->uses_need_wakeup)
> >                 flags |= XDP_USE_NEED_WAKEUP;
> >
> >         return xp_assign_dev(pool, dev, queue_id, flags);
> > --
> > 2.34.1
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH bpf v3] xsk: inherit need_wakeup flag for shared sockets
  2022-09-21 12:16   ` Maciej Fijalkowski
@ 2022-09-21 13:57     ` Jalal Mostafa
  2022-09-22 15:20       ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 5+ messages in thread
From: Jalal Mostafa @ 2022-09-21 13:57 UTC (permalink / raw)
  To: maciej.fijalkowski, netdev, bpf
  Cc: bjorn, magnus.karlsson, jonathan.lemon, davem, edumazet, kuba,
	pabeni, daniel, john.fastabend, hawk, ast, linux-kernel,
	jalal.mostafa, jalal.a.mostapha

The flag for need_wakeup is not set for xsks with `XDP_SHARED_UMEM`
flag and of different queue ids and/or devices. They should inherit
the flag from the first socket buffer pool since no flags can be
specified once `XDP_SHARED_UMEM` is specified.

Fixes: b5aea28dca134 ("xsk: Add shared umem support between queue ids")

Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 include/net/xsk_buff_pool.h | 2 +-
 net/xdp/xsk.c               | 4 ++--
 net/xdp/xsk_buff_pool.c     | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h
index 647722e847b4..f787c3f524b0 100644
--- a/include/net/xsk_buff_pool.h
+++ b/include/net/xsk_buff_pool.h
@@ -95,7 +95,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,
 						struct xdp_umem *umem);
 int xp_assign_dev(struct xsk_buff_pool *pool, struct net_device *dev,
 		  u16 queue_id, u16 flags);
-int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
+int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
 			 struct net_device *dev, u16 queue_id);
 int xp_alloc_tx_descs(struct xsk_buff_pool *pool, struct xdp_sock *xs);
 void xp_destroy(struct xsk_buff_pool *pool);
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 5b4ce6ba1bc7..7bada4e8460b 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -954,8 +954,8 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
 				goto out_unlock;
 			}
 
-			err = xp_assign_dev_shared(xs->pool, umem_xs->umem,
-						   dev, qid);
+			err = xp_assign_dev_shared(xs->pool, umem_xs, dev,
+						   qid);
 			if (err) {
 				xp_destroy(xs->pool);
 				xs->pool = NULL;
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index a71a8c6edf55..ed6c71826d31 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -212,17 +212,18 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
 	return err;
 }
 
-int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
+int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
 			 struct net_device *dev, u16 queue_id)
 {
 	u16 flags;
+	struct xdp_umem *umem = umem_xs->umem;
 
 	/* One fill and completion ring required for each queue id. */
 	if (!pool->fq || !pool->cq)
 		return -EINVAL;
 
 	flags = umem->zc ? XDP_ZEROCOPY : XDP_COPY;
-	if (pool->uses_need_wakeup)
+	if (umem_xs->pool->uses_need_wakeup)
 		flags |= XDP_USE_NEED_WAKEUP;
 
 	return xp_assign_dev(pool, dev, queue_id, flags);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf v3] xsk: inherit need_wakeup flag for shared sockets
  2022-09-21 13:57     ` [PATCH bpf v3] " Jalal Mostafa
@ 2022-09-22 15:20       ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-22 15:20 UTC (permalink / raw)
  To: Jalal Mostafa
  Cc: maciej.fijalkowski, netdev, bpf, bjorn, magnus.karlsson,
	jonathan.lemon, davem, edumazet, kuba, pabeni, daniel,
	john.fastabend, hawk, ast, linux-kernel, jalal.mostafa

Hello:

This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Wed, 21 Sep 2022 13:57:01 +0000 you wrote:
> The flag for need_wakeup is not set for xsks with `XDP_SHARED_UMEM`
> flag and of different queue ids and/or devices. They should inherit
> the flag from the first socket buffer pool since no flags can be
> specified once `XDP_SHARED_UMEM` is specified.
> 
> Fixes: b5aea28dca134 ("xsk: Add shared umem support between queue ids")
> 
> [...]

Here is the summary with links:
  - [bpf,v3] xsk: inherit need_wakeup flag for shared sockets
    https://git.kernel.org/bpf/bpf/c/60240bc26114

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-22 15:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-20 11:58 [PATCH bpf v2] xsk: inherit need_wakeup flag for shared sockets Jalal Mostafa
2022-09-20 13:34 ` Magnus Karlsson
2022-09-21 12:16   ` Maciej Fijalkowski
2022-09-21 13:57     ` [PATCH bpf v3] " Jalal Mostafa
2022-09-22 15:20       ` patchwork-bot+netdevbpf

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).