XDP-Newbies Archive mirror
 help / color / mirror / Atom feed
From: "Karlsson, Magnus" <magnus.karlsson@intel.com>
To: "Nuno Gonçalves" <nunog@fr24.com>,
	"xdp-newbies@vger.kernel.org" <xdp-newbies@vger.kernel.org>
Subject: RE: [PATCH] xsk: allow remap of fill and/or completion rings
Date: Mon, 20 Mar 2023 10:04:22 +0000	[thread overview]
Message-ID: <MW3PR11MB46023B056366E7B79E105549F7809@MW3PR11MB4602.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230319220811.165506-1-nunog@fr24.com>



> -----Original Message-----
> From: Nuno Gonçalves <nunog@fr24.com>
> Sent: Sunday, March 19, 2023 11:08 PM
> To: xdp-newbies@vger.kernel.org; Karlsson, Magnus <magnus.karlsson@intel.com>
> Cc: Nuno Gonçalves <nunog@fr24.com>
> Subject: [PATCH] xsk: allow remap of fill and/or completion rings

Please add the bpf mailing list too in the to-line and resubmit. I do not think this will be picked up from xdp-newbies list alone. And put the AF_XDP maintainers in the to-line so that we get this in our mailboxes. You can find us in the MAINTAINERS file. Please add Alexei Starovoitov and Daniel Borkmann too as they are the bpf list maintainers.

And the destination of the patch should be bpf-next, so [PATCH bpf-next] in the subject please. 

Thanks: Magnus

> The remap of fill and completion rings was frowned upon as they
> control the usage of UMEM which does not support concurrent use.
> At the same time this would disallow the remap of this rings
> into another process.
> 
> A possible use case is that the user wants to transfer the socket/
> UMEM ownerwhip to another process (via SYS_pidfd_getfd) and so
> would need to also remap this rings.
> 
> This will have no impact on current usages and just relaxes the
> remap limitation.
> 
> Signed-off-by: Nuno Gonçalves <nunog@fr24.com>
> ---
>  net/xdp/xsk.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 2ac58b282b5eb..2af4ff64b22bd 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -1300,10 +1300,11 @@ static int xsk_mmap(struct file *file, struct socket *sock,
>  {
>  	loff_t offset = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
>  	unsigned long size = vma->vm_end - vma->vm_start;
> +	int state = READ_ONCE(xs->state);
>  	struct xdp_sock *xs = xdp_sk(sock->sk);
>  	struct xsk_queue *q = NULL;
> 
> -	if (READ_ONCE(xs->state) != XSK_READY)
> +	if (!(state == XSK_READY || state == XSK_BOUND))
>  		return -EBUSY;
> 
>  	if (offset == XDP_PGOFF_RX_RING) {
> @@ -1314,9 +1315,11 @@ static int xsk_mmap(struct file *file, struct socket *sock,
>  		/* Matches the smp_wmb() in XDP_UMEM_REG */
>  		smp_rmb();
>  		if (offset == XDP_UMEM_PGOFF_FILL_RING)
> -			q = READ_ONCE(xs->fq_tmp);
> +			q = READ_ONCE(state == XSK_READY ? xs->fq_tmp :
> +							   xs->pool->fq);
>  		else if (offset == XDP_UMEM_PGOFF_COMPLETION_RING)
> -			q = READ_ONCE(xs->cq_tmp);
> +			q = READ_ONCE(state == XSK_READY ? xs->cq_tmp :
> +							   xs->pool->cq);
>  	}
> 
>  	if (!q)
> --
> 2.40.0


      reply	other threads:[~2023-03-20 10:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-19 22:08 [PATCH] xsk: allow remap of fill and/or completion rings Nuno Gonçalves
2023-03-20 10:04 ` Karlsson, Magnus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MW3PR11MB46023B056366E7B79E105549F7809@MW3PR11MB4602.namprd11.prod.outlook.com \
    --to=magnus.karlsson@intel.com \
    --cc=nunog@fr24.com \
    --cc=xdp-newbies@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).