From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by dpdk.org (Postfix) with ESMTP id E518C1B3A1; Mon, 14 Jan 2019 10:23:47 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 415B5A78; Mon, 14 Jan 2019 01:23:47 -0800 (PST) Received: from 2p2660v4-1.austin.arm.com (2p2660v4-1.austin.arm.com [10.118.14.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 082B03F5AF; Mon, 14 Jan 2019 01:23:46 -0800 (PST) From: Dharmik Thakkar To: dev@dpdk.org Cc: Dharmik Thakkar , stable@dpdk.org Date: Mon, 14 Jan 2019 03:23:04 -0600 Message-Id: <20190114092304.1195-1-dharmik.thakkar@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181129183855.9361-1-dharmik.thakkar@arm.com> References: <20181129183855.9361-1-dharmik.thakkar@arm.com> Subject: [dpdk-dev] [PATCH v2] test/hash: reset iter and found in perf test 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: Mon, 14 Jan 2019 09:23:48 -0000 Reset 'iter' and 'tbl_rw_test_param.found' on each iteration to give correct result for lost and duplicated keys. This patch also changes the default return value of the test to -1 when not enough resources are provided. Fixes: 0eb3726ebcf14 ("test/hash: add test for read/write concurrency") Cc: stable@dpdk.org Signed-off-by: Dharmik Thakkar Reviewed-by: Ferruh Yigit Reviewed-by: Yipeng Wang -- v2: * Update commit message * Change 'found' array type to uint8_t * Restore declaration of 'iter' to the start --- test/test/test_hash_readwrite.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/test/test_hash_readwrite.c b/test/test/test_hash_readwrite.c index 6b695ce6e444..480ae97d857d 100644 --- a/test/test/test_hash_readwrite.c +++ b/test/test/test_hash_readwrite.c @@ -39,7 +39,7 @@ static struct perf htm_results, non_htm_results; struct { uint32_t *keys; - uint32_t *found; + uint8_t *found; uint32_t num_insert; uint32_t rounded_tot_insert; struct rte_hash *h; @@ -126,7 +126,7 @@ init_params(int use_ext, int use_htm, int use_jhash) unsigned int i; uint32_t *keys = NULL; - uint32_t *found = NULL; + uint8_t *found = NULL; struct rte_hash *handle; struct rte_hash_parameters hash_params = { @@ -173,7 +173,7 @@ init_params(int use_ext, int use_htm, int use_jhash) goto err; } - found = rte_zmalloc(NULL, sizeof(uint32_t) * TOTAL_ENTRY, 0); + found = rte_zmalloc(NULL, sizeof(uint8_t) * TOTAL_ENTRY, 0); if (found == NULL) { printf("RTE_ZMALLOC failed\n"); goto err; @@ -361,7 +361,7 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm, const void *next_key; void *next_data; - uint32_t iter = 0; + uint32_t iter; int use_jhash = 0; uint32_t duplicated_keys = 0; @@ -536,6 +536,8 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm, rte_eal_mp_wait_lcore(); + iter = 0; + memset(tbl_rw_test_param.found, 0, TOTAL_ENTRY); while (rte_hash_iterate(tbl_rw_test_param.h, &next_key, &next_data, &iter) >= 0) { /* Search for the key in the list of keys added .*/ @@ -619,7 +621,7 @@ test_hash_readwrite_main(void) if (rte_lcore_count() <= 2) { printf("More than two lcores are required " "to do read write test\n"); - return 0; + return -1; } RTE_LCORE_FOREACH_SLAVE(core_id) { -- 2.17.1