mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>, netdev@vger.kernel.org
Cc: brouer@redhat.com, alexander.duyck@gmail.com,
	Alexander Duyck <alexanderduyck@fb.com>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] page_pool: add a comment explaining the fragment counter usage
Date: Sat, 18 Feb 2023 20:53:02 +0100	[thread overview]
Message-ID: <04a324be-69d1-7378-8e7f-0f0d85c6c09d@redhat.com> (raw)
In-Reply-To: <20230217222130.85205-1-ilias.apalodimas@linaro.org>


On 17/02/2023 23.21, Ilias Apalodimas wrote:
> When reading the page_pool code the first impression is that keeping
> two separate counters, one being the page refcnt and the other being
> fragment pp_frag_count, is counter-intuitive.
> 
> However without that fragment counter we don't know when to reliably
> destroy or sync the outstanding DMA mappings.  So let's add a comment
> explaining this part.
> 
> Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>


> ---
> Changes since v2:
>   - Removed a uneeded commas on the comment
> Changes since v1:
>   - Update the comment withe the correct description for pp_frag_count
>   include/net/page_pool.h | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/include/net/page_pool.h b/include/net/page_pool.h
> index 34bf531ffc8d..ddfa0b328677 100644
> --- a/include/net/page_pool.h
> +++ b/include/net/page_pool.h
> @@ -277,6 +277,16 @@ void page_pool_put_defragged_page(struct page_pool *pool, struct page *page,
>   				  unsigned int dma_sync_size,
>   				  bool allow_direct);
> 
> +/* pp_frag_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
> + * refcnt is 1 or return it back to the memory allocator and destroy any
> + * mappings we have.
> + */
>   static inline void page_pool_fragment_page(struct page *page, long nr)
>   {
>   	atomic_long_set(&page->pp_frag_count, nr);
> --
> 2.38.1
> 


  reply	other threads:[~2023-02-18 19:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 22:21 Ilias Apalodimas
2023-02-18 19:53 ` Jesper Dangaard Brouer [this message]
2023-02-21  9:12 ` Paolo Abeni
2023-02-21 17:14 ` Jakub Kicinski
2023-02-21 17:21   ` Ilias Apalodimas
2023-02-21 17:30 ` patchwork-bot+netdevbpf

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=04a324be-69d1-7378-8e7f-0f0d85c6c09d@redhat.com \
    --to=jbrouer@redhat.com \
    --cc=alexander.duyck@gmail.com \
    --cc=alexanderduyck@fb.com \
    --cc=brouer@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®