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 E3B81A0545; Tue, 11 Oct 2022 14:24:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 01B4842E23; Tue, 11 Oct 2022 14:23:16 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id D729942DE4 for ; Tue, 11 Oct 2022 14:23:05 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MmvvV3s1HzlVvJ; Tue, 11 Oct 2022 20:18:30 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 11 Oct 2022 20:23:04 +0800 From: Chengwen Feng To: , , , , , CC: , Subject: [PATCH v8 9/9] app/test: add memarea to malloc-perf-autotest Date: Tue, 11 Oct 2022 12:17:20 +0000 Message-ID: <20221011121720.2657-10-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221011121720.2657-1-fengchengwen@huawei.com> References: <20220721044648.6817-1-fengchengwen@huawei.com> <20221011121720.2657-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected 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 This patch adds memarea to malloc_perf_autotest. Test platform: Kunpeng920 Test command: dpdk-test -a 0000:7d:00.3 -l 10-12 Test result: USER1: Performance: rte_memarea USER1: Size (B) Runs Alloc (us) Free (us) Total (us) memset (us) USER1: 64 10000 0.03 0.03 0.06 0.01 USER1: 128 10000 0.02 0.03 0.05 0.01 USER1: 1024 10000 0.03 0.05 0.07 0.20 USER1: 4096 10000 0.03 0.05 0.07 0.34 USER1: 65536 10000 0.10 0.08 0.18 2.14 USER1: 1048576 644 0.10 0.04 0.14 29.07 USER1: 2097152 322 0.10 0.04 0.14 57.50 USER1: 4194304 161 0.12 0.04 0.15 114.50 USER1: 16777216 40 0.11 0.04 0.15 456.09 USER1: 1073741824 Interrupted: out of memory. [1] Compared with rte_malloc: USER1: Performance: rte_malloc USER1: Size (B) Runs Alloc (us) Free (us) Total (us) memset (us) USER1: 64 10000 0.14 0.07 0.21 0.01 USER1: 128 10000 0.10 0.05 0.15 0.01 USER1: 1024 10000 0.11 0.18 0.29 0.21 USER1: 4096 10000 0.13 0.39 0.53 0.35 USER1: 65536 10000 0.17 2.27 2.44 2.15 USER1: 1048576 10000 37.21 71.63 108.84 29.08 USER1: 2097152 10000 8831.15 160.02 8991.17 63.52 USER1: 4194304 10000 47131.88 413.75 47545.62 173.79 USER1: 16777216 4221 119604.60 2209.73 121814.34 964.42 USER1: 1073741824 31 335058.32 223369.31 558427.63 62440.87 [1] The total-size of the memarea is restricted to avoid creation failed. Signed-off-by: Chengwen Feng --- app/test/test_malloc_perf.c | 55 ++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/app/test/test_malloc_perf.c b/app/test/test_malloc_perf.c index ccec43ae84..a8b4531fe3 100644 --- a/app/test/test_malloc_perf.c +++ b/app/test/test_malloc_perf.c @@ -7,10 +7,12 @@ #include #include #include +#include #include #include "test.h" +#define PERFTEST_MAX_RUNS 10000 #define TEST_LOG(level, ...) RTE_LOG(level, USER1, __VA_ARGS__) typedef void * (alloc_t)(const char *name, size_t size, unsigned int align); @@ -147,10 +149,52 @@ memzone_free(void *addr) rte_memzone_free((struct rte_memzone *)addr); } +static struct rte_memarea *test_ma; + +static int +memarea_pre_env(void) +{ + struct rte_memarea_param init = { 0 }; + snprintf(init.name, sizeof(init.name), "perftest"); + init.source = RTE_MEMAREA_SOURCE_HEAP; + init.alg = RTE_MEMAREA_ALG_NEXTFIT; + init.total_sz = PERFTEST_MAX_RUNS * KB * 66; /* test for max 64KB (add 2KB for meta) */ + init.mt_safe = 1; + init.numa_socket = SOCKET_ID_ANY; + init.bak_memarea = NULL; + test_ma = rte_memarea_create(&init); + if (test_ma == NULL) { + fprintf(stderr, "memarea create failed, skip memarea perftest!\n"); + return -1; + } + return 0; +} + +static void +memarea_clear_env(void) +{ + rte_memarea_destroy(test_ma); + test_ma = NULL; +} + +static void * +memarea_alloc(const char *name, size_t size, unsigned int align) +{ + RTE_SET_USED(name); + RTE_SET_USED(align); + return rte_memarea_alloc(test_ma, size, 0); +} + +static void +memarea_free(void *addr) +{ + rte_memarea_free(test_ma, addr); +} + static int test_malloc_perf(void) { - static const size_t MAX_RUNS = 10000; + static const size_t MAX_RUNS = PERFTEST_MAX_RUNS; double memset_us_gb = 0; @@ -168,6 +212,15 @@ test_malloc_perf(void) NULL, memset_us_gb, RTE_MAX_MEMZONE - 1) < 0) return -1; + if (memarea_pre_env() < 0) + return 0; + if (test_alloc_perf("rte_memarea", memarea_alloc, memarea_free, + memset, memset_us_gb, MAX_RUNS) < 0) { + memarea_clear_env(); + return -1; + } + memarea_clear_env(); + return 0; } -- 2.17.1