From: Leon Romanovsky <leon@kernel.org>
To: Mina Almasry <almasrymina@google.com>
Cc: "Kaiyuan Zhang" <kaiyuanz@google.com>,
dri-devel@lists.freedesktop.org,
"Eric Dumazet" <edumazet@google.com>,
sdf@google.com, "Sumit Semwal" <sumit.semwal@linaro.org>,
"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"Hari Ramakrishnan" <rharix@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
linux-media@vger.kernel.org,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Andy Lutomirski" <luto@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Dan Williams" <dan.j.williams@intel.com>,
"Willem de Bruijn" <willemb@google.com>,
netdev@vger.kernel.org, "David Ahern" <dsahern@kernel.org>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"David S. Miller" <davem@davemloft.net>,
stephen@networkplumber.org,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [RFC PATCH v2 02/11] netdev: implement netlink api to bind dma-buf to netdevice
Date: Sun, 13 Aug 2023 14:26:50 +0300 [thread overview]
Message-ID: <20230813112650.GK7707@unreal> (raw)
In-Reply-To: <20230810015751.3297321-3-almasrymina@google.com>
On Wed, Aug 09, 2023 at 06:57:38PM -0700, Mina Almasry wrote:
> Add a netdev_dmabuf_binding struct which represents the
> dma-buf-to-netdevice binding. The netlink API will bind the dma-buf to
> an rx queue on the netdevice. On the binding, the dma_buf_attach
> & dma_buf_map_attachment will occur. The entries in the sg_table from
> mapping will be inserted into a genpool to make it ready
> for allocation.
>
> The chunks in the genpool are owned by a dmabuf_chunk_owner struct which
> holds the dma-buf offset of the base of the chunk and the dma_addr of
> the chunk. Both are needed to use allocations that come from this chunk.
>
> We create a new type that represents an allocation from the genpool:
> page_pool_iov. We setup the page_pool_iov allocation size in the
> genpool to PAGE_SIZE for simplicity: to match the PAGE_SIZE normally
> allocated by the page pool and given to the drivers.
>
> The user can unbind the dmabuf from the netdevice by closing the netlink
> socket that established the binding. We do this so that the binding is
> automatically unbound even if the userspace process crashes.
>
> The binding and unbinding leaves an indicator in struct netdev_rx_queue
> that the given queue is bound, but the binding doesn't take effect until
> the driver actually reconfigures its queues, and re-initializes its page
> pool. This issue/weirdness is highlighted in the memory provider
> proposal[1], and I'm hoping that some generic solution for all
> memory providers will be discussed; this patch doesn't address that
> weirdness again.
>
> The netdev_dmabuf_binding struct is refcounted, and releases its
> resources only when all the refs are released.
>
> [1] https://lore.kernel.org/netdev/20230707183935.997267-1-kuba@kernel.org/
>
> Signed-off-by: Willem de Bruijn <willemb@google.com>
> Signed-off-by: Kaiyuan Zhang <kaiyuanz@google.com>
>
> Signed-off-by: Mina Almasry <almasrymina@google.com>
> ---
> include/linux/netdevice.h | 57 ++++++++++++
> include/net/page_pool.h | 27 ++++++
> net/core/dev.c | 178 ++++++++++++++++++++++++++++++++++++++
> net/core/netdev-genl.c | 101 ++++++++++++++++++++-
> 4 files changed, 361 insertions(+), 2 deletions(-)
<...>
> +void __netdev_devmem_binding_free(struct netdev_dmabuf_binding *binding);
> +
> +static inline void
> +netdev_devmem_binding_get(struct netdev_dmabuf_binding *binding)
> +{
> + refcount_inc(&binding->ref);
> +}
> +
> +static inline void
> +netdev_devmem_binding_put(struct netdev_dmabuf_binding *binding)
> +{
> + if (!refcount_dec_and_test(&binding->ref))
> + return;
> +
> + __netdev_devmem_binding_free(binding);
> +}
Not a big deal, but it looks like reimplemented version of kref_get/kref_put to me.
Thanks
WARNING: multiple messages have this Message-ID (diff)
From: Leon Romanovsky <leon@kernel.org>
To: Mina Almasry <almasrymina@google.com>
Cc: netdev@vger.kernel.org, linux-media@vger.kernel.org,
dri-devel@lists.freedesktop.org,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"David Ahern" <dsahern@kernel.org>,
"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"Hari Ramakrishnan" <rharix@google.com>,
"Dan Williams" <dan.j.williams@intel.com>,
"Andy Lutomirski" <luto@kernel.org>,
stephen@networkplumber.org, sdf@google.com,
"Willem de Bruijn" <willemb@google.com>,
"Kaiyuan Zhang" <kaiyuanz@google.com>
Subject: Re: [RFC PATCH v2 02/11] netdev: implement netlink api to bind dma-buf to netdevice
Date: Sun, 13 Aug 2023 14:26:50 +0300 [thread overview]
Message-ID: <20230813112650.GK7707@unreal> (raw)
In-Reply-To: <20230810015751.3297321-3-almasrymina@google.com>
On Wed, Aug 09, 2023 at 06:57:38PM -0700, Mina Almasry wrote:
> Add a netdev_dmabuf_binding struct which represents the
> dma-buf-to-netdevice binding. The netlink API will bind the dma-buf to
> an rx queue on the netdevice. On the binding, the dma_buf_attach
> & dma_buf_map_attachment will occur. The entries in the sg_table from
> mapping will be inserted into a genpool to make it ready
> for allocation.
>
> The chunks in the genpool are owned by a dmabuf_chunk_owner struct which
> holds the dma-buf offset of the base of the chunk and the dma_addr of
> the chunk. Both are needed to use allocations that come from this chunk.
>
> We create a new type that represents an allocation from the genpool:
> page_pool_iov. We setup the page_pool_iov allocation size in the
> genpool to PAGE_SIZE for simplicity: to match the PAGE_SIZE normally
> allocated by the page pool and given to the drivers.
>
> The user can unbind the dmabuf from the netdevice by closing the netlink
> socket that established the binding. We do this so that the binding is
> automatically unbound even if the userspace process crashes.
>
> The binding and unbinding leaves an indicator in struct netdev_rx_queue
> that the given queue is bound, but the binding doesn't take effect until
> the driver actually reconfigures its queues, and re-initializes its page
> pool. This issue/weirdness is highlighted in the memory provider
> proposal[1], and I'm hoping that some generic solution for all
> memory providers will be discussed; this patch doesn't address that
> weirdness again.
>
> The netdev_dmabuf_binding struct is refcounted, and releases its
> resources only when all the refs are released.
>
> [1] https://lore.kernel.org/netdev/20230707183935.997267-1-kuba@kernel.org/
>
> Signed-off-by: Willem de Bruijn <willemb@google.com>
> Signed-off-by: Kaiyuan Zhang <kaiyuanz@google.com>
>
> Signed-off-by: Mina Almasry <almasrymina@google.com>
> ---
> include/linux/netdevice.h | 57 ++++++++++++
> include/net/page_pool.h | 27 ++++++
> net/core/dev.c | 178 ++++++++++++++++++++++++++++++++++++++
> net/core/netdev-genl.c | 101 ++++++++++++++++++++-
> 4 files changed, 361 insertions(+), 2 deletions(-)
<...>
> +void __netdev_devmem_binding_free(struct netdev_dmabuf_binding *binding);
> +
> +static inline void
> +netdev_devmem_binding_get(struct netdev_dmabuf_binding *binding)
> +{
> + refcount_inc(&binding->ref);
> +}
> +
> +static inline void
> +netdev_devmem_binding_put(struct netdev_dmabuf_binding *binding)
> +{
> + if (!refcount_dec_and_test(&binding->ref))
> + return;
> +
> + __netdev_devmem_binding_free(binding);
> +}
Not a big deal, but it looks like reimplemented version of kref_get/kref_put to me.
Thanks
next prev parent reply other threads:[~2023-08-13 11:27 UTC|newest]
Thread overview: 109+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 1:57 [RFC PATCH v2 00/11] Device Memory TCP Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 01/11] net: add netdev netlink api to bind dma-buf to a net device Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 16:04 ` Samudrala, Sridhar
2023-08-10 16:04 ` Samudrala, Sridhar
2023-08-11 2:19 ` Mina Almasry
2023-08-11 2:19 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 02/11] netdev: implement netlink api to bind dma-buf to netdevice Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-13 11:26 ` Leon Romanovsky [this message]
2023-08-13 11:26 ` Leon Romanovsky
2023-08-14 1:10 ` David Ahern
2023-08-14 1:10 ` David Ahern
2023-08-14 3:15 ` Mina Almasry
2023-08-14 3:15 ` Mina Almasry
2023-08-16 0:16 ` Jakub Kicinski
2023-08-16 16:12 ` Willem de Bruijn
2023-08-18 1:33 ` David Ahern
2023-08-18 2:09 ` Jakub Kicinski
2023-08-18 2:21 ` David Ahern
2023-08-18 21:52 ` Mina Almasry
2023-08-19 1:34 ` David Ahern
2023-08-19 2:06 ` Jakub Kicinski
2023-08-19 3:30 ` David Ahern
2023-08-19 14:18 ` Willem de Bruijn
2023-08-19 17:59 ` Mina Almasry
2023-08-21 21:16 ` Jakub Kicinski
2023-08-22 0:38 ` Willem de Bruijn
2023-08-22 1:51 ` Jakub Kicinski
2023-08-22 3:19 ` David Ahern
2023-08-30 12:38 ` Yunsheng Lin
2023-08-30 12:38 ` Yunsheng Lin
2023-09-08 0:47 ` David Wei
2023-09-08 0:47 ` David Wei
2023-08-10 1:57 ` [RFC PATCH v2 03/11] netdev: implement netdevice devmem allocator Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 04/11] memory-provider: updates to core provider API for devmem TCP Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 05/11] memory-provider: implement dmabuf devmem memory provider Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 06/11] page-pool: add device memory support Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-19 9:51 ` Jesper Dangaard Brouer
2023-08-19 9:51 ` Jesper Dangaard Brouer
2023-08-19 14:08 ` Willem de Bruijn
2023-08-19 14:08 ` Willem de Bruijn
2023-08-19 15:22 ` Jesper Dangaard Brouer
2023-08-19 15:22 ` Jesper Dangaard Brouer
2023-08-19 15:49 ` David Ahern
2023-08-19 15:49 ` David Ahern
2023-08-19 16:12 ` Willem de Bruijn
2023-08-19 16:12 ` Willem de Bruijn
2023-08-21 21:31 ` Jakub Kicinski
2023-08-21 21:31 ` Jakub Kicinski
2023-08-22 0:58 ` Willem de Bruijn
2023-08-22 0:58 ` Willem de Bruijn
2023-08-19 16:11 ` Willem de Bruijn
2023-08-19 16:11 ` Willem de Bruijn
2023-08-19 20:24 ` Mina Almasry
2023-08-19 20:24 ` Mina Almasry
2023-08-19 20:27 ` Mina Almasry
2023-08-19 20:27 ` Mina Almasry
2023-09-08 2:32 ` David Wei
2023-09-08 2:32 ` David Wei
2023-08-22 6:05 ` Mina Almasry
2023-08-22 6:05 ` Mina Almasry
2023-08-22 12:24 ` Jesper Dangaard Brouer
2023-08-22 12:24 ` Jesper Dangaard Brouer
2023-08-22 23:33 ` Mina Almasry
2023-08-22 23:33 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 07/11] net: support non paged skb frags Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 08/11] net: add support for skbs with unreadable frags Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 09/11] tcp: implement recvmsg() RX path for devmem TCP Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 10/11] net: add SO_DEVMEM_DONTNEED setsockopt to release RX pages Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 1:57 ` [RFC PATCH v2 11/11] selftests: add ncdevmem, netcat for devmem TCP Mina Almasry
2023-08-10 1:57 ` Mina Almasry
2023-08-10 10:29 ` [RFC PATCH v2 00/11] Device Memory TCP Christian König
2023-08-10 10:29 ` Christian König
2023-08-10 16:06 ` Jason Gunthorpe
2023-08-10 16:06 ` Jason Gunthorpe
2023-08-10 18:44 ` Mina Almasry
2023-08-10 18:44 ` Mina Almasry
2023-08-10 18:58 ` Jason Gunthorpe
2023-08-10 18:58 ` Jason Gunthorpe
2023-08-11 1:56 ` Mina Almasry
2023-08-11 1:56 ` Mina Almasry
2023-08-11 11:02 ` Christian König
2023-08-11 11:02 ` Christian König
2023-08-14 1:12 ` David Ahern
2023-08-14 1:12 ` David Ahern
2023-08-14 2:11 ` Mina Almasry
2023-08-14 2:11 ` Mina Almasry
2023-08-17 18:00 ` Pavel Begunkov
2023-08-17 18:00 ` Pavel Begunkov
2023-08-17 22:18 ` Mina Almasry
2023-08-17 22:18 ` Mina Almasry
2023-08-23 22:52 ` David Wei
2023-08-23 22:52 ` David Wei
2023-08-24 3:35 ` David Ahern
2023-08-24 3:35 ` David Ahern
2023-08-15 13:38 ` David Laight
2023-08-15 13:38 ` David Laight
2023-08-15 14:41 ` Willem de Bruijn
2023-08-15 14:41 ` Willem de Bruijn
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=20230813112650.GK7707@unreal \
--to=leon@kernel.org \
--cc=almasrymina@google.com \
--cc=arnd@arndb.de \
--cc=christian.koenig@amd.com \
--cc=dan.j.williams@intel.com \
--cc=davem@davemloft.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=jgg@ziepe.ca \
--cc=kaiyuanz@google.com \
--cc=kuba@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=luto@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rharix@google.com \
--cc=sdf@google.com \
--cc=stephen@networkplumber.org \
--cc=sumit.semwal@linaro.org \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.