Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp814122lqs; Tue, 5 Mar 2024 18:43:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWZ9ZohkikXEazo2+JY1oBmxCwwbMsxYJsc/xjWO9qE7pJBC+COhAm8wMa8Xy4+lgzRfKLn9te3/QNvkUaOkFAHzhD6xh+xYG7BR9buyA== X-Google-Smtp-Source: AGHT+IELebrzjWxGOg2HquZ9MAigZfmIkSLc/2NbVTSxzrLoeW1aZ9y0jpKormElD6OzF61vQhOj X-Received: by 2002:a17:902:f604:b0:1db:9fa2:3408 with SMTP id n4-20020a170902f60400b001db9fa23408mr4635696plg.42.1709693012707; Tue, 05 Mar 2024 18:43:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709693012; cv=pass; d=google.com; s=arc-20160816; b=eObVmxNuTnqAhx9KaAsLmSdI+afrF+/dyc8kEWz+4vCKVjVluAGbKgCjAmuDl8nMZO j/akT9oYc7vOwZwwNvuNCNwtoH2iMjcbTQ5p2O19s5VPjP5+hvEYXrdkijfzi9ZwoW7/ UDb4JdAog0B7XZzOQCKul4PFXGURvF6skRyVPzcCf/eulvMw3sF4zulVP3W9TqR10w6E iY7ifljxJkakjs8mH4FV87Cq99AB2MTuSfrDct8TQBmW2Ee5JgFb2FvfzxPq6Ha+gZxm pDYFOWvoMdRg7cbNc/AlbEJ67DFl419Ck2s75F63/8LRx7rxmip3KB6cVo3kMSjeaJ/S itrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=x2WY4uFfSORqsxmoN252fMsc5YpGsXMNwoTLggkrkUc=; fh=PSejWG+3+x61aVP3S/l9zYkQqWzJ3Cprny8J3GI3/tg=; b=rxHsdQnIS0BNvslXeDBn64M7hdXe81bxFMAORjAAX4u2xAZU54kC0X3AzoY0SA+6aa VNpelVThR3SwrvccCdefF6lAFD4tBpHCxmDqck1uy0t/qNj9FznwJurCD4+/N4lvH4FU N1p5+ZxngRIiNT4yVQyX4Pokqae1ojkTzwGvLU/JO1o2ITX1FCpIS9PJcwsk9RhYtE38 lmA0be3JLw4GobN2nQpZrEWwgznCr6IfcfvFRLtciRYrW7l6Tia+PKLiWXJD2du9dOn/ RjK2DUtPaaBz9GnJaodVHxdAxEEcrQc4vdD53psiOMmMtEARabXYt5H/fd2wMdAecjTD dMSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZFNSeEi6; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-93248-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l18-20020a170903245200b001db4f0f3698si11167554pls.458.2024.03.05.18.43.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 18:43:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93248-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZFNSeEi6; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-93248-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93248-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CEBD928BDDC for ; Wed, 6 Mar 2024 02:43:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28B3812B9A; Wed, 6 Mar 2024 02:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZFNSeEi6" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E06E1D51D for ; Wed, 6 Mar 2024 02:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709692973; cv=none; b=mdSvP+au+Ygu3Dw+yqIQqKzaQiGMLxeM75s/ReX5XHcXdIyqEBokBUkhvLgnxsqJtf1UsaFHXMW+Als/QaQiZU5oXGSaLT+d/xgicko/cuJCXNbwVd0uayJP6LHYGpL3BrojviRQXW7UYBZMLbM4kAxCB/i5uM0Rbop3QBrs6a8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709692973; c=relaxed/simple; bh=NvDvKdXSBfFKBtLGn84e/ck4Kn9xC15K+wg1+/TVvIE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=l9jdUOHRGkb90yjXzXMQecL83CcB0Df9JaRpnlj3gcDRhFPA3jN/6XcSK88la0O+pihvpJtDWSKNn2Im76c12zlQK97SvXSChdew9IlKDTLE+cfxXb1ey0hgz/V8DiLuIDsPwcXAKaO+4+bWkQLltyjWogzz3YDYbObVzJuG0YE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZFNSeEi6; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a45b6fcd5e8so32165966b.1 for ; Tue, 05 Mar 2024 18:42:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709692969; x=1710297769; darn=vger.kernel.org; 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=x2WY4uFfSORqsxmoN252fMsc5YpGsXMNwoTLggkrkUc=; b=ZFNSeEi6fJz1DxapDerPDO0oc3CCjhA4NKeWKjNh5mOF7RPy73sAJa+6d8Jl0hD4// qaWfnGJDRztzQdE2ONgL48DEla3ykgVII3xlYaOzktBdXeecXIwEZVtg6/f6zcJSbyCX +v2Pw8/EdMIoYJEAWnRtEM5Wsg6PMFK7cK+8MTNNuip90TSqu4T/KUDQbN7knCo4jkU6 XxmEhZhJtc0Xv79ozueLyCX+rP7eVEN6JxHPfclD5yooPfLL0R/mf0co4iPW0Kp4nVuU 0bn1Ttic5qrtTyM+vhJn3yWOo08SQZQt7OWKODQd9eXY3FFWNQ28hjWU0UeuyvPQb3qp LS6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709692969; x=1710297769; 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=x2WY4uFfSORqsxmoN252fMsc5YpGsXMNwoTLggkrkUc=; b=Ag4SkbBmUujdC9A+RV/YQ3k0SuO3X1QlVSm5Cxsdj/Sagq8bTbhzVKIfcv/YCy3bgn y7Y3x0MXnu8BBStE29YWiESV8jRUYvuyOIVdVwdYNXCOz1LD26/P9J6DJEEqeSprEjhd lQlvNdtymawSiMvj0T0H9mytfyzujpE8O+tH5kw5sb3MEgkflluV2077sUcC0jVQScnA wzf6S4+puMCQpz6JBYTZ1ehvWtmK6tHSZfujEpRQ1l8Vddmrd3e2Whm6GLWPo+vxM/aN XTlU9jHz70Ak/GGPRByaDGKCIO2rDEzciX2OSLQIXC+gE+N/o7fv2E7U1blapgAmAwNV rXFA== X-Forwarded-Encrypted: i=1; AJvYcCW86G/WaTM02fpOsUqwp9kQig1j/8BKlzzN9KQNazMZEgaSM6EOH1PTMMUV1nm1vAg0mAz0LjheyngeOBZ2203r23rJ5HYY9A1HADDy X-Gm-Message-State: AOJu0YxnOuy54UiOCRCAvlXXjDQf2WKRhCVyBFBug5A+8gY85jK7ztKP Nbw6EUHQhNwan8DF7i2Ip8GI4evVRaZtmIsbb/Lv16C5gis2jC8p/BvEZhOMasXjYnxC3JEFkgC gpUDY3PjqQB96I2H4F8RJDcl4Fycnp+0NscTa X-Received: by 2002:a17:906:2417:b0:a45:ad5d:98ac with SMTP id z23-20020a170906241700b00a45ad5d98acmr1779500eja.44.1709692968869; Tue, 05 Mar 2024 18:42:48 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240305020153.2787423-1-almasrymina@google.com> <20240305020153.2787423-10-almasrymina@google.com> <383c4870-167f-4123-bbf3-928db1463e01@davidwei.uk> In-Reply-To: <383c4870-167f-4123-bbf3-928db1463e01@davidwei.uk> From: Mina Almasry Date: Tue, 5 Mar 2024 18:42:35 -0800 Message-ID: Subject: Re: [RFC PATCH net-next v6 09/15] memory-provider: dmabuf devmem memory provider To: David Wei Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Andreas Larsson , Jesper Dangaard Brouer , Ilias Apalodimas , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Arnd Bergmann , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Pavel Begunkov , Jason Gunthorpe , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Jeroen de Borst , Praveen Kaligineedi , Willem de Bruijn , Kaiyuan Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 5, 2024 at 6:28=E2=80=AFPM David Wei wrote: > > On 2024-03-04 18:01, Mina Almasry wrote: > > + if (pool->p.queue) > > + binding =3D READ_ONCE(pool->p.queue->binding); > > + > > + if (binding) { > > + pool->mp_ops =3D &dmabuf_devmem_ops; > > + pool->mp_priv =3D binding; > > + } > > This is specific to TCP devmem. For ZC Rx we will need something more > generic to let us pass our own memory provider backend down to the page > pool. > > What about storing ops and priv void ptr in struct netdev_rx_queue > instead? Then we can both use it. Yes, this is dmabuf specific, I was thinking you'd define your own member of netdev_rx_queue, and then add something like this to page_pool_init: + if (pool->p.queue) + io_uring_metadata =3D READ_ONCE(pool->p.queue->io_uring_met= adata); + + /* We don't support rx-queues that are configured for both io_uring & dmabuf binding */ + BUG_ON(io_uring_metadata && binding); + + if (io_uring_metadata) { + pool->mp_ops =3D &io_uring_ops; + pool->mp_priv =3D io_uring_metadata; + } I.e., we share the pool->mp_ops and the pool->mp_priv but we don't really need to share the same netdev_rx_queue member. For me it's a dma-buf specific data structure (netdev_dmabuf_binding) and for you it's something else. page_pool_init() probably needs to validate that the queue is configured for dma-buf or io_uring but not both. If it's configured for both then the user is doing something funky we shouldn't support. Perhaps I can make the intention clearer by renaming 'binding' to something more specific to dma-buf like queue->dmabuf_binding, to make it clear that this is the dma-buf binding and not some other binding like io_uring? --=20 Thanks, Mina