From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50071.outbound.protection.outlook.com [40.107.5.71]) by dpdk.org (Postfix) with ESMTP id CF242D018 for ; Fri, 27 Apr 2018 19:05:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Olw9PL3t4qOrsIWZysCnyf06uMl3Zq8HXouFbhIwqBs=; b=TVuPPOKc5FHSHuhyIP60XGI5QzcuVk+N+OGA11dfu/NoocT6vnr17I5o8wo6GHHEyN6kexrglOXd7wcuXFbVDZctR5iON0uaYNGhM/mIJUw7X97/AjBGnivjmnzGWJuSRmxxC0B542BM6++5umKsCBn+2sjVvCuSpP1CCIGEYO0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; Received: from Tophie.ap.freescale.net (14.142.187.166) by AM5PR0402MB2770.eurprd04.prod.outlook.com (2603:10a6:203:98::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.13; Fri, 27 Apr 2018 17:05:17 +0000 From: Shreyansh Jain To: thomas@monjalon.net, dev@dpdk.org Cc: hemant.agrawal@nxp.com, akhil.goyal@nxp.com, anatoly.burakov@intel.com, Shreyansh Jain Date: Fri, 27 Apr 2018 22:50:58 +0530 Message-Id: <20180427172058.26850-4-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180427172058.26850-1-shreyansh.jain@nxp.com> References: <20180427162556.22781-1-shreyansh.jain@nxp.com> <20180427172058.26850-1-shreyansh.jain@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: TYAPR04CA0016.apcprd04.prod.outlook.com (2603:1096:404:15::28) To AM5PR0402MB2770.eurprd04.prod.outlook.com (2603:10a6:203:98::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM5PR0402MB2770; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0402MB2770; 3:yKvzc2BmOuoXkBNGnVN2hkolb8vn/iyGTLchq6hv5KZZi/R8KEjUUHH/mkNnOavYTW9+9timUOZXsPXYjw2AWobQXNJMjYqGiorJoSQXdMjHurLwXGVYQSPE6XPL1OmcpRm1P1u7WmOyT94d0x/kprnqPUn/qypGWbAhF4Geq8C+stm/Gg5ahRNX0/CNA31j+ss9aOUGGQc/ORtsVGViBJ9gFosy1zCNz1wu95Q1Qgg5ft0I/vPLrwL/NaSxJXex; 25:zTlWf5EFsC39FpPw/8mXOzlt3thgyIQMVSH1BnREn8OoY4BrrtZIFB7I/KrBX4hZ7F0S+3XY+ZtlGh69CLrj2+DvdpU27UmGegsdufrmDrRDGVmHDYKYS37SHbxLZEyOWNRy2W68hlzIjP9uCwk+YzDR3GZ92gImwf/VL+X3ozTxkxlA6K6yUg+nP0/4eaKQMw9a9cYeZDwGiDYSEBUAGLf3+i2xvmK+0FXQKe07y5yiE7GDvxE9Uztt55oHi2ipxWoJoitObbNXfzVV/yhSZDYFNzTtUU2IxiHUZuztD5mZBX9w4u3BACvdMspTCbOjm62/3dRkDCI/qA8gxBIW/g==; 31:qxlmesmxDHNbtMM4fa3XHgXaxtFuggT+zxRZFxSY2XRvzDqEyg+MYbLM+Kjf8s3KLKm94br3eXoBFvnCYTFkv3hGJmdiMysONl8XQf16F08ep3pXxXNXWq6L/H05tktw44rqocToMPOl2SNw0IhdT0iBHMeFPIbTUXzbLE0xD/RxtmjiN4eOkTZVaBLZ2y6L9Ns0Jm+VflZ99k35CWVxHz7J0Tbl1VDMPy/mCK6loGg= X-MS-TrafficTypeDiagnostic: AM5PR0402MB2770: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0402MB2770; 20:uVgZMLSRsRdpSOxDtNge1xH2WRn4gHE1R3NwwCMt363RpQvYZa+TgX+OICHKXfXf+7gdCG5papk62mishtOJt0UJjfmoxayny7GDYfcftEAnx77hY9Q/3RTsd7e7ImqJ0QUPo9CAgBJ0AHADqgfqDnEK3ENLLwe+kT166iizZCK+iJUo26LJ/CFF/obnr+D9vik38Vmlo3uIBcTUTIs8t7gXhicO/kGRKZxd6RsH4Fw4FfleMsCDtIxjcbs2bOL4rW6TZX2YSuXTJsEdV1xZ9rbSu5Spp3ehFTPnBZEHe6YThvPQYdyvSTCPuTjNb+4Nq2f6HtY/TjIKPSfmA7kO0yo/TQ78AZzjq2dHeHL/5Fkh6DSCIahqrpBhmPrEk5NL1mQc+QC/+qyO0AZ8NhPd6jL7M26Ck7TLI+l0qDhDiHmyRWSSWeg7q6aDZFbRCvzMACP9lvjMmJyrSmt73g7P3jjyXCvpgc7kfjj7YwxG/YobSAydSLFDvmj1VKAv/NJi; 4:gPisbQxRVcCrMuV0QXU4GL57SdQGFlhTlYfM2uLegJISNbM90qW5rAF/xIgcO2bbtn8o1NqiwFxK/h+jSTNGBNiWbqswbvwXc0IyNhTBng44ftqAosMlZwjjDKht2Fv1hUyE6Fhj93plEvcAAEiAarNENgufxqi6w4H/fJySfRbsRPU3EHByCGf8pBb1dAeBkesK6BvU6YrDCKQ0HUOZfAj9C9IpT0gswHGlTp9DWmqW/X2NjmCRDvSuKps5jvXyMcV/wd8/+V2ZMrMmTvTtvhniyD5PojTrrJaLmjVmXyOa50vNR4mHDLznrc/2vfigGys5euEjUgw6hRqBWHCdKrLwXoMQjT+LFoMQEVv86xhZtaAPDbc1vAFAUK2Ef3aV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(131327999870524)(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231232)(944501410)(52105095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:AM5PR0402MB2770; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0402MB2770; X-Forefront-PRVS: 0655F9F006 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(396003)(376002)(366004)(346002)(189003)(199004)(2906002)(66066001)(106356001)(186003)(6512007)(8936002)(4326008)(81156014)(81166006)(25786009)(53936002)(50226002)(8676002)(48376002)(47776003)(6486002)(105586002)(50466002)(36756003)(486006)(6116002)(6666003)(68736007)(316002)(446003)(86362001)(956004)(11346002)(97736004)(55236004)(59450400001)(5660300001)(1076002)(26005)(3846002)(476003)(478600001)(51416003)(305945005)(7736002)(16526019)(76176011)(44832011)(16586007)(6506007)(386003)(2616005)(52116002)(5009440100003)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0402MB2770; H:Tophie.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0402MB2770; 23:K6/S8DeKXFMtXLqNYinJesZE2hMh5SCrYZzuihf?= =?us-ascii?Q?3pLME14hQqgz0iXlzAPDx3gEM6vVzPGucCg0v84yHfKj8SS0MEUbkhvICHKz?= =?us-ascii?Q?ybDQDTs9+dXYAIUfMzkKYKM8RLloJJgJHc6cFffWhqIYPOImBdVDRdNX/Lkk?= =?us-ascii?Q?GljuhZDlKqNHXMAeSLG9S9pwS0xCXYpzW+NagJLOCDTFpjfqrvWbKHgKwLGf?= =?us-ascii?Q?N63OUsw9N0wPuvqSpZ4ioP2JurdyNcQvtjw62e+Wt6soxOR5OLJchQJ7L7/I?= =?us-ascii?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Dfed9TFS92WtVqB2YHva8=; 24:XqXE22rzTOAay7p61FIab+3704QOvV3nOwXMs2xdpNemIRAqdISOmB4uCYOBJUgtKvQQgvntBBg2fQ6ilqk5qWouwnAE+urbg/VbO3FX2Y4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0402MB2770; 7:jgd08KEyoJBLKo1oKUqivyiCKXN/LaHrlRcQvvpDEnXVh/GYwqUNYajcvvgQs1uThtOh/PKOwQwv/k9cU19H/f9P0Hb5p68V+nGWFuex4iLGqPcaYiEpA4mFSQCyk46UyB833d5Sisrh+6ui4fmNRSZMGV8qp3wjOQe10UFsFPyztfU7lnHCGa10mpHlAcTQOBBu7xpChraA14sUIhLyiw6yVL15ILmLWwEDjZd+GYQwqgds5cYl9jk9j8AkIhp1 X-MS-Office365-Filtering-Correlation-Id: 29bcd3f8-4e23-4904-5a8a-08d5ac610f00 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2018 17:05:17.2651 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29bcd3f8-4e23-4904-5a8a-08d5ac610f00 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2770 Subject: [dpdk-dev] [PATCH v2 3/3] bus/dpaa: optimize physical to virtual address searching 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: Fri, 27 Apr 2018 17:05:23 -0000 With Hotplugging memory support, the order of memseg has been changed from physically contiguous to virtual contiguous. DPAA bus and drivers depend on PA to VA address conversion for I/O. This patch creates a list of blocks requested to be pinned to the DPAA mempool. For searching physical addresses, it is expected that it would belong to this list (from hardware pool) and hence it is less expensive than memseg walks. Though, there is a marginal drop in performance vis-a-vis the legacy mode with physically contiguous memsegs. Signed-off-by: Shreyansh Jain --- An optimized algorithm is being worked upon based on some recent patches in hotplugging. That would improve/recover the performance. Until that time, this patch is to be treated a stop-gap solution. --- drivers/bus/dpaa/rte_dpaa_bus.h | 27 ++++++++++++++++++++++++++- drivers/mempool/dpaa/dpaa_mempool.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index 89aeac2d1..ca32b7f2f 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -95,9 +95,34 @@ struct dpaa_portal { uint64_t tid;/**< Parent Thread id for this portal */ }; -/* TODO - this is costly, need to write a fast coversion routine */ +/* Various structures representing contiguous memory maps */ +struct dpaa_memseg { + TAILQ_ENTRY(dpaa_memseg) next; + char *vaddr; + rte_iova_t iova; + size_t len; +}; + +TAILQ_HEAD(dpaa_memseg_list, dpaa_memseg); +extern struct dpaa_memseg_list dpaa_memsegs; + +/* Either iterate over the list of internal memseg references or fallback to + * EAL memseg based iova2virt. + */ static inline void *rte_dpaa_mem_ptov(phys_addr_t paddr) { + struct dpaa_memseg *ms; + + /* Check if the address is already part of the memseg list internally + * maintained by the dpaa driver. + */ + TAILQ_FOREACH(ms, &dpaa_memsegs, next) { + if (paddr >= ms->iova && paddr < + ms->iova + ms->len) + return RTE_PTR_ADD(ms->vaddr, (paddr - ms->iova)); + } + + /* If not, Fallback to full memseg list searching */ return rte_mem_iova2virt(paddr); } diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c index 580e4640c..9d6277f82 100644 --- a/drivers/mempool/dpaa/dpaa_mempool.c +++ b/drivers/mempool/dpaa/dpaa_mempool.c @@ -27,6 +27,13 @@ #include +/* List of all the memseg information locally maintained in dpaa driver. This + * is to optimize the PA_to_VA searches until a better mechanism (algo) is + * available. + */ +struct dpaa_memseg_list dpaa_memsegs + = TAILQ_HEAD_INITIALIZER(dpaa_memsegs); + struct dpaa_bp_info rte_dpaa_bpid_info[DPAA_MAX_BPOOLS]; static int @@ -287,10 +294,34 @@ dpaa_populate(struct rte_mempool *mp, unsigned int max_objs, /* Detect pool area has sufficient space for elements in this memzone */ if (len >= total_elt_sz * mp->size) bp_info->flags |= DPAA_MPOOL_SINGLE_SEGMENT; + struct dpaa_memseg *ms; + + /* For each memory chunk pinned to the Mempool, a linked list of the + * contained memsegs is created for searching when PA to VA + * conversion is required. + */ + ms = rte_zmalloc(NULL, sizeof(struct dpaa_memseg), 0); + if (!ms) { + DPAA_MEMPOOL_ERR("Unable to allocate internal memory."); + DPAA_MEMPOOL_WARN("Fast Physical to Virtual Addr translation would not be available."); + /* If the element is not added, it would only lead to failure + * in searching for the element and the logic would Fallback + * to traditional DPDK memseg traversal code. So, this is not + * a blocking error - but, error would be printed on screen. + */ + return 0; + } + + ms->vaddr = vaddr; + ms->iova = paddr; + ms->len = len; + /* Head insertions are generally faster than tail insertions as the + * buffers pinned are picked from rear end. + */ + TAILQ_INSERT_HEAD(&dpaa_memsegs, ms, next); return rte_mempool_op_populate_default(mp, max_objs, vaddr, paddr, len, obj_cb, obj_cb_arg); - } struct rte_mempool_ops dpaa_mpool_ops = { -- 2.14.1