From patchwork Tue Jul 2 00:27:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 55828 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 07DF11B99B; Tue, 2 Jul 2019 02:27:39 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id BDC8B1B999; Tue, 2 Jul 2019 02:27:37 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 209D9344; Mon, 1 Jul 2019 17:27:37 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 046433F718; Mon, 1 Jul 2019 17:27:37 -0700 (PDT) From: Honnappa Nagarahalli To: yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com, david.marchand@redhat.com, honnappa.nagarahalli@arm.com Cc: dharmik.thakkar@arm.com, dev@dpdk.org, nd@arm.com, stable@dpdk.org Date: Mon, 1 Jul 2019 19:27:21 -0500 Message-Id: <20190702002724.41400-1-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627032420.4730-1-honnappa.nagarahalli@arm.com> References: <20190627032420.4730-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v3 1/4] test/hash: reset global variable to discard old data 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Reset tbl_rwc_test_param to discard data from previous run of the test. Fixes: c7eb0972e74b ("test/hash: add lock-free r/w concurrency") Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Dharmik Thakkar --- v3 - No changes V2 - No changes app/test/test_hash_readwrite_lf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/test/test_hash_readwrite_lf.c b/app/test/test_hash_readwrite_lf.c index 343a338b4..e9aca6ff4 100644 --- a/app/test/test_hash_readwrite_lf.c +++ b/app/test/test_hash_readwrite_lf.c @@ -1264,6 +1264,9 @@ test_hash_readwrite_lf_main(void) setlocale(LC_NUMERIC, ""); + /* Reset tbl_rwc_test_param to discard values from previous run */ + memset(&tbl_rwc_test_param, 0, sizeof(tbl_rwc_test_param)); + if (rte_tm_supported()) htm = 1; else From patchwork Tue Jul 2 00:27:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 55829 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3B4561B9A7; Tue, 2 Jul 2019 02:27:41 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 6E1B61B9A0; Tue, 2 Jul 2019 02:27:39 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CE2A9CFC; Mon, 1 Jul 2019 17:27:38 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B98E03F718; Mon, 1 Jul 2019 17:27:38 -0700 (PDT) From: Honnappa Nagarahalli To: yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com, david.marchand@redhat.com, honnappa.nagarahalli@arm.com Cc: dharmik.thakkar@arm.com, dev@dpdk.org, nd@arm.com, stable@dpdk.org Date: Mon, 1 Jul 2019 19:27:22 -0500 Message-Id: <20190702002724.41400-2-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702002724.41400-1-honnappa.nagarahalli@arm.com> References: <20190627032420.4730-1-honnappa.nagarahalli@arm.com> <20190702002724.41400-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v3 2/4] test/hash: init hash parameters in the correct function 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Each test case initializes its hash parameters in the test case function. To be consistent, generate keys function should initialize hash parameters similarly. Fixes: c7eb0972e74b ("test/hash: add lock-free r/w concurrency") Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Dharmik Thakkar --- v3 - no changes v2 - changed the order of the patch app/test/test_hash_readwrite_lf.c | 98 +++++++++++++++---------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/app/test/test_hash_readwrite_lf.c b/app/test/test_hash_readwrite_lf.c index e9aca6ff4..12522e265 100644 --- a/app/test/test_hash_readwrite_lf.c +++ b/app/test/test_hash_readwrite_lf.c @@ -141,6 +141,52 @@ get_enabled_cores_list(void) return 0; } +static int +init_params(int rwc_lf, int use_jhash, int htm, int ext_bkt) +{ + struct rte_hash *handle; + + struct rte_hash_parameters hash_params = { + .entries = TOTAL_ENTRY, + .key_len = sizeof(uint32_t), + .hash_func_init_val = 0, + .socket_id = rte_socket_id(), + }; + + if (use_jhash) + hash_params.hash_func = rte_jhash; + else + hash_params.hash_func = rte_hash_crc; + + if (rwc_lf) + hash_params.extra_flag = + RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF | + RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD; + else if (htm) + hash_params.extra_flag = + RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | + RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | + RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD; + else + hash_params.extra_flag = + RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | + RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD; + + if (ext_bkt) + hash_params.extra_flag |= RTE_HASH_EXTRA_FLAGS_EXT_TABLE; + + hash_params.name = "tests"; + + handle = rte_hash_create(&hash_params); + if (handle == NULL) { + printf("hash creation failed"); + return -1; + } + + tbl_rwc_test_param.h = handle; + return 0; +} + static inline int check_bucket(uint32_t bkt_idx, uint32_t key) { @@ -215,6 +261,9 @@ generate_keys(void) uint32_t count_keys_extbkt = 0; uint32_t i; + if (init_params(0, 0, 0, 0) != 0) + return -1; + /* * keys will consist of a) keys whose addition to the hash table * will result in shifting of the existing keys to their alternate @@ -504,52 +553,6 @@ generate_keys(void) return -1; } -static int -init_params(int rwc_lf, int use_jhash, int htm, int ext_bkt) -{ - struct rte_hash *handle; - - struct rte_hash_parameters hash_params = { - .entries = TOTAL_ENTRY, - .key_len = sizeof(uint32_t), - .hash_func_init_val = 0, - .socket_id = rte_socket_id(), - }; - - if (use_jhash) - hash_params.hash_func = rte_jhash; - else - hash_params.hash_func = rte_hash_crc; - - if (rwc_lf) - hash_params.extra_flag = - RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF | - RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD; - else if (htm) - hash_params.extra_flag = - RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | - RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | - RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD; - else - hash_params.extra_flag = - RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | - RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD; - - if (ext_bkt) - hash_params.extra_flag |= RTE_HASH_EXTRA_FLAGS_EXT_TABLE; - - hash_params.name = "tests"; - - handle = rte_hash_create(&hash_params); - if (handle == NULL) { - printf("hash creation failed"); - return -1; - } - - tbl_rwc_test_param.h = handle; - return 0; -} - static int test_rwc_reader(__attribute__((unused)) void *arg) { @@ -1254,7 +1257,6 @@ test_hash_readwrite_lf_main(void) */ int rwc_lf = 0; int htm; - int use_jhash = 0; int ext_bkt = 0; if (rte_lcore_count() == 1) { printf("More than one lcore is required " @@ -1272,8 +1274,6 @@ test_hash_readwrite_lf_main(void) else htm = 0; - if (init_params(rwc_lf, use_jhash, htm, ext_bkt) != 0) - return -1; if (generate_keys() != 0) return -1; if (get_enabled_cores_list() != 0) From patchwork Tue Jul 2 00:27:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 55830 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 47AF01B9B6; Tue, 2 Jul 2019 02:27:44 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 23F501B9AB; Tue, 2 Jul 2019 02:27:42 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AD05AEBD; Mon, 1 Jul 2019 17:27:41 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9A4BB3F718; Mon, 1 Jul 2019 17:27:41 -0700 (PDT) From: Honnappa Nagarahalli To: yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com, david.marchand@redhat.com, honnappa.nagarahalli@arm.com Cc: dharmik.thakkar@arm.com, dev@dpdk.org, nd@arm.com, stable@dpdk.org Date: Mon, 1 Jul 2019 19:27:23 -0500 Message-Id: <20190702002724.41400-3-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702002724.41400-1-honnappa.nagarahalli@arm.com> References: <20190627032420.4730-1-honnappa.nagarahalli@arm.com> <20190702002724.41400-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v3 3/4] test/hash: free allocated memory 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Free allocated memory. Fixes: 3f9aab961ed3 ("test/hash: check lock-free extendable bucket") Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Dharmik Thakkar --- v3 - removed freeing pos (addressed in 4/4) v2 - freed more memory app/test/test_hash_readwrite_lf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/test/test_hash_readwrite_lf.c b/app/test/test_hash_readwrite_lf.c index 12522e265..792244fd0 100644 --- a/app/test/test_hash_readwrite_lf.c +++ b/app/test/test_hash_readwrite_lf.c @@ -537,6 +537,7 @@ generate_keys(void) tbl_rwc_test_param.count_keys_ks_extbkt); rte_free(found); + rte_free(scanned_bkts); rte_hash_free(tbl_rwc_test_param.h); return 0; @@ -547,9 +548,11 @@ generate_keys(void) rte_free(keys_absent); rte_free(found); rte_free(tbl_rwc_test_param.keys_shift_path); + rte_free(keys_non_shift_path); rte_free(keys_ext_bkt); rte_free(keys_ks_extbkt); rte_free(scanned_bkts); + rte_hash_free(tbl_rwc_test_param.h); return -1; } @@ -1431,7 +1434,9 @@ test_hash_readwrite_lf_main(void) rte_free(tbl_rwc_test_param.keys_ks); rte_free(tbl_rwc_test_param.keys_absent); rte_free(tbl_rwc_test_param.keys_shift_path); - rte_free(scanned_bkts); + rte_free(tbl_rwc_test_param.keys_non_shift_path); + rte_free(tbl_rwc_test_param.keys_ext_bkt); + rte_free(tbl_rwc_test_param.keys_ks_extbkt); return 0; } From patchwork Tue Jul 2 00:27:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honnappa Nagarahalli X-Patchwork-Id: 55831 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0BAA81B9BA; Tue, 2 Jul 2019 02:27:46 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 29A3C1B9B2 for ; Tue, 2 Jul 2019 02:27:43 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9B5911424; Mon, 1 Jul 2019 17:27:42 -0700 (PDT) Received: from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com [10.118.12.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 88FD53F718; Mon, 1 Jul 2019 17:27:42 -0700 (PDT) From: Honnappa Nagarahalli To: yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com, david.marchand@redhat.com, honnappa.nagarahalli@arm.com Cc: dharmik.thakkar@arm.com, dev@dpdk.org, nd@arm.com Date: Mon, 1 Jul 2019 19:27:24 -0500 Message-Id: <20190702002724.41400-4-honnappa.nagarahalli@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702002724.41400-1-honnappa.nagarahalli@arm.com> References: <20190627032420.4730-1-honnappa.nagarahalli@arm.com> <20190702002724.41400-1-honnappa.nagarahalli@arm.com> Subject: [dpdk-dev] [PATCH v3 4/4] test/hash: use array for small amount of memory 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Variables of size 128B can make use of stack instead of dynamically allocated memory. Signed-off-by: Honnappa Nagarahalli --- v3 - Allocated pos on stack as it is just 128B v2 - N/A app/test/test_hash_readwrite_lf.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/test/test_hash_readwrite_lf.c b/app/test/test_hash_readwrite_lf.c index 792244fd0..f0d6f42c1 100644 --- a/app/test/test_hash_readwrite_lf.c +++ b/app/test/test_hash_readwrite_lf.c @@ -567,16 +567,9 @@ test_rwc_reader(__attribute__((unused)) void *arg) uint32_t read_cnt; uint32_t *keys; uint32_t extra_keys; - int32_t *pos; + int32_t pos[BULK_LOOKUP_SIZE]; void *temp_a[BULK_LOOKUP_SIZE]; - /* Used to identify keys not inserted in the hash table */ - pos = rte_malloc(NULL, sizeof(uint32_t) * BULK_LOOKUP_SIZE, 0); - if (pos == NULL) { - printf("RTE_MALLOC failed\n"); - return -1; - } - if (read_type & READ_FAIL) { keys = tbl_rwc_test_param.keys_absent; read_cnt = tbl_rwc_test_param.count_keys_absent;