mbox series

[v4,0/2] add a fast path for memif Rx/Tx

Message ID 20220915065825.26169-1-joyce.kong@arm.com (mailing list archive)
Headers
Series add a fast path for memif Rx/Tx |

Message

Joyce Kong Sept. 15, 2022, 6:58 a.m. UTC
  For memif non-zero-copy mode, there is a branch to compare
the mbuf and memif buffer size during memory copy. Add a
fast memcpy path by removing this branch with mbuf and memif
buffer size defined at compile time. For Rx fast path, bulk
allocating mbufs to get additional speedup. For Tx fast path,
bulk free mbufs which come from the same mempool.

When mbuf == memif buffer size, both Rx/Tx would choose the
fast memcpy path. When mbuf < memif buffer size, the Rx
chooses previous memcpy path while Tx chooses fast memcpy
path. When mbuf > memif buffer size, the Rx chooses fast
memcpy path while Tx chooses previous memcpy path.

Test with 1p1q on N1SDP AArch64 server,
---------------------------------------------------------
  buf size  | memif = mbuf | memif < mbuf | memif > mbuf
---------------------------------------------------------
non-zc gain |    47.16%    |    24.67%    |    12.47%
---------------------------------------------------------
   zc gain  |    20.96%    |     9.16%    |    10.66%
---------------------------------------------------------

Test with 1p1q on Cascade Lake Xeon X86 server,
---------------------------------------------------------
  buf size  | memif = mbuf | memif < mbuf | memif > mbuf
---------------------------------------------------------
non-zc gain |    23.52%    |    14.20%    |     5.10%
---------------------------------------------------------
   zc gain  |    17.49%    |    10.62%    |    12.42%
---------------------------------------------------------

v4:
 1.Fix incorrect indentation.
 2.Fix the mbuf array length to avoid additional overhead if
   stack-protector strong is enabled. <Stephen Hemminger>

v3:
 Add bulk allocation to get additional speedup for memif Rx
 fast path. <Stephen Hemminger>

v2:
 Rebase v1 and update commit message.

Joyce Kong (2):
  net/memif: add a Rx fast path
  net/memif: add a Tx fast path

 drivers/net/memif/rte_eth_memif.c | 280 +++++++++++++++++++++---------
 drivers/net/memif/rte_eth_memif.h |   2 +
 2 files changed, 199 insertions(+), 83 deletions(-)
  

Comments

Ferruh Yigit Sept. 22, 2022, 9:12 a.m. UTC | #1
On 9/15/2022 7:58 AM, Joyce Kong wrote:
> For memif non-zero-copy mode, there is a branch to compare
> the mbuf and memif buffer size during memory copy. Add a
> fast memcpy path by removing this branch with mbuf and memif
> buffer size defined at compile time. For Rx fast path, bulk
> allocating mbufs to get additional speedup. For Tx fast path,
> bulk free mbufs which come from the same mempool.
> 
> When mbuf == memif buffer size, both Rx/Tx would choose the
> fast memcpy path. When mbuf < memif buffer size, the Rx
> chooses previous memcpy path while Tx chooses fast memcpy
> path. When mbuf > memif buffer size, the Rx chooses fast
> memcpy path while Tx chooses previous memcpy path.
> 
> Test with 1p1q on N1SDP AArch64 server,
> ---------------------------------------------------------
>    buf size  | memif = mbuf | memif < mbuf | memif > mbuf
> ---------------------------------------------------------
> non-zc gain |    47.16%    |    24.67%    |    12.47%
> ---------------------------------------------------------
>     zc gain  |    20.96%    |     9.16%    |    10.66%
> ---------------------------------------------------------
> 
> Test with 1p1q on Cascade Lake Xeon X86 server,
> ---------------------------------------------------------
>    buf size  | memif = mbuf | memif < mbuf | memif > mbuf
> ---------------------------------------------------------
> non-zc gain |    23.52%    |    14.20%    |     5.10%
> ---------------------------------------------------------
>     zc gain  |    17.49%    |    10.62%    |    12.42%
> ---------------------------------------------------------
> 
> v4:
>   1.Fix incorrect indentation.
>   2.Fix the mbuf array length to avoid additional overhead if
>     stack-protector strong is enabled. <Stephen Hemminger>
> 
> v3:
>   Add bulk allocation to get additional speedup for memif Rx
>   fast path. <Stephen Hemminger>
> 
> v2:
>   Rebase v1 and update commit message.
> 
> Joyce Kong (2):
>    net/memif: add a Rx fast path
>    net/memif: add a Tx fast path
> 

Hi Jakub,

Reminder of this set waiting for your review.

Thanks,
ferruh
  
Ferruh Yigit Dec. 9, 2022, 1:59 p.m. UTC | #2
On 9/22/2022 10:12 AM, Ferruh Yigit wrote:
> On 9/15/2022 7:58 AM, Joyce Kong wrote:
>> For memif non-zero-copy mode, there is a branch to compare
>> the mbuf and memif buffer size during memory copy. Add a
>> fast memcpy path by removing this branch with mbuf and memif
>> buffer size defined at compile time. For Rx fast path, bulk
>> allocating mbufs to get additional speedup. For Tx fast path,
>> bulk free mbufs which come from the same mempool.
>>
>> When mbuf == memif buffer size, both Rx/Tx would choose the
>> fast memcpy path. When mbuf < memif buffer size, the Rx
>> chooses previous memcpy path while Tx chooses fast memcpy
>> path. When mbuf > memif buffer size, the Rx chooses fast
>> memcpy path while Tx chooses previous memcpy path.
>>
>> Test with 1p1q on N1SDP AArch64 server,
>> ---------------------------------------------------------
>>    buf size  | memif = mbuf | memif < mbuf | memif > mbuf
>> ---------------------------------------------------------
>> non-zc gain |    47.16%    |    24.67%    |    12.47%
>> ---------------------------------------------------------
>>     zc gain  |    20.96%    |     9.16%    |    10.66%
>> ---------------------------------------------------------
>>
>> Test with 1p1q on Cascade Lake Xeon X86 server,
>> ---------------------------------------------------------
>>    buf size  | memif = mbuf | memif < mbuf | memif > mbuf
>> ---------------------------------------------------------
>> non-zc gain |    23.52%    |    14.20%    |     5.10%
>> ---------------------------------------------------------
>>     zc gain  |    17.49%    |    10.62%    |    12.42%
>> ---------------------------------------------------------
>>
>> v4:
>>   1.Fix incorrect indentation.
>>   2.Fix the mbuf array length to avoid additional overhead if
>>     stack-protector strong is enabled. <Stephen Hemminger>
>>
>> v3:
>>   Add bulk allocation to get additional speedup for memif Rx
>>   fast path. <Stephen Hemminger>
>>
>> v2:
>>   Rebase v1 and update commit message.
>>
>> Joyce Kong (2):
>>    net/memif: add a Rx fast path
>>    net/memif: add a Tx fast path
>>
> 
> Hi Jakub,
> 
> Reminder of this set waiting for your review.
> 

No objection received on the patch, and I can reproduce the performance
improvement.
Taking into account that we are at the beginning of the release cycle
and will have time to address any possible issue later, I will proceed
with the set.

Series applied to dpdk-next-net/main, thanks.