All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dean Nelson <dnelson@redhat.com>
To: Robert Richter <rric@kernel.org>,
	Sunil Goutham <sgoutham@cavium.com>,
	David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Vadim Lomovtsev <vlomovtsev@marvell.com>
Subject: [PATCH net 1/2] thunderx: enable page recycling for non-XDP case
Date: Tue, 26 Mar 2019 10:04:47 -0400	[thread overview]
Message-ID: <155360908585.12643.12967701630346715912.email-sent-by-dnelson@cyan> (raw)
In-Reply-To: <155360907744.12643.15472521931039184559.email-sent-by-dnelson@cyan>

Commit 773225388dae15e72790 added code to nicvf_alloc_page() that inadvertently
disables receive buffer page recycling for the non-XDP case by always NULL'ng
the page pointer.

This patch corrects two if-conditionals to allow for the recycling of non-XDP
mode pages by only setting the page pointer to NULL when the page is not ready
for recycling.

Signed-off-by: Dean Nelson <dnelson@redhat.com>
---
 drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 23 +++++++++++-----------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
index 5b4d3badcb73..55dbf02c42af 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
@@ -105,20 +105,19 @@ static inline struct pgcache *nicvf_alloc_page(struct nicvf *nic,
 	/* Check if page can be recycled */
 	if (page) {
 		ref_count = page_ref_count(page);
-		/* Check if this page has been used once i.e 'put_page'
-		 * called after packet transmission i.e internal ref_count
-		 * and page's ref_count are equal i.e page can be recycled.
+		/* This page can be recycled if internal ref_count and page's
+		 * ref_count are equal, indicating that the page has been used
+		 * once for packet transmission. For non-XDP mode, internal
+		 * ref_count is always '1'.
 		 */
-		if (rbdr->is_xdp && (ref_count == pgcache->ref_count))
-			pgcache->ref_count--;
-		else
-			page = NULL;
-
-		/* In non-XDP mode, page's ref_count needs to be '1' for it
-		 * to be recycled.
-		 */
-		if (!rbdr->is_xdp && (ref_count != 1))
+		if (rbdr->is_xdp) {
+			if (ref_count == pgcache->ref_count)
+				pgcache->ref_count--;
+			else
+				page = NULL;
+		} else if (ref_count != 1) {
 			page = NULL;
+		}
 	}
 
 	if (!page) {

  reply	other threads:[~2019-03-26 14:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26 14:04 [PATCH net 0/2] thunderx: fix receive buffer page recycling Dean Nelson
2019-03-26 14:04 ` Dean Nelson [this message]
2019-03-26 14:39   ` [PATCH net 1/2] thunderx: enable page recycling for non-XDP case Jesper Dangaard Brouer
2019-03-26 14:39     ` Jesper Dangaard Brouer
2019-03-26 14:44     ` Dean Nelson
2019-03-26 14:44       ` Dean Nelson
2019-03-26 14:59       ` Jesper Dangaard Brouer
2019-03-26 14:59         ` Jesper Dangaard Brouer
2019-03-26 15:39         ` Dean Nelson
2019-03-26 15:39           ` Dean Nelson
2019-03-26 14:04 ` [PATCH net 2/2] thunderx: eliminate extra calls to put_page() for pages held for recycling Dean Nelson
2019-03-26 15:39 ` [PATCH net 0/2] thunderx: fix receive buffer page recycling Dean Nelson
2019-03-26 15:39   ` Dean Nelson

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=155360908585.12643.12967701630346715912.email-sent-by-dnelson@cyan \
    --to=dnelson@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=rric@kernel.org \
    --cc=sgoutham@cavium.com \
    --cc=vlomovtsev@marvell.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.