From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B95A043746; Tue, 19 Dec 2023 17:36:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABC4142E11; Tue, 19 Dec 2023 17:36:08 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2084.outbound.protection.outlook.com [40.107.243.84]) by mails.dpdk.org (Postfix) with ESMTP id 0236E42DED; Tue, 19 Dec 2023 17:36:06 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=izFRo10JP6pq+HCo7eNR6spu6CjQXVnFOATLBNKV4gEC06/D8q07lzbDEd7MjlmwxI7lUCeMtk1nnXAhiM3EUDsI0Wl4GZt5bHh5IiUpa5GthY2vgyv5J4irknDElj45zNJ3HTm1ev0xFvYLNH1HEHPLPXigGcyGe6+sg9qYJuaBC9RQ0y+BNf9DIGVYMYl/y8gwtjd8qIPzx0ar4kTpcuV87iJrNICW36uq5dLccuTMjEyGfm4IvXdBILbB8XMtXd/W4lSj79eO3SDaktpy2CFdfOZwV1+Nan1VGT0nvxZ/7peh4g+hMVQXYBW8qjQNFddpV9qugwBxGNRT+Zv3hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pLlnxfaEfurfxikcCzi5l8Mhe8xuvIls1wL/6tYviA8=; b=AkbA41QuYodF4jVeZifRzamn1xogEdIinCAsBVfoPflamvR69oJn9Cpy2Ao/d+mAgGJgiXq4WoBZ/5lvuqfiLnV75h6ZbwPOKvnB1jwoddxGK8oTf1SJ/Jtr4Ot3+ZUe4T/gpCe857aez9KkTls/neemHGMzbmHlx8EMyTCgUjRJ6MsH7DxQ0L3WXw5IRSuEcnw5tnvnkShpZl+ukcRGWqj0PtQ2BB6UdTHEALZ4vaL/YCsak8LHHVYygEfIdnCjnApiNv13bWZcXu+WgxmmAqxEtZWQdLPy1u4yqLQU59eFEHzxb5UsYIEJ0shCvGQdR/wHVNgYu6uTb93CFxjVIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pLlnxfaEfurfxikcCzi5l8Mhe8xuvIls1wL/6tYviA8=; b=cXiH8aShzNxjU2owdCIKeIpq4afykV+tLFtHaAbUrOEiD0FQ1ac5f9g2GOjM0baGoP7RD1NVOsdygU7QvNwKjVPrunowWNg/hNZhrpAutJUxol2tDe0x11054+HAfx8HEcYzx1ms5Ce4PxrEuZOcEEe1CGiE9dkKsabMoACePKY= Received: from SJ0PR03CA0027.namprd03.prod.outlook.com (2603:10b6:a03:33a::32) by CH0PR12MB5348.namprd12.prod.outlook.com (2603:10b6:610:d7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38; Tue, 19 Dec 2023 16:36:03 +0000 Received: from CO1PEPF000044F5.namprd05.prod.outlook.com (2603:10b6:a03:33a:cafe::99) by SJ0PR03CA0027.outlook.office365.com (2603:10b6:a03:33a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38 via Frontend Transport; Tue, 19 Dec 2023 16:36:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044F5.mail.protection.outlook.com (10.167.241.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7113.14 via Frontend Transport; Tue, 19 Dec 2023 16:36:02 +0000 Received: from BLR-5CG134626B.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 19 Dec 2023 10:35:54 -0600 From: Vipin Varghese To: , , , , Subject: [PATCH] app/dma-perf: replace pktmbuf with mempool objects Date: Tue, 19 Dec 2023 22:05:32 +0530 Message-ID: <20231219163532.827-1-vipin.varghese@amd.com> X-Mailer: git-send-email 2.41.0.windows.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F5:EE_|CH0PR12MB5348:EE_ X-MS-Office365-Filtering-Correlation-Id: 505413f6-3d4b-473d-cfb2-08dc00b096c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2iiZHKyWyH4qMu37qDO9WuGbZKq9i/eYIpxUAaBUBvGHns/BWVHwOvO0HFB0oW+ugdojP7OJfLs6Fe82n1hiYbJqfUxdS1D1lcjiOcSVRldTpAAJOu3HoOlb32hlJ2v9XP9KoAi8rcwTwWOdrd4TbXVjOLNw0GU3i60GSDOv95RRCUwx93Lv42/gWfxsFbEY4lOZ6k9NcFdkR5JFxUcTy5gghVRdnSh/JEDqIGEaIUD0wLl1n2sLVnxQyDiwsjTUg3iihdqw8ORbK3+scov0tTJBVsNvzpq9nqu0T5eQ3T/DdJH3p+QCQuuNOIC+Xab/n5aGkWZjhZQb5t4ScFOdDnCb3zZ5luWxSpb1cufj6EAdXssLp7biqD8h3DuOY8U7kDwYv01pEswMCFy/u7Lp+FG0FehNu2eG/q6Wov7OrOZsRKDAQ6posM854X26/zJ43qJrltOUIJ7MLrhV53JsSZaAXruQDdrrolEWlFUPnQtdy1xtpJWjxlHQU1ECbhqQfBkD2OaG1jSAURrVu9wajNcPEp9AKwNPZaBu+Porj81yVDlrcFdYlG/LlsA7mpQNy9Ow5LOH8lKorbklG4XKNxx6DqiNquvWO5KbvfhlwjguddGHobE5r4DnA/F47CNLYyTMpacVO8MMn0sJazH7Ok72yU4EQtBbLneAzoXVsa9fOpH+0np7kpbB5OQIoatONTK+uJ+YIJfzAktgHtFIKQPknDBkAIOPhFCdzncxUtQtrnAU4Q3UhvBECpaOCwajxRZRCDFUT8I8/MTma8K1dQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(346002)(136003)(376002)(230922051799003)(64100799003)(82310400011)(186009)(451199024)(1800799012)(46966006)(40470700004)(36840700001)(40480700001)(40460700003)(36860700001)(81166007)(47076005)(356005)(82740400003)(36756003)(2906002)(83380400001)(6666004)(426003)(16526019)(26005)(7696005)(5660300002)(1076003)(2616005)(336012)(478600001)(70206006)(6636002)(41300700001)(70586007)(86362001)(8676002)(44832011)(8936002)(316002)(110136005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2023 16:36:02.1683 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 505413f6-3d4b-473d-cfb2-08dc00b096c5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5348 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace pktmbuf pool with mempool, this allows increase in MOPS especially in lower buffer size. Using Mempool, allows to reduce the extra CPU cycles. Changes made are 1. pktmbuf pool create with mempool create. 2. create src & dst pointer array from the appropaite numa. 3. use get pool and put for mempool objects. 4. remove pktmbuf_mtod for dma and cpu memcpy. Signed-off-by: Vipin Varghese --- app/test-dma-perf/benchmark.c | 74 +++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma-perf/benchmark.c index 9b1f58c78c..dc6f16cc01 100644 --- a/app/test-dma-perf/benchmark.c +++ b/app/test-dma-perf/benchmark.c @@ -43,8 +43,8 @@ struct lcore_params { uint16_t kick_batch; uint32_t buf_size; uint16_t test_secs; - struct rte_mbuf **srcs; - struct rte_mbuf **dsts; + void **srcs; + void **dsts; volatile struct worker_info worker_info; }; @@ -110,17 +110,17 @@ output_result(uint8_t scenario_id, uint32_t lcore_id, char *dma_name, uint16_t r } static inline void -cache_flush_buf(__rte_unused struct rte_mbuf **array, +cache_flush_buf(__rte_unused void **array, __rte_unused uint32_t buf_size, __rte_unused uint32_t nr_buf) { #ifdef RTE_ARCH_X86_64 char *data; - struct rte_mbuf **srcs = array; + void **srcs = array; uint32_t i, offset; for (i = 0; i < nr_buf; i++) { - data = rte_pktmbuf_mtod(srcs[i], char *); + data = (char *) srcs[i]; for (offset = 0; offset < buf_size; offset += 64) __builtin_ia32_clflush(data + offset); } @@ -224,8 +224,8 @@ do_dma_mem_copy(void *p) const uint32_t nr_buf = para->nr_buf; const uint16_t kick_batch = para->kick_batch; const uint32_t buf_size = para->buf_size; - struct rte_mbuf **srcs = para->srcs; - struct rte_mbuf **dsts = para->dsts; + void **srcs = para->srcs; + void **dsts = para->dsts; uint16_t nr_cpl; uint64_t async_cnt = 0; uint32_t i; @@ -241,8 +241,12 @@ do_dma_mem_copy(void *p) while (1) { for (i = 0; i < nr_buf; i++) { dma_copy: - ret = rte_dma_copy(dev_id, 0, rte_mbuf_data_iova(srcs[i]), - rte_mbuf_data_iova(dsts[i]), buf_size, 0); + ret = rte_dma_copy(dev_id, + 0, + (rte_iova_t) srcs[i], + (rte_iova_t) dsts[i], + buf_size, + 0); if (unlikely(ret < 0)) { if (ret == -ENOSPC) { do_dma_submit_and_poll(dev_id, &async_cnt, worker_info); @@ -276,8 +280,8 @@ do_cpu_mem_copy(void *p) volatile struct worker_info *worker_info = &(para->worker_info); const uint32_t nr_buf = para->nr_buf; const uint32_t buf_size = para->buf_size; - struct rte_mbuf **srcs = para->srcs; - struct rte_mbuf **dsts = para->dsts; + void **srcs = para->srcs; + void **dsts = para->dsts; uint32_t i; worker_info->stop_flag = false; @@ -288,8 +292,8 @@ do_cpu_mem_copy(void *p) while (1) { for (i = 0; i < nr_buf; i++) { - const void *src = rte_pktmbuf_mtod(dsts[i], void *); - void *dst = rte_pktmbuf_mtod(srcs[i], void *); + const void *src = (void *) dsts[i]; + void *dst = (void *) srcs[i]; /* copy buffer form src to dst */ rte_memcpy(dst, src, (size_t)buf_size); @@ -303,8 +307,8 @@ do_cpu_mem_copy(void *p) } static int -setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, - struct rte_mbuf ***dsts) +setup_memory_env(struct test_configure *cfg, void ***srcs, + void ***dsts) { unsigned int buf_size = cfg->buf_size.cur; unsigned int nr_sockets; @@ -317,47 +321,57 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, return -1; } - src_pool = rte_pktmbuf_pool_create("Benchmark_DMA_SRC", + src_pool = rte_mempool_create("Benchmark_DMA_SRC", nr_buf, + buf_size, 0, 0, - buf_size + RTE_PKTMBUF_HEADROOM, - cfg->src_numa_node); + NULL, + NULL, + NULL, + NULL, + cfg->src_numa_node, + RTE_MEMPOOL_F_SP_PUT | RTE_MEMPOOL_F_SC_GET); if (src_pool == NULL) { PRINT_ERR("Error with source mempool creation.\n"); return -1; } - dst_pool = rte_pktmbuf_pool_create("Benchmark_DMA_DST", + dst_pool = rte_mempool_create("Benchmark_DMA_DST", nr_buf, + buf_size, 0, 0, - buf_size + RTE_PKTMBUF_HEADROOM, - cfg->dst_numa_node); + NULL, + NULL, + NULL, + NULL, + cfg->dst_numa_node, + RTE_MEMPOOL_F_SP_PUT | RTE_MEMPOOL_F_SC_GET); if (dst_pool == NULL) { PRINT_ERR("Error with destination mempool creation.\n"); return -1; } - *srcs = rte_malloc(NULL, nr_buf * sizeof(struct rte_mbuf *), 0); + *srcs = rte_malloc_socket(NULL, nr_buf * sizeof(unsigned char *), 0, cfg->src_numa_node); if (*srcs == NULL) { printf("Error: srcs malloc failed.\n"); return -1; } - *dsts = rte_malloc(NULL, nr_buf * sizeof(struct rte_mbuf *), 0); + *dsts = rte_malloc_socket(NULL, nr_buf * sizeof(unsigned char *), 0, cfg->dst_numa_node); if (*dsts == NULL) { printf("Error: dsts malloc failed.\n"); return -1; } - if (rte_pktmbuf_alloc_bulk(src_pool, *srcs, nr_buf) != 0) { - printf("alloc src mbufs failed.\n"); + if (rte_mempool_get_bulk(src_pool, *srcs, nr_buf) != 0) { + printf("alloc src bufs failed.\n"); return -1; } - if (rte_pktmbuf_alloc_bulk(dst_pool, *dsts, nr_buf) != 0) { - printf("alloc dst mbufs failed.\n"); + if (rte_mempool_get_bulk(dst_pool, *dsts, nr_buf) != 0) { + printf("alloc dst bufs failed.\n"); return -1; } @@ -370,7 +384,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) uint16_t i; uint32_t offset; unsigned int lcore_id = 0; - struct rte_mbuf **srcs = NULL, **dsts = NULL; + void **srcs = NULL, **dsts = NULL; struct lcore_dma_map_t *ldm = &cfg->lcore_dma_map; unsigned int buf_size = cfg->buf_size.cur; uint16_t kick_batch = cfg->kick_batch.cur; @@ -478,9 +492,9 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) out: /* free mbufs used in the test */ if (srcs != NULL) - rte_pktmbuf_free_bulk(srcs, nr_buf); + rte_mempool_put_bulk(src_pool, srcs, nr_buf); if (dsts != NULL) - rte_pktmbuf_free_bulk(dsts, nr_buf); + rte_mempool_put_bulk(dst_pool, dsts, nr_buf); /* free the points for the mbufs */ rte_free(srcs); -- 2.34.1