public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Lorenzo Bianconi <lorenzo@kernel.org>, netdev@vger.kernel.org
Cc: bpf@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	lorenzo.bianconi@redhat.com, brouer@redhat.com,
	ilias.apalodimas@linaro.org
Subject: RE: [PATCH v5 net-nex 2/5] net: page_pool: add bulk support for ptr_ring
Date: Wed, 11 Nov 2020 01:29:48 -0800	[thread overview]
Message-ID: <5fabaf0c4a68a_bb2602085a@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <1229970bf6f36fd4689169a2e47fdcc664d28366.1605020963.git.lorenzo@kernel.org>

Lorenzo Bianconi wrote:
> Introduce the capability to batch page_pool ptr_ring refill since it is
> usually run inside the driver NAPI tx completion loop.
> 
> Suggested-by: Jesper Dangaard Brouer <brouer@redhat.com>
> Co-developed-by: Jesper Dangaard Brouer <brouer@redhat.com>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>  include/net/page_pool.h | 26 ++++++++++++++++
>  net/core/page_pool.c    | 69 +++++++++++++++++++++++++++++++++++------
>  net/core/xdp.c          |  9 ++----
>  3 files changed, 87 insertions(+), 17 deletions(-)

[...]

> +/* Caller must not use data area after call, as this function overwrites it */
> +void page_pool_put_page_bulk(struct page_pool *pool, void **data,
> +			     int count)
> +{
> +	int i, bulk_len = 0, pa_len = 0;
> +
> +	for (i = 0; i < count; i++) {
> +		struct page *page = virt_to_head_page(data[i]);
> +
> +		page = __page_pool_put_page(pool, page, -1, false);
> +		/* Approved for bulk recycling in ptr_ring cache */
> +		if (page)
> +			data[bulk_len++] = page;
> +	}
> +
> +	if (unlikely(!bulk_len))
> +		return;
> +
> +	/* Bulk producer into ptr_ring page_pool cache */
> +	page_pool_ring_lock(pool);
> +	for (i = 0; i < bulk_len; i++) {
> +		if (__ptr_ring_produce(&pool->ring, data[i]))
> +			data[pa_len++] = data[i];

How about bailing out on the first error? bulk_len should be less than
16 right, so should we really keep retying hoping ring->size changes?

> +	}
> +	page_pool_ring_unlock(pool);
> +
> +	if (likely(!pa_len))
> +		return;
> +
> +	/* ptr_ring cache full, free pages outside producer lock since
> +	 * put_page() with refcnt == 1 can be an expensive operation
> +	 */
> +	for (i = 0; i < pa_len; i++)
> +		page_pool_return_page(pool, data[i]);
> +}
> +EXPORT_SYMBOL(page_pool_put_page_bulk);
> +

Otherwise LGTM.

  reply	other threads:[~2020-11-11  9:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 15:37 [PATCH v5 net-nex 0/5] xdp: introduce bulking for page_pool tx return path Lorenzo Bianconi
2020-11-10 15:37 ` [PATCH v5 net-nex 1/5] net: xdp: introduce bulking for xdp " Lorenzo Bianconi
2020-11-10 15:37 ` [PATCH v5 net-nex 2/5] net: page_pool: add bulk support for ptr_ring Lorenzo Bianconi
2020-11-11  9:29   ` John Fastabend [this message]
2020-11-11 10:43     ` Lorenzo Bianconi
2020-11-11 12:59       ` Jesper Dangaard Brouer
2020-11-10 15:37 ` [PATCH v5 net-nex 3/5] net: mvneta: add xdp tx return bulking support Lorenzo Bianconi
2020-11-10 15:37 ` [PATCH v5 net-nex 4/5] net: mvpp2: " Lorenzo Bianconi
2020-11-10 15:38 ` [PATCH v5 net-nex 5/5] net: mlx5: " Lorenzo Bianconi
2020-11-10 16:19   ` Jesper Dangaard Brouer
2020-11-10 15:50 ` [PATCH v5 net-nex 0/5] xdp: introduce bulking for page_pool tx return path Jesper Dangaard Brouer
2020-11-10 15:56   ` Lorenzo Bianconi

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=5fabaf0c4a68a_bb2602085a@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=davem@davemloft.net \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kuba@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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