diff mbox series

[net,1/2] thunderx: enable page recycling for non-XDP case

Message ID 155360908585.12643.12967701630346715912.email-sent-by-dnelson@cyan
State Superseded
Delegated to: David Miller
Headers show
Series thunderx: fix receive buffer page recycling | expand

Commit Message

Dean Nelson March 26, 2019, 2:04 p.m. UTC
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(-)

Comments

Jesper Dangaard Brouer March 26, 2019, 2:39 p.m. UTC | #1
On Tue, 26 Mar 2019 10:04:47 -0400
Dean Nelson <dnelson@redhat.com> wrote:

> 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>

You need to add a "fixes" line like this:

Fixes: 773225388dae ("net: thunderx: Optimize page recycling for XDP")

And in-general reference a commit in the same way in the description.
Dean Nelson March 26, 2019, 2:44 p.m. UTC | #2
On 3/26/19 9:39 AM, Jesper Dangaard Brouer wrote:
> On Tue, 26 Mar 2019 10:04:47 -0400
> Dean Nelson <dnelson@redhat.com> wrote:
> 
>> 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>
> 
> You need to add a "fixes" line like this:
> 
> Fixes: 773225388dae ("net: thunderx: Optimize page recycling for XDP")
> 
> And in-general reference a commit in the same way in the description.

Sorry, for some reason I thought the 'Fixes' line was optional.

Thank you for setting me straight. Should I repost the patchset?
Jesper Dangaard Brouer March 26, 2019, 2:59 p.m. UTC | #3
On Tue, 26 Mar 2019 09:44:19 -0500
Dean Nelson <dnelson@redhat.com> wrote:

> On 3/26/19 9:39 AM, Jesper Dangaard Brouer wrote:
> > On Tue, 26 Mar 2019 10:04:47 -0400
> > Dean Nelson <dnelson@redhat.com> wrote:
> >   
> >> 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>  
> > 
> > You need to add a "fixes" line like this:
> > 
> > Fixes: 773225388dae ("net: thunderx: Optimize page recycling for XDP")
> > 
> > And in-general reference a commit in the same way in the description.  
> 
> Sorry, for some reason I thought the 'Fixes' line was optional.
> 
> Thank you for setting me straight. Should I repost the patchset?

I would say, yes please. (Given the amount of patches DaveM have to
process, lets make it easy for him).
Dean Nelson March 26, 2019, 3:39 p.m. UTC | #4
On 3/26/19 9:59 AM, Jesper Dangaard Brouer wrote:
> On Tue, 26 Mar 2019 09:44:19 -0500
> Dean Nelson <dnelson@redhat.com> wrote:
> 
>> On 3/26/19 9:39 AM, Jesper Dangaard Brouer wrote:
>>> On Tue, 26 Mar 2019 10:04:47 -0400
>>> Dean Nelson <dnelson@redhat.com> wrote:
>>>    
>>>> 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>
>>>
>>> You need to add a "fixes" line like this:
>>>
>>> Fixes: 773225388dae ("net: thunderx: Optimize page recycling for XDP")
>>>
>>> And in-general reference a commit in the same way in the description.
>>
>> Sorry, for some reason I thought the 'Fixes' line was optional.
>>
>> Thank you for setting me straight. Should I repost the patchset?
> 
> I would say, yes please. (Given the amount of patches DaveM have to
> process, lets make it easy for him).

Would be glad to, as I definitely agree.
Thanks for responding to my question.
diff mbox series

Patch

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) {