All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Mina Almasry <almasrymina@google.com>
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, linux-kselftest@vger.kernel.org,
	bpf@vger.kernel.org, linux-media@vger.kernel.org,
	dri-devel@lists.freedesktop.org,
	"Donald Hunter" <donald.hunter@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Ivan Kokshaysky" <ink@jurassic.park.msu.ru>,
	"Matt Turner" <mattst88@gmail.com>,
	"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Helge Deller" <deller@gmx.de>,
	"Andreas Larsson" <andreas@gaisler.com>,
	"Jesper Dangaard Brouer" <hawk@kernel.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Steffen Klassert" <steffen.klassert@secunet.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"David Ahern" <dsahern@kernel.org>,
	"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.com>,
	"Bagas Sanjaya" <bagasdotme@gmail.com>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Nikolay Aleksandrov" <razor@blackwall.org>,
	"Taehee Yoo" <ap420073@gmail.com>,
	"Pavel Begunkov" <asml.silence@gmail.com>,
	"David Wei" <dw@davidwei.uk>, "Jason Gunthorpe" <jgg@ziepe.ca>,
	"Yunsheng Lin" <linyunsheng@huawei.com>,
	"Shailend Chand" <shailend@google.com>,
	"Harshitha Ramamurthy" <hramamurthy@google.com>,
	"Shakeel Butt" <shakeel.butt@linux.dev>,
	"Jeroen de Borst" <jeroendb@google.com>,
	"Praveen Kaligineedi" <pkaligineedi@google.com>,
	"Willem de Bruijn" <willemb@google.com>,
	"Kaiyuan Zhang" <kaiyuanz@google.com>
Subject: Re: [PATCH net-next v16 04/13] netdev: netdevice devmem allocator
Date: Wed, 10 Jul 2024 12:55:33 -0700	[thread overview]
Message-ID: <20240710125533.7a14bbe7@kernel.org> (raw)
In-Reply-To: <CAHS8izOoM3YfcQorLJXL4H+t2OL+oJ4fPP5ZBJRhnH5AxsUqfQ@mail.gmail.com>

On Wed, 10 Jul 2024 12:29:58 -0700 Mina Almasry wrote:
> On Wed, Jul 10, 2024 at 9:37 AM Jakub Kicinski <kuba@kernel.org> wrote:
> > On Wed, 10 Jul 2024 00:17:37 +0000 Mina Almasry wrote:  
> > > +     net_devmem_dmabuf_binding_get(binding);  
> >
> > Why does every iov need to hold a ref? pp holds a ref and does its own
> > accounting, so it won't disappear unless all the pages are returned.  
> 
> I guess it doesn't really need to, but this is the design/approach I
> went with, and I actually prefer it a bit. The design is borrowed from
> how struct dev_pagemap does this, IIRC. Every page allocated from the
> pgmap holds a reference to the pgmap to ensure the pgmap doesn't go
> away while some page that originated from it is out in the wild, and
> similarly I did so in the binding here.

Oh, you napi_pp_put_page() on the other end! I can see how that could
be fine.

> We could assume that the page_pool is accounting iovs for us, but that
> is not always true, right? page_pool_return_page() disconnects a
> netmem from the page_pool and AFAIU the page_pool can go away while
> there is such a netmem still in use in the net stack. Currently this
> can't happen with iovs because I currently don't support non-pp
> refcounting for iovs (so they're always recyclable), but you have a
> comment on the other patch asking why that works; depending on how we
> converge on that conversation, the details of how the pp refcounting
> could change.

Even then - we could take the ref as the page "leaks" out of the pool,
rather than doing it on the fast path, right? Or just BUG_ON() 'cause
that reference ain't coming back ;)

> It's nice to know that the binding refcounting will work regardless of
> the details of how the pp refcounting works. IMHO having the binding
> rely on the pp refcounting to ensure all the iovs are freed introduces
> some fragility.
> 
> Additionally IMO the net_devmem_dmabuf_binding_get/put aren't so
> expensive to want to optimize out, right? The allocation is a slow
> path anyway and the fast path recycles netmem.

Yes, I should have read patch 10. I think it's avoidable :) but with
recycling it can indeed perform just fine (do you happen to have
recycling rate stats from prod runs?)

  reply	other threads:[~2024-07-10 19:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10  0:17 [PATCH net-next v16 00/13] Device Memory TCP Mina Almasry
2024-07-10  0:17 ` [PATCH net-next v16 01/13] netdev: add netdev_rx_queue_restart() Mina Almasry
2024-07-10 15:35   ` Jakub Kicinski
2024-07-10  0:17 ` [PATCH net-next v16 02/13] net: netdev netlink api to bind dma-buf to a net device Mina Almasry
2024-07-10 10:30   ` Donald Hunter
2024-07-10 15:43   ` Jakub Kicinski
2024-07-10  0:17 ` [PATCH net-next v16 03/13] netdev: support binding dma-buf to netdevice Mina Almasry
2024-07-10 15:56   ` Jakub Kicinski
2024-07-10  0:17 ` [PATCH net-next v16 04/13] netdev: netdevice devmem allocator Mina Almasry
2024-07-10 16:36   ` Jakub Kicinski
2024-07-10 19:29     ` Mina Almasry
2024-07-10 19:55       ` Jakub Kicinski [this message]
2024-07-10 22:45         ` Mina Almasry
2024-07-10  0:17 ` [PATCH net-next v16 05/13] page_pool: devmem support Mina Almasry
2024-07-10 16:49   ` Jakub Kicinski
2024-07-10 20:29     ` Mina Almasry
2024-07-11  1:22       ` Jakub Kicinski
2024-07-10 23:42     ` Mina Almasry
2024-07-11  1:23       ` Jakub Kicinski
2024-07-11 20:57         ` Mina Almasry
2024-07-11 21:41           ` Jakub Kicinski
2024-07-10  0:17 ` [PATCH net-next v16 06/13] memory-provider: dmabuf devmem memory provider Mina Almasry
2024-07-10  0:17 ` [PATCH net-next v16 07/13] net: support non paged skb frags Mina Almasry
2024-07-10  0:17 ` [PATCH net-next v16 08/13] net: add support for skbs with unreadable frags Mina Almasry
2024-07-10  0:17 ` [PATCH net-next v16 09/13] tcp: RX path for devmem TCP Mina Almasry
2024-07-10  0:17 ` [PATCH net-next v16 10/13] net: add SO_DEVMEM_DONTNEED setsockopt to release RX frags Mina Almasry
2024-07-10  0:17 ` [PATCH net-next v16 11/13] net: add devmem TCP documentation Mina Almasry
2024-07-10 10:28   ` Donald Hunter
2024-07-10  0:17 ` [PATCH net-next v16 12/13] selftests: add ncdevmem, netcat for devmem TCP Mina Almasry
2024-07-11  0:44   ` John Hubbard
2024-07-11 15:28     ` Mina Almasry
2024-07-11 18:34       ` John Hubbard
2024-07-10  0:17 ` [PATCH net-next v16 13/13] netdev: add dmabuf introspection Mina Almasry
2024-07-11  1:35   ` Jakub Kicinski

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=20240710125533.7a14bbe7@kernel.org \
    --to=kuba@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=almasrymina@google.com \
    --cc=andreas@gaisler.com \
    --cc=ap420073@gmail.com \
    --cc=arnd@arndb.de \
    --cc=asml.silence@gmail.com \
    --cc=bagasdotme@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=donald.hunter@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dsahern@kernel.org \
    --cc=dw@davidwei.uk \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=hch@infradead.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=hramamurthy@google.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=ink@jurassic.park.msu.ru \
    --cc=jeroendb@google.com \
    --cc=jgg@ziepe.ca \
    --cc=kaiyuanz@google.com \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linyunsheng@huawei.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mattst88@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pkaligineedi@google.com \
    --cc=razor@blackwall.org \
    --cc=richard.henderson@linaro.org \
    --cc=rostedt@goodmis.org \
    --cc=shailend@google.com \
    --cc=shakeel.butt@linux.dev \
    --cc=shuah@kernel.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tsbogend@alpha.franken.de \
    --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.