From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50087.outbound.protection.outlook.com [40.107.5.87]) by dpdk.org (Postfix) with ESMTP id 13FDC4C95 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=bev1uhl5IT7VcovHIv7YtrZtdpsB2RGRPVaxXZVuv1M=; b=Rku3bqZQIBAqjaBnfoSLGbmYH+QXWm1VmbOSbiZyfFMhOtwc9jfO4d6zhoDakfvvp7cjaiqgK2FvaPrfrPOvjfk75tgCWp1jw6AGHbnFg9v9ULRDfy2eF/OE8B0PbS2twUOx68NDhrVFxLCgKuGeTjEGNWnqKrudFJyJX6JOwXM= 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:16 +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:16 +0000 From: Yongseok Koh To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh Thread-Topic: [PATCH 1/4] net/mlx4: optimize Tx external memory registration Thread-Index: AQHUfM4PBsIsC09Bz02hkPuPZscNWw== Date: Thu, 15 Nov 2018 10:29:16 +0000 Message-ID: <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:dmajPLJjaMIIoqhr6GEp0zv0zNHJRdKEYhatfh54Wg+W/db2uqdua8eytbsx7zr1j5ZlCu1PLXUtDRby1Lt/r2ClAcjHdMyRgC2Lq8ejmnW5oJ6RxuxFWscgnbhA9+K9PbBtii9wMNfBcLJeC3UO7uLYbTEzUXDzcxo4h6uwPdGYWZjBLY/WLBwA00g4RTTM6AhvZ/DS/hFOpYlpU4la1tWs4D6PkfMCcZjh6kg/3BI61HO3wKmMGLPyG5ms1qpF0TSAtskWWxqeZwyv/PHgNMZUiGbKs+7iJIe58+cKaurRW72MG6EdjCY7VXLJ7+I1tBK9ezrRnfN/c7dCW82PJvZmPNUTo7V8XCjP373phGOAzRe7cl5vXlGVhzdpiD93kH9jvPa3dT5Zb/wtlokl0+ZYC+89sXwyhpkN2MnA8TA4ikGk5yCsrx+56l51Y2GbRalwZKNpbLpe9leJD6gRfg==; 5:+TmEt+6srhtnFoPEGS2Yr0GdASMauArASimOQepieYAX6wHhFXxB8eSkZ81gnoq9ERwoOu3SZu/I9df/VbQ0pFFWqKHDTvJglkMx6FSYafw4/9z9MXPVLkZlkXaTtzK6I3tv44L3Ln5k2hWrEAkL7laLxtzfr+QO3Q5Ce/qzOyo=; 7:Xhmm0ZqmYYRQsuQLhp9dWs4VlNpatNln5xy3cZ97pcD8d2MxQLWrxkmdlfgA5/zVzVU56pvbAY5HKDBdXQJmiGXmAAUHRP2mrG1uJpcsdxlJAw45AzzphU33vcYysO/8y8AEgnoji9tEtQiN/n+Q5A== x-ms-office365-filtering-correlation-id: 5f833451-c3af-4261-940e-08d64ae53194 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)(5660300001)(386003)(6506007)(8936002)(81166006)(81156014)(68736007)(52116002)(6512007)(66066001)(36756003)(478600001)(2616005)(14454004)(53936002)(7736002)(4326008)(6862004)(71200400001)(71190400001)(8676002)(6486002)(97736004)(86362001)(575784001)(305945005)(99286004)(26005)(14444005)(476003)(54906003)(2900100001)(6116002)(3846002)(37006003)(2906002)(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: LhNX09qY8QUPTgS5CI05HKOWQVXjNquGiMvfHF4kOuEF410waPTi2wQNwZeIUmY3W0VDGU+ul5MDpWgu/2zYdz9zFz11mEld0vgNeZS1COgbbWJuIIlCDsxib7sOz4O0wKlm9GpFGkQm2fXZR4GFTdpQCET0w62IehKUNq6W4MH/UwgEyJY8E9JbxwFE6nwFjhR/HLBNuK255y4DaIRedTd6B94xSIJOA9MzYuR00YZpe9X6zEI51bP43X/OssxgYm7dlJiwJbx5gFTz1NyUhdZmKAV/XwDoX27M5xQo1U4TQRGiEzXfRXm8u/KhURtZUGa+7Z982AKeIBbi8c5w9luX+aBbrFBlw/gBhJZOizg= 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: 5f833451-c3af-4261-940e-08d64ae53194 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Nov 2018 10:29:16.4603 (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 1/4] net/mlx4: 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:18 -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: 31912d992403 ("net/mlx4: support externally allocated static memory"= ) Signed-off-by: Yongseok Koh --- drivers/net/mlx4/mlx4_mr.c | 28 +++++++++++++++++++++++++++- drivers/net/mlx4/mlx4_rxtx.h | 26 ++++++-------------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c index 726788a60d..a0094483ab 100644 --- a/drivers/net/mlx4/mlx4_mr.c +++ b/drivers/net/mlx4/mlx4_mr.c @@ -1042,7 +1042,7 @@ mlx4_rx_addr2mr_bh(struct rxq *rxq, uintptr_t addr) * @return * Searched LKey on success, UINT32_MAX on no match. */ -uint32_t +static uint32_t mlx4_tx_addr2mr_bh(struct txq *txq, uintptr_t addr) { struct mlx4_mr_ctrl *mr_ctrl =3D &txq->mr_ctrl; @@ -1054,6 +1054,32 @@ mlx4_tx_addr2mr_bh(struct txq *txq, uintptr_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 +mlx4_tx_mb2mr_bh(struct txq *txq, struct rte_mbuf *mb) +{ + uintptr_t addr =3D (uintptr_t)mb->buf_addr; + uint32_t lkey; + + lkey =3D mlx4_tx_addr2mr_bh(txq, addr); + if (lkey =3D=3D UINT32_MAX && rte_errno =3D=3D ENXIO) { + /* Mempool may have externally allocated memory. */ + return mlx4_tx_update_ext_mp(txq, addr, mlx4_mb2mp(mb)); + } + return lkey; +} + +/** * Flush all of the local cache entries. * * @param mr_ctrl diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index 1be060cda1..d7ec4e0c5f 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -162,7 +162,7 @@ void mlx4_tx_queue_release(void *dpdk_txq); =20 void mlx4_mr_flush_local_cache(struct mlx4_mr_ctrl *mr_ctrl); uint32_t mlx4_rx_addr2mr_bh(struct rxq *rxq, uintptr_t addr); -uint32_t mlx4_tx_addr2mr_bh(struct txq *txq, uintptr_t addr); +uint32_t mlx4_tx_mb2mr_bh(struct txq *txq, struct rte_mbuf *mb); uint32_t mlx4_tx_update_ext_mp(struct txq *txq, uintptr_t addr, struct rte_mempool *mp); =20 @@ -176,7 +176,7 @@ uint32_t mlx4_tx_update_ext_mp(struct txq *txq, uintptr= _t addr, * @return * Memory pool where data is located for given mbuf. */ -static struct rte_mempool * +static inline struct rte_mempool * mlx4_mb2mp(struct rte_mbuf *buf) { if (unlikely(RTE_MBUF_INDIRECT(buf))) @@ -225,9 +225,10 @@ mlx4_rx_addr2mr(struct rxq *rxq, uintptr_t addr) * Searched LKey on success, UINT32_MAX on no match. */ static __rte_always_inline uint32_t -mlx4_tx_addr2mr(struct txq *txq, uintptr_t addr) +mlx4_tx_mb2mr(struct txq *txq, struct rte_mbuf *mb) { struct mlx4_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. */ @@ -238,23 +239,8 @@ mlx4_tx_addr2mr(struct txq *txq, uintptr_t addr) MLX4_MR_CACHE_N, addr); if (likely(lkey !=3D UINT32_MAX)) return lkey; - /* Take slower bottom-half (binary search) on miss. */ - return mlx4_tx_addr2mr_bh(txq, addr); -} - -static __rte_always_inline uint32_t -mlx4_tx_mb2mr(struct txq *txq, struct rte_mbuf *mb) -{ - uintptr_t addr =3D (uintptr_t)mb->buf_addr; - uint32_t lkey =3D mlx4_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 mlx4_tx_update_ext_mp(txq, addr, mlx4_mb2mp(mb)); - } - return lkey; + /* Take slower bottom-half on miss. */ + return mlx4_tx_mb2mr_bh(txq, mb); } =20 #endif /* MLX4_RXTX_H_ */ --=20 2.11.0