From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tariq Toukan Subject: Re: [net-next V9 PATCH 14/16] mlx5: use page_pool for xdp_return_frame call Date: Wed, 4 Apr 2018 16:12:14 +0300 Message-ID: <72eccc60-21d2-0789-81c6-1bad2adb41ed@mellanox.com> References: <152275360298.1026.10333759008401281682.stgit@firesoul> <152275372705.1026.11963048035925660701.stgit@firesoul> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: eugenia@mellanox.com, Jason Wang , John Fastabend , Eran Ben Elisha , Saeed Mahameed , galp@mellanox.com, Daniel Borkmann , Alexei Starovoitov , Tariq Toukan To: Jesper Dangaard Brouer , netdev@vger.kernel.org, =?UTF-8?B?QmrDtnJuVMO2cGVs?= , magnus.karlsson@intel.com Return-path: Received: from mail-he1eur01on0054.outbound.protection.outlook.com ([104.47.0.54]:60107 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750853AbeDDNMa (ORCPT ); Wed, 4 Apr 2018 09:12:30 -0400 In-Reply-To: <152275372705.1026.11963048035925660701.stgit@firesoul> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 03/04/2018 2:08 PM, Jesper Dangaard Brouer wrote: > This patch shows how it is possible to have both the driver local page > cache, which uses elevated refcnt for "catching"/avoiding SKB > put_page returns the page through the page allocator. And at the > same time, have pages getting returned to the page_pool from > ndp_xdp_xmit DMA completion. > > The performance improvement for XDP_REDIRECT in this patch is really > good. Especially considering that (currently) the xdp_return_frame > API and page_pool_put_page() does per frame operations of both > rhashtable ID-lookup and locked return into (page_pool) ptr_ring. > (It is the plan to remove these per frame operation in a followup > patchset). > > The benchmark performed was RX on mlx5 and XDP_REDIRECT out ixgbe, > with xdp_redirect_map (using devmap) . And the target/maximum > capability of ixgbe is 13Mpps (on this HW setup). > > Before this patch for mlx5, XDP redirected frames were returned via > the page allocator. The single flow performance was 6Mpps, and if I > started two flows the collective performance drop to 4Mpps, because we > hit the page allocator lock (further negative scaling occurs). > > Two test scenarios need to be covered, for xdp_return_frame API, which > is DMA-TX completion running on same-CPU or cross-CPU free/return. > Results were same-CPU=10Mpps, and cross-CPU=12Mpps. This is very > close to our 13Mpps max target. > > The reason max target isn't reached in cross-CPU test, is likely due > to RX-ring DMA unmap/map overhead (which doesn't occur in ixgbe to > ixgbe testing). It is also planned to remove this unnecessary DMA > unmap in a later patchset > > V2: Adjustments requested by Tariq > - Changed page_pool_create return codes not return NULL, only > ERR_PTR, as this simplifies err handling in drivers. > - Save a branch in mlx5e_page_release > - Correct page_pool size calc for MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ > > V5: Updated patch desc > > V8: Adjust for b0cedc844c00 ("net/mlx5e: Remove rq_headroom field from params") > V9: > - Adjust for 121e89275471 ("net/mlx5e: Refactor RQ XDP_TX indication") > - Adjust for 73281b78a37a ("net/mlx5e: Derive Striding RQ size from MTU") > - Correct handling if page_pool_create fail for MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ > > Signed-off-by: Jesper Dangaard Brouer > Reviewed-by: Tariq Toukan > Acked-by: Saeed Mahameed > --- > drivers/net/ethernet/mellanox/mlx5/core/en.h | 3 ++ > drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 41 +++++++++++++++++---- > drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 16 ++++++-- > 3 files changed, 48 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h > index 1a05d1072c5e..3317a4da87cb 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h > @@ -53,6 +53,8 @@ > #include "mlx5_core.h" > #include "en_stats.h" > > +struct page_pool; > + > #define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v) > > #define MLX5E_ETH_HARD_MTU (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN) > @@ -534,6 +536,7 @@ struct mlx5e_rq { > unsigned int hw_mtu; > struct mlx5e_xdpsq xdpsq; > DECLARE_BITMAP(flags, 8); > + struct page_pool *page_pool; > > /* control */ > struct mlx5_wq_ctrl wq_ctrl; > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > index 13c1e61258a7..d0f2cd86ef32 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > @@ -35,6 +35,7 @@ > #include > #include > #include > +#include > #include "eswitch.h" > #include "en.h" > #include "en_tc.h" > @@ -389,10 +390,11 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, > struct mlx5e_rq_param *rqp, > struct mlx5e_rq *rq) > { > + struct page_pool_params pp_params = { 0 }; > struct mlx5_core_dev *mdev = c->mdev; > void *rqc = rqp->rqc; > void *rqc_wq = MLX5_ADDR_OF(rqc, rqc, wq); > - u32 byte_count; > + u32 byte_count, pool_size; > int npages; > int wq_sz; > int err; > @@ -432,9 +434,12 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, > > rq->buff.map_dir = rq->xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE; > rq->buff.headroom = mlx5e_get_rq_headroom(mdev, params); > + pool_size = 1 << params->log_rq_mtu_frames; > > switch (rq->wq_type) { > case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: > + > + pool_size = pool_size * MLX5_MPWRQ_PAGES_PER_WQE; For rq->wq_type != MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ, please use: pool_size = 1 << params->log_rq_mtu_frames; For rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ, please use: pool_size = MLX5_MPWRQ_PAGES_PER_WQ * mlx5e_mpwqe_get_log_rq_size(params); Thanks, Tariq