From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) by dpdk.org (Postfix) with ESMTP id DA3394C95 for ; Thu, 15 Nov 2018 11:29:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cFIMQVF0u2bJRlKN0ppbNYl5dOHl5EgFOnn/GIBcNqg=; b=gdKwQkhHgYkNIE9fHMcN2XNf3tgtCJ1Tv0HzHbqnNGeLpJ+vGlY5V6HQnvyI4cyVPDU8GUDZ2ZL3urk+Dc8nbsL7VMeQV8Cn/4twUAVNTW84GezODPxmFT/4ZtuJ1Mafe+DpurovA9ey5vBveJDFUe6vrza7bIMU5Spod0NkB1w= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3963.eurprd05.prod.outlook.com (52.134.72.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.27; Thu, 15 Nov 2018 10:29:17 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::58e7:97d8:f9c1:4323]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::58e7:97d8:f9c1:4323%3]) with mapi id 15.20.1294.045; Thu, 15 Nov 2018 10:29:17 +0000 From: Yongseok Koh To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh Thread-Topic: [PATCH 2/4] net/mlx5: optimize Tx external memory registration Thread-Index: AQHUfM4Q9dydNzIS1kGOolcWPMHceA== Date: Thu, 15 Nov 2018 10:29:17 +0000 Message-ID: <20181115102859.10928-2-yskoh@mellanox.com> References: <20181115102859.10928-1-yskoh@mellanox.com> In-Reply-To: <20181115102859.10928-1-yskoh@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR05CA0019.namprd05.prod.outlook.com (2603:10b6:a03:c0::32) To DB3PR0502MB3980.eurprd05.prod.outlook.com (2603:10a6:8:10::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB3963; 6:Ml2YtLnHYtG7YZCs10YdBeL+ViHHGKouyFi5p6umpksIB0lS6PkW8q+4lGvhEFhkbM2SvqCijCMQny52+T92itOgPdTfkITsVooKJR+li/4yTjmjW7B646FhwmWpw3sCayGnfHTBGIi6FXy/zvTM76u1UVB/cMPJsPpv0ico8Cbcs7hYG/AP+Ta0K4jNbce/PTvUnB6kKBa8sOrV/6NeHDoE1OJXIE5QGUDsG/5eM6qdQ4Qv49XXvkI2IYvdSAXcXEnlV0uMYRWa6dUG0/N+YdeVOEYeFqAeHKUasqGRjeQEO0qOfwz8D6oWLLA6TF8M3Ud+UZN8/glP1JERzuhW5D/837zwtlIN5Te8ycPKEdD58gL2zWeZWQ6uyWMtfooPXdHtpCRP3NR9TmirB13s5FVALlL+jT6lnrQJiUWqNODvuN27pPxcZKEmwcOAHfd75LcfwkClcSN2qX21cIqEww==; 5:PWZZTJqpGKa/Hj3B8zP28YcFYqJVIJd74H2lc7rGDdEBt0+9TZBU11ajrXwTkyyxnlLS5rDBg0kNQFUfV53KMpQR0q/jubavLaHV1F9rmn7Gjl/lTQxxK1YNfAxBjo6ckuIu8UXJOJFItLbW001z8OGj3j02++bv8pWMZz+lGOI=; 7:+y64t0FfHx4HNSNG/2Y/s13QftXJXxK7f80AxA/F+h9S8rpftbyqEKjat7kcD2QxVUHDSJ14vV0J8L/cWUpttoMZ7yytyGt9mVpaJYRnPEc60y1r4nEZPbEuamzfUN5PAepN8Wm+l9VsA41ZqvYxFQ== x-ms-office365-filtering-correlation-id: 4e3c89a7-450e-4d7c-c5c9-08d64ae53268 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB3963; x-ms-traffictypediagnostic: DB3PR0502MB3963: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231415)(944501410)(52105112)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB3963; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3963; x-forefront-prvs: 08572BD77F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(39860400002)(396003)(366004)(136003)(189003)(199004)(102836004)(1076002)(186003)(316002)(6636002)(105586002)(6436002)(486006)(106356001)(107886003)(25786009)(11346002)(5660300001)(386003)(6506007)(8936002)(81166006)(81156014)(68736007)(52116002)(6512007)(66066001)(36756003)(478600001)(2616005)(14454004)(53936002)(7736002)(4326008)(6862004)(71200400001)(71190400001)(8676002)(6486002)(97736004)(86362001)(305945005)(99286004)(26005)(14444005)(476003)(54906003)(2900100001)(6116002)(3846002)(446003)(37006003)(2906002)(76176011)(256004); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3963; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: GUXLD1zIu+/VsKh9hiETRyKN8VESPBh2eyH7ezB0jh/G0aYr/JUF10KApUx7gwKjlT5DsliGGTHgIbk+daPlV/BHdWYb5pInlXkCscSpc4Vm10h4RsMyAZU8+0U6nNqNMRKq5WLjDuhJoKq83VEwXGED8v/JEXkkewfuS1tG1hmJ9D8gquvub7L1m8MLzm2/1o34IGIdA/Tb1cTnl5t+kGFmtwStitmmQ5k0vY6O1WLEEn3kM7U2jT3YYmpUjDmabxzVam0fCsPTOic86GtlBjE01bTOdCLkMFG7KIFR1/q5WjlkoF1SrO/9eeOMTvvPHJLnwil6UXVbRKQ0w6iID/wSTlW+qFiwDciL3bMSpbM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e3c89a7-450e-4d7c-c5c9-08d64ae53268 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Nov 2018 10:29:17.8666 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3963 Subject: [dpdk-dev] [PATCH 2/4] net/mlx5: optimize Tx external memory registration X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Nov 2018 10:29:19 -0000 There's some performance drop due to extra condition checks on the datapath. Checking for external memory registration should be consolidated to the existing bottom-half. Fixes: 7e43a32ee060 ("net/mlx5: support externally allocated static memory"= ) Signed-off-by: Yongseok Koh --- drivers/net/mlx5/mlx5_mr.c | 28 +++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_rxtx.h | 26 ++++++-------------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index 6d7653d7d6..442b2d2321 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -1045,7 +1045,7 @@ mlx5_rx_addr2mr_bh(struct mlx5_rxq_data *rxq, uintptr= _t addr) * @return * Searched LKey on success, UINT32_MAX on no match. */ -uint32_t +static uint32_t mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr) { struct mlx5_txq_ctrl *txq_ctrl =3D @@ -1060,6 +1060,32 @@ mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintpt= r_t addr) } =20 /** + * Bottom-half of LKey search on Tx. If it can't be searched in the memseg + * list, register the mempool of the mbuf as externally allocated memory. + * + * @param txq + * Pointer to Tx queue structure. + * @param mb + * Pointer to mbuf. + * + * @return + * Searched LKey on success, UINT32_MAX on no match. + */ +uint32_t +mlx5_tx_mb2mr_bh(struct mlx5_txq_data *txq, struct rte_mbuf *mb) +{ + uintptr_t addr =3D (uintptr_t)mb->buf_addr; + uint32_t lkey; + + lkey =3D mlx5_tx_addr2mr_bh(txq, addr); + if (lkey =3D=3D UINT32_MAX && rte_errno =3D=3D ENXIO) { + /* Mempool may have externally allocated memory. */ + return mlx5_tx_update_ext_mp(txq, addr, mlx5_mb2mp(mb)); + } + return lkey; +} + +/** * Flush all of the local cache entries. * * @param mr_ctrl diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 1b6200f6c8..59fb43fefe 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -363,7 +363,7 @@ uint16_t mlx5_rx_burst_vec(void *dpdk_txq, struct rte_m= buf **pkts, =20 void mlx5_mr_flush_local_cache(struct mlx5_mr_ctrl *mr_ctrl); uint32_t mlx5_rx_addr2mr_bh(struct mlx5_rxq_data *rxq, uintptr_t addr); -uint32_t mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr); +uint32_t mlx5_tx_mb2mr_bh(struct mlx5_txq_data *txq, struct rte_mbuf *mb); uint32_t mlx5_tx_update_ext_mp(struct mlx5_txq_data *txq, uintptr_t addr, struct rte_mempool *mp); =20 @@ -619,7 +619,7 @@ mlx5_tx_complete(struct mlx5_txq_data *txq) * @return * Memory pool where data is located for given mbuf. */ -static struct rte_mempool * +static inline struct rte_mempool * mlx5_mb2mp(struct rte_mbuf *buf) { if (unlikely(RTE_MBUF_INDIRECT(buf))) @@ -668,9 +668,10 @@ mlx5_rx_addr2mr(struct mlx5_rxq_data *rxq, uintptr_t a= ddr) * Searched LKey on success, UINT32_MAX on no match. */ static __rte_always_inline uint32_t -mlx5_tx_addr2mr(struct mlx5_txq_data *txq, uintptr_t addr) +mlx5_tx_mb2mr(struct mlx5_txq_data *txq, struct rte_mbuf *mb) { struct mlx5_mr_ctrl *mr_ctrl =3D &txq->mr_ctrl; + uintptr_t addr =3D (uintptr_t)mb->buf_addr; uint32_t lkey; =20 /* Check generation bit to see if there's any change on existing MRs. */ @@ -681,23 +682,8 @@ mlx5_tx_addr2mr(struct mlx5_txq_data *txq, uintptr_t a= ddr) MLX5_MR_CACHE_N, addr); if (likely(lkey !=3D UINT32_MAX)) return lkey; - /* Take slower bottom-half (binary search) on miss. */ - return mlx5_tx_addr2mr_bh(txq, addr); -} - -static __rte_always_inline uint32_t -mlx5_tx_mb2mr(struct mlx5_txq_data *txq, struct rte_mbuf *mb) -{ - uintptr_t addr =3D (uintptr_t)mb->buf_addr; - uint32_t lkey =3D mlx5_tx_addr2mr(txq, addr); - - if (likely(lkey !=3D UINT32_MAX)) - return lkey; - if (rte_errno =3D=3D ENXIO) { - /* Mempool may have externally allocated memory. */ - lkey =3D mlx5_tx_update_ext_mp(txq, addr, mlx5_mb2mp(mb)); - } - return lkey; + /* Take slower bottom-half on miss. */ + return mlx5_tx_mb2mr_bh(txq, mb); } =20 /** --=20 2.11.0