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 D76FE43C10; Wed, 28 Feb 2024 09:10:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3AB64027D; Wed, 28 Feb 2024 09:10:31 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id B136D4003C for ; Wed, 28 Feb 2024 09:10:30 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tl6Rd1mJvz2BdtQ; Wed, 28 Feb 2024 16:08:13 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 2C68E1404F1; Wed, 28 Feb 2024 16:10:28 +0800 (CST) Received: from [10.67.121.161] (10.67.121.161) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 28 Feb 2024 16:10:27 +0800 Subject: Re: [PATCH v10 3/4] app/dma-perf: validate copied memory To: Amit Prakash Shukla , Cheng Jiang , Gowrishankar Muthukrishnan CC: , , , Kevin Laatz , Bruce Richardson , Pavan Nikhilesh References: <20240227160031.3931694-1-amitprakashs@marvell.com> <20240227183555.3932711-1-amitprakashs@marvell.com> <20240227183555.3932711-4-amitprakashs@marvell.com> From: fengchengwen Message-ID: Date: Wed, 28 Feb 2024 16:10:27 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20240227183555.3932711-4-amitprakashs@marvell.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.161] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500024.china.huawei.com (7.185.36.10) 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 Hi Gowrishankar, On 2024/2/28 2:35, Amit Prakash Shukla wrote: > From: Gowrishankar Muthukrishnan > > Validate copied memory to ensure DMA copy did not fail. > > Signed-off-by: Gowrishankar Muthukrishnan > Acked-by: Anoob Joseph > Acked-by: Chengwen Feng > --- > app/test-dma-perf/benchmark.c | 21 ++++++++++++++++++++- > app/test-dma-perf/main.c | 16 +++++++++++----- > app/test-dma-perf/main.h | 2 +- > 3 files changed, 32 insertions(+), 7 deletions(-) > > diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma-perf/benchmark.c > index 4370d71134..0047e2f4b8 100644 > --- a/app/test-dma-perf/benchmark.c > +++ b/app/test-dma-perf/benchmark.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > > #include "main.h" > > @@ -407,6 +408,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, > return -1; > } > > + for (i = 0; i < nr_buf; i++) { > + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); > + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); > + } > + > if (cfg->transfer_dir == RTE_DMA_DIR_DEV_TO_MEM || > cfg->transfer_dir == RTE_DMA_DIR_MEM_TO_DEV) { > ext_buf_info = rte_malloc(NULL, sizeof(struct rte_mbuf_ext_shared_info), 0); > @@ -443,7 +449,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, > return 0; > } > > -void > +int > mem_copy_benchmark(struct test_configure *cfg, bool is_dma) > { > uint32_t i; > @@ -461,6 +467,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) > uint32_t avg_cycles_total; > float mops, mops_total; > float bandwidth, bandwidth_total; > + int ret = 0; > > if (setup_memory_env(cfg, &srcs, &dsts) < 0) > goto out; > @@ -534,6 +541,16 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) > > rte_eal_mp_wait_lcore(); > > + for (i = 0; i < (nr_buf / nb_workers) * nb_workers; i++) { > + if (memcmp(rte_pktmbuf_mtod(srcs[i], void *), > + rte_pktmbuf_mtod(dsts[i], void *), > + cfg->buf_size.cur) != 0) { > + printf("Copy validation fails for buffer number %d\n", i); For non-mem2mem DMA, like mem2dev or dev2mem, the device host address may not direct accessable by CPU (if could may need mmap). So pls restrict it only mem2mem, or drop this commit. Thanks > + ret = -1; > + goto out; > + } > + } > + > mops_total = 0; > bandwidth_total = 0; > avg_cycles_total = 0; > @@ -599,4 +616,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) > rte_dma_stop(ldm->dma_ids[i]); > } > } > + > + return ret; > } > diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c > index 051f76a6f9..df05bcd7df 100644 > --- a/app/test-dma-perf/main.c > +++ b/app/test-dma-perf/main.c > @@ -101,20 +101,24 @@ open_output_csv(const char *rst_path_ptr) > return 0; > } > > -static void > +static int > run_test_case(struct test_configure *case_cfg) > { > + int ret = 0; > + > switch (case_cfg->test_type) { > case TEST_TYPE_DMA_MEM_COPY: > - mem_copy_benchmark(case_cfg, true); > + ret = mem_copy_benchmark(case_cfg, true); > break; > case TEST_TYPE_CPU_MEM_COPY: > - mem_copy_benchmark(case_cfg, false); > + ret = mem_copy_benchmark(case_cfg, false); > break; > default: > printf("Unknown test type. %s\n", case_cfg->test_type_str); > break; > } > + > + return ret; > } > > static void > @@ -159,8 +163,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) > case_cfg->scenario_id++; > printf("\nRunning scenario %d\n", case_cfg->scenario_id); > > - run_test_case(case_cfg); > - output_csv(false); > + if (run_test_case(case_cfg) < 0) > + printf("\nTest fails! skipping this scenario.\n"); > + else > + output_csv(false); > > if (var_entry->op == OP_ADD) > var_entry->cur += var_entry->incr; > diff --git a/app/test-dma-perf/main.h b/app/test-dma-perf/main.h > index 745c24b7fe..1123e7524a 100644 > --- a/app/test-dma-perf/main.h > +++ b/app/test-dma-perf/main.h > @@ -66,6 +66,6 @@ struct test_configure { > struct test_vchan_dev_config vchan_dev; > }; > > -void mem_copy_benchmark(struct test_configure *cfg, bool is_dma); > +int mem_copy_benchmark(struct test_configure *cfg, bool is_dma); > > #endif /* MAIN_H */ >