Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1116149rwl; Fri, 24 Mar 2023 06:33:29 -0700 (PDT) X-Google-Smtp-Source: AKy350bXm5zDJek2UGycMhiUS4DbYGgIRdNHdvdavj+g/9AUJ9PFTnVraxESsHVEVTZPObdYGwQv X-Received: by 2002:a17:906:d784:b0:92f:5f00:db9c with SMTP id pj4-20020a170906d78400b0092f5f00db9cmr2970461ejb.23.1679664808760; Fri, 24 Mar 2023 06:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679664808; cv=none; d=google.com; s=arc-20160816; b=Gwaihsv6eAioCyUDwLyZr/fn3XAJVoMiQNUiiz04+/PbhVbSjG4fZdgM77y8T+Sifs MMIOxsah0a+2KDerksJ+vIH1dK8QEChgA9+bmUl9IkAq/+2zO+9YM5AFUV0UNaixNSEc B1+6YMX827RDlFvxtO3eP5KrYiKSvn3se13zOtq1JFCjWmwbalE1Ql6i80DnZ4Y8hUfO ewcnxmmdmAfv+/f0fvw3dJu/T3HL0ag4Rk+r7m/vOC+hvZUZg9BbJaImcwsb1EsGO6hj GB92pLB8sYlRQrUybYWttn0A5SoDwa/SVZo7vKtK2roBLMOLmEjYpn3FCzWbEke9f4Km M1uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9TWgGtgtUJ5ulwzvO8r2Booz+DyAosWcUpTNzBogezc=; b=aGjN9sDYuIhWGFSW5G2syTlNsPI0Y3f0fSrApsUVv7Xoo/rm2F7Tk1MTKZU6D9MmXf 9g2CEmsvhbs5o7yVF9dwuwPcmflhYGTf5rjkVFP5lf+cDPzPxc0uQPQIlC775zEDc425 KenJFeydu6fAgQ7Htd5FwYLFjfzoZolC4kbd5BGvtfCDbWgOszuDjkz5etqcOBiW/CuO GxFm8/0AuxSZxxSeJtjdPINO90ee+NSFK7oOnV3O1BErlgaX+E2G/QXGlCuEHq2WP3Kd KUlv5rd6LizosxQbAh4sxc1QUbS6GEOt0qySuSg4wcnGRKgBYYlO/yYWvUJFVDrzVj85 7Osg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="A/w6LUcR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qh19-20020a170906ecb300b008bc4db74272si21538137ejb.471.2023.03.24.06.33.04; Fri, 24 Mar 2023 06:33:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="A/w6LUcR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbjCXNad (ORCPT + 99 others); Fri, 24 Mar 2023 09:30:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbjCXNab (ORCPT ); Fri, 24 Mar 2023 09:30:31 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DF501702; Fri, 24 Mar 2023 06:30:29 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id r187so2129752ybr.6; Fri, 24 Mar 2023 06:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679664628; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9TWgGtgtUJ5ulwzvO8r2Booz+DyAosWcUpTNzBogezc=; b=A/w6LUcRP3gszxeyOCYcmTA4JZs95onD5n6II3XlBaPu7AxM4WHXVfLdO24epn+6Hh GnzOtpaiapAGXliF6nEDbzoW5oOBCkr3uh2RH86Y1Qg8Fxry6cIwzjPF6eBBmh+1t/Cd u9JDYwIDfYvoP4DFTs02+Nl/Ra6l/PrsuIWZW9WT3pgiTO6gSG8t5BlCGkIWj7gQ/ZNV Ciiz4UwOY9mdRGrIH1aCgXRtaPspowj0ydagvf1725me7M/NjkkvmJy1B9O3REFiUsuF ftaRkqLzuK9hcquJ7uRjiq3NWMmNXuXmEukQBGerxuOV5YFcnuLawYOFMViMTA+PdUpN /XwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679664628; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9TWgGtgtUJ5ulwzvO8r2Booz+DyAosWcUpTNzBogezc=; b=y7vG9iB0VTth6IKP/74IycTzeMXigAYXEcXjaUlT7MdJHh+Jtmn3zXDY0E3IZ53WHj bepTX8XRH4vpLy+4CRO7s24nCRRz0PKJZ52uuuE9N6d4CK8OxBOs6DdL1Hhqqwqnzypm bAbeJzbU1NxByAatc2tjr5iYIRnPNmoW9ifErMuH6Pvuy/SRrBT6lOtkw5ahjEor211s 5ZuqC/M39sK3rDKFHoc+9oVF8FOXYNIjGIB++nnM+3bhbj2HCpegZJuNC9JWa6e7N7PI 1bMNjAyo9RUSJ+KsedlxGyXwmwocCamemfheNMlg8UTvv7nT2WS5Qs4ExwXSENrENvzL K9jw== X-Gm-Message-State: AAQBX9cneZDmHI7vvndHqUQpFpZIlOJvLS9XRl/uLRv9fAV8AAKnMfmR 55UEG88uHgWXobzknq9KrFNM9eL2nkqkV11bm4OWxdxoS0IFnw== X-Received: by 2002:a05:6902:1247:b0:b78:4b00:7772 with SMTP id t7-20020a056902124700b00b784b007772mr268828ybu.5.1679664628254; Fri, 24 Mar 2023 06:30:28 -0700 (PDT) MIME-Version: 1.0 References: <20230324100222.13434-1-nunog@fr24.com> In-Reply-To: From: Magnus Karlsson Date: Fri, 24 Mar 2023 14:30:17 +0100 Message-ID: Subject: Re: [PATCH bpf-next V4] xsk: allow remap of fill and/or completion rings To: Maciej Fijalkowski Cc: =?UTF-8?Q?Nuno_Gon=C3=A7alves?= , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Jonathan Lemon , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Brauner , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 Mar 2023 at 13:22, Maciej Fijalkowski wrote: > > On Fri, Mar 24, 2023 at 10:02:22AM +0000, Nuno Gon=C3=A7alves wrote: > > 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 these rings > > into another process. > > > > A possible use case is that the user wants to transfer the socket/ > > UMEM ownership to another process (via SYS_pidfd_getfd) and so > > would need to also remap these rings. > > > > This will have no impact on current usages and just relaxes the > > remap limitation. > > > > Signed-off-by: Nuno Gon=C3=A7alves > > --- > > V3 -> V4: Remove undesired format changes > > V2 -> V3: Call READ_ONCE for each variable and not for the ternary oper= ator > > V1 -> V2: Format and comment changes > > thanks, it now looks good to me, i applied this locally and it builds, so= : > Reviewed-by: Maciej Fijalkowski > > but i am giving a last call to Magnus since he was acking this before. I have already acked it, but I can do it twice. Acked-by: Magnus Karlsson > > > > 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..cc1e7f15fa731 100644 > > --- a/net/xdp/xsk.c > > +++ b/net/xdp/xsk.c > > @@ -1301,9 +1301,10 @@ static int xsk_mmap(struct file *file, struct so= cket *sock, > > loff_t offset =3D (loff_t)vma->vm_pgoff << PAGE_SHIFT; > > unsigned long size =3D vma->vm_end - vma->vm_start; > > struct xdp_sock *xs =3D xdp_sk(sock->sk); > > + int state =3D READ_ONCE(xs->state); > > struct xsk_queue *q =3D NULL; > > > > - if (READ_ONCE(xs->state) !=3D XSK_READY) > > + if (state !=3D XSK_READY && state !=3D XSK_BOUND) > > return -EBUSY; > > > > if (offset =3D=3D XDP_PGOFF_RX_RING) { > > @@ -1314,9 +1315,11 @@ static int xsk_mmap(struct file *file, struct so= cket *sock, > > /* Matches the smp_wmb() in XDP_UMEM_REG */ > > smp_rmb(); > > if (offset =3D=3D XDP_UMEM_PGOFF_FILL_RING) > > - q =3D READ_ONCE(xs->fq_tmp); > > + q =3D state =3D=3D XSK_READY ? READ_ONCE(xs->fq_t= mp) : > > + READ_ONCE(xs->pool->fq); > > else if (offset =3D=3D XDP_UMEM_PGOFF_COMPLETION_RING) > > - q =3D READ_ONCE(xs->cq_tmp); > > + q =3D state =3D=3D XSK_READY ? READ_ONCE(xs->cq_t= mp) : > > + READ_ONCE(xs->pool->cq); > > } > > > > if (!q) > > -- > > 2.40.0 > >