From: Liang Chen <liangchen.linux@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
hawk@kernel.org, ilias.apalodimas@linaro.org,
linyunsheng@huawei.com, netdev@vger.kernel.org,
linux-mm@kvack.org, jasowang@redhat.com
Subject: Re: [PATCH net-next v7 1/4] page_pool: transition to reference count management after page draining
Date: Mon, 11 Dec 2023 11:31:06 +0800 [thread overview]
Message-ID: <CAKhg4tKXfos+M=rmu25B=dCmS_uzmBy743BB=6NBZgBMWnHobA@mail.gmail.com> (raw)
In-Reply-To: <20231208173816.2f32ad0f@kernel.org>
On Sat, Dec 9, 2023 at 9:38 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Wed, 6 Dec 2023 18:54:16 +0800 Liang Chen wrote:
> > -/* pp_frag_count represents the number of writers who can update the page
> > +/* pp_ref_count represents the number of writers who can update the page
> > * either by updating skb->data or via DMA mappings for the device.
> > * We can't rely on the page refcnt for that as we don't know who might be
> > * holding page references and we can't reliably destroy or sync DMA mappings
> > * of the fragments.
> > *
> > - * When pp_frag_count reaches 0 we can either recycle the page if the page
> > + * pp_ref_count initially corresponds to the number of fragments. However,
> > + * when multiple users start to reference a single fragment, for example in
> > + * skb_try_coalesce, the pp_ref_count will become greater than the number of
> > + * fragments.
> > + *
> > + * When pp_ref_count reaches 0 we can either recycle the page if the page
> > * refcnt is 1 or return it back to the memory allocator and destroy any
> > * mappings we have.
> > */
>
> Sorry to nit pick but I think this whole doc has to be rewritten
> completely. It does state the most important thing which is that
> the caller must have just allocated the page.
>
> How about:
>
> /**
> * page_pool_fragment_page() - split a fresh page into fragments
> * @.. fill these in
> *
> * pp_ref_count represents the number of outstanding references
> * to the page, which will be freed using page_pool APIs (rather
> * than page allocator APIs like put_page()). Such references are
> * usually held by page_pool-aware objects like skbs marked for
> * page pool recycling.
> *
> * This helper allows the caller to take (set) multiple references
> * to a freshly allocated page. The page must be freshly allocated
> * (have a pp_ref_count of 1). This is commonly done by drivers
> * and "fragment allocators" to save atomic operations - either
> * when they know upfront how many references they will need; or
> * to take MAX references and return the unused ones with a single
> * atomic dec(), instead of performing multiple atomic inc()
> * operations.
> */
>
> I think that's more informative at this stage of evolution of
> the page pool API, when most users aren't experts on internals.
> But feel free to disagree..
>
Thanks for the help! This is certainly better.
> > static inline void page_pool_fragment_page(struct page *page, long nr)
> > {
> > - atomic_long_set(&page->pp_frag_count, nr);
> > + atomic_long_set(&page->pp_ref_count, nr);
> > }
>
> The code itself and rest of the patches LGTM, although it would be
> great to get ACKs from pp maintainers..
next prev parent reply other threads:[~2023-12-11 3:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 10:54 [PATCH net-next v7 0/4] skbuff: Optimize SKB coalescing for page pool Liang Chen
2023-12-06 10:54 ` [PATCH net-next v7 1/4] page_pool: transition to reference count management after page draining Liang Chen
2023-12-09 1:38 ` Jakub Kicinski
2023-12-11 3:31 ` Liang Chen [this message]
2023-12-06 10:54 ` [PATCH net-next v7 2/4] page_pool: halve BIAS_MAX for multiple user references of a fragment Liang Chen
2023-12-06 10:54 ` [PATCH net-next v7 3/4] skbuff: Add a function to check if a page belongs to page_pool Liang Chen
2023-12-06 10:54 ` [PATCH net-next v7 4/4] skbuff: Optimization of SKB coalescing for page pool Liang Chen
2023-12-09 2:18 ` Mina Almasry
2023-12-11 3:38 ` Liang Chen
2023-12-11 4:21 ` Mina Almasry
2023-12-11 19:32 ` Jakub Kicinski
2023-12-11 20:07 ` Mina Almasry
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='CAKhg4tKXfos+M=rmu25B=dCmS_uzmBy743BB=6NBZgBMWnHobA@mail.gmail.com' \
--to=liangchen.linux@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-mm@kvack.org \
--cc=linyunsheng@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox