Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp817411lqs; Tue, 5 Mar 2024 18:55:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXIshx6IaRRzyiIq94x9aL62HjjMC9u//ibxQeVYAccEJENxkrLx7sj2bqFt4M/uzKiXBzeakI9Dk6HfLwHU6g7NG6JvKq+TU7+TQzsmA== X-Google-Smtp-Source: AGHT+IF+iqIIF+gE4xcjKGaJ/C0MfqT/H6EYF/E2sIZcwmPYcCmFTdmtWXtXAXK2+oqDXORiGXe8 X-Received: by 2002:a05:622a:50c:b0:42e:eb94:c151 with SMTP id l12-20020a05622a050c00b0042eeb94c151mr4500079qtx.44.1709693702673; Tue, 05 Mar 2024 18:55:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709693702; cv=pass; d=google.com; s=arc-20160816; b=QbIt+o51An94p/qzwsAvwt/23rcBEMdfAfBR7OK9SzXk3Z/UiCI+QgCDRTJCcuTXks dIfXpJNmqcHRQn5P26pHgHzaEx18dK9hmTv0oz0Eu73Ke+vmaCDQq7CHDsL6rNgiZMYW LX+aQn36Y/C6nMpIHUkoMhr/uWnOX1G5xywBeS2hAszcLT9b6MVWPhEa9HxLYVqsW3Bx 3Ux75akGDtDDZ9ZZ2gnkxN00gMwjVo57sjqPW+EGQKpjIijvjX3GdC1iZ2q8oXFRZrJa +fZCOEEG0TiRXe95YiImwOB8h8TE1/qBcjGHKbsYpwEliFKAt49u5m/nR+slcBgK58AH XDGQ== 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=eS/C6JRe/LZxR5BB0/jvRViDTj3F8vBSe/WWRgNeFIA=; fh=Ux8+q1J5eyu7TYDIriZzkdNYZ559lNXVaCI2itGxRsM=; b=v8fPyUrnoWqiuKhKLudI439WPsTFVb/HKMn+LaTPSD03YRuM/RsAAH/qx84JFeVok4 jNKfBI7ge3ChoaSHNc1DV+JMYu7VK8N8ceo9PfD5dkHnCZikD+U9idHAX2m4gPLJr4UD h5F8PR2+T0sqvcInKNRg8qih7X8eRagj1qhwKn7aT2fr8Y6Np1LRP5nSh9NBs2jjHI2a 7htsdz4ia15s0xjXTArj77g/FAwuMHEcMTVjoPpf7blmVo2A34BZhn08Jsc8hNswl72p yRi+nRMC2scFFEk+pIVcWs0aB14gcJrFOB0oT3tY0RXHwJ1qAlyCbx3fjQPzyxUlCOd0 iZ4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FfspCDPZ; 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-93253-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93253-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r8-20020a05622a034800b0042edeafa85fsi9115958qtw.159.2024.03.05.18.55.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 18:55:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93253-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FfspCDPZ; 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-93253-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93253-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 52C231C20A31 for ; Wed, 6 Mar 2024 02:55:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B686E11737; Wed, 6 Mar 2024 02:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FfspCDPZ" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 5B9EF12E75 for ; Wed, 6 Mar 2024 02:54:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709693684; cv=none; b=WrTX9hfOO+DNE6bSI55wa1nHVUEwvTf+U9fKuzaptE4n3ejTnuT0Obrvl9E7Q9oEzWQmQmwTATL8jFpOPwWgbTxBrKXjGJGiwQpDu2yk9plRWV2d8hXb46AEy8RL2sCzP2FoHKxAYDCXA4zfK7KWDvy64CIignNlL70+/VwADI8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709693684; c=relaxed/simple; bh=rCsQQP7xgQocqgJZyTCewEFa4pqWP3bm2r+qfnB/Kdw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=nUdWlEFvgC5PBRO5jVcewTpnxXg4zYw/pHPy4UrrfCF8ez4ID89kjHY92kQ6BgqxBUSL58wI6Lcc+ITbqRSWTIEL3B0+8vj7T4bkQJRok3ILwKMOnlPHr1YR5PDKxQx3qsHB5uTJ//Crr2L7eG8q5db6gcbLtCA7V6kyh+aib28= 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=FfspCDPZ; arc=none smtp.client-ip=209.85.218.48 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-f48.google.com with SMTP id a640c23a62f3a-a2f22bfb4e6so195771866b.0 for ; Tue, 05 Mar 2024 18:54:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709693681; x=1710298481; 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=eS/C6JRe/LZxR5BB0/jvRViDTj3F8vBSe/WWRgNeFIA=; b=FfspCDPZNW8S7Qf7wpydUp7nMkxbIvbEb4ID33aWUPwHOYvxyiL5+xjC/RGuYky5nJ UXbu0gXQCFwnw50zF+4eh5urGT9USQAfcXkEasQoB328Tb8CE77MTWKT72cElYJh0wiU E8M6JwS0IqClv/VPW882Nqjm33OxkixBNmv2B1WPXiL5arG8e00lOAa7AfTo3NB4z5xf jcpIGJ9Llm7DNOCjp3Jw3H51L90Ew0/AcaBWuTDJDOQG4bdnCW1kNOzZmO/JeKseNhq8 VZCcpvUcpy7bLKHJluNjLXFu8vbMbxapQ9qoBZgzezbUe/OupdB7FZDjPG1+nCvQ0lcD tgYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709693681; x=1710298481; 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=eS/C6JRe/LZxR5BB0/jvRViDTj3F8vBSe/WWRgNeFIA=; b=rRwqaKEC9iYLLe+eZ8qqK+cex5ql0adLximc81HEChSIIFY7VP2dHSigp991k4Xr70 S7z2LME4KjG4lH8Ah4vc3VYYVrKNG0xh2INEvpXOTYmj+AYxFJqSXO8KWLSKHFP6D1Gg 5Ndec1j3HnVJvcAZ6GNrhzyW7Bby/YwFsxbetyHJbBq/y9TemVnvgxnRylrzxZGmASID 0441aB/nSLjP3ojVb1PqO55vxYoT/ThA2whCkJjqjKNHjLvixqufUkTd/ty41LyKg6EC wcCIA6jklKuYQr8UktcFWj5oMQZsobmp6W6gYVmYpcOd7FbgqU8EJn1ZjyfRSMJKuMig HvwA== X-Forwarded-Encrypted: i=1; AJvYcCXzPVXqJ7l7Q0ETZu5R/3LekfEdGjOApMN3VZU//gxbjwrGFtk+qezMZ/px+4LudDcbvxblzZDTEvGpi1pSLLyahDGP23LbQ8CaWmxh X-Gm-Message-State: AOJu0YyG6XPzfYmGkgOoyjMY2zX5MAsEv9aKeLV3IKnStcVOiJNzfuLS GtqWIL4R/6S2LIAMPbKrR9ecskVxlhQ3mtdzkAeDZwxQM3LuOwY+dmW8A4g5Uh7UZwbGUY8Hdqz RZohAnl/dUdNyaqTY8rbqOS/Wfi9I7uW6xa+3 X-Received: by 2002:a17:906:4551:b0:a45:270e:3617 with SMTP id s17-20020a170906455100b00a45270e3617mr5771839ejq.27.1709693680497; Tue, 05 Mar 2024 18:54:40 -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> <6562b8b0-6cc0-4652-b746-75549801c002@davidwei.uk> In-Reply-To: <6562b8b0-6cc0-4652-b746-75549801c002@davidwei.uk> From: Mina Almasry Date: Tue, 5 Mar 2024 18:54:28 -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:47=E2=80=AFPM David Wei wrote: > > On 2024-03-05 18:42, Mina Almasry wrote: > > 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 pag= e > >> 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= _metadata); > > + > > + /* 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. > > This adds size to struct netdev_rx_queue and requires checks on whether > both are set. There can be thousands of these structs at any one time so > if we don't need to add size unnecessarily then that would be best. > > We can disambiguate by comparing &mp_ops and then cast the void ptr to > our impl specific objects. > > What do you not like about this approach? > I was thinking it leaks page_pool specifics into a generic struct unrelated to the page pool like netdev_rx_queue. My mental model is that the rx-queue just says that it's bound to a dma-buf/io_uring unaware of page_pool internals, and the page pool internals figure out what to do from there. Currently netdev_rx_queue.h doesn't include net/page_pool/types.h for example because there is no dependency between netdev_rx_queue & page_pool, I think this change would add a dependency. But I concede it does not matter much AFAICT, I can certainly change the netdev_rx_queue to hold the mp_priv & mp_ops directly and include net/page_pool/types.h if you prefer that. I'll look into applying this change in the next iteration if there are no objections. > > > > 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