DPDK patches and discussions
 help / color / mirror / Atom feed
From: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
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
Subject: [dpdk-dev] [PATCH v2 2/3] test/hash: init hash parameters in the correct function
Date: Thu, 27 Jun 2019 23:52:53 -0500	[thread overview]
Message-ID: <20190628045254.17614-2-honnappa.nagarahalli@arm.com> (raw)
In-Reply-To: <20190628045254.17614-1-honnappa.nagarahalli@arm.com>

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 <honnappa.nagarahalli@arm.com>
Reviewed-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
---
 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)
-- 
2.17.1


  reply	other threads:[~2019-06-28  4:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-27  3:24 [dpdk-dev] [PATCH 1/3] test/hash: reset global variable to discard old data Honnappa Nagarahalli
2019-06-27  3:24 ` [dpdk-dev] [PATCH 2/3] test/hash: free allocated memory Honnappa Nagarahalli
2019-06-27  8:07   ` [dpdk-dev] [dpdk-stable] " David Marchand
2019-06-28  4:59     ` Honnappa Nagarahalli
2019-06-28  8:36       ` David Marchand
2019-06-27  3:24 ` [dpdk-dev] [PATCH 3/3] test/hash: init hash parameters in the correct function Honnappa Nagarahalli
2019-06-27  8:07   ` [dpdk-dev] [dpdk-stable] " David Marchand
2019-06-28  4:55     ` Honnappa Nagarahalli
2019-06-28  4:52 ` [dpdk-dev] [PATCH v2 1/3] test/hash: reset global variable to discard old data Honnappa Nagarahalli
2019-06-28  4:52   ` Honnappa Nagarahalli [this message]
2019-06-28  4:52   ` [dpdk-dev] [PATCH v2 3/3] test/hash: free allocated memory Honnappa Nagarahalli
2019-06-28  8:38     ` [dpdk-dev] [dpdk-stable] " David Marchand
2019-07-02  0:27 ` [dpdk-dev] [PATCH v3 1/4] test/hash: reset global variable to discard old data Honnappa Nagarahalli
2019-07-02  0:27   ` [dpdk-dev] [PATCH v3 2/4] test/hash: init hash parameters in the correct function Honnappa Nagarahalli
2019-07-02  0:27   ` [dpdk-dev] [PATCH v3 3/4] test/hash: free allocated memory Honnappa Nagarahalli
2019-07-02  0:27   ` [dpdk-dev] [PATCH v3 4/4] test/hash: use array for small amount of memory Honnappa Nagarahalli
2019-07-05  8:46   ` [dpdk-dev] [PATCH v3 1/4] test/hash: reset global variable to discard old data Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190628045254.17614-2-honnappa.nagarahalli@arm.com \
    --to=honnappa.nagarahalli@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dharmik.thakkar@arm.com \
    --cc=nd@arm.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=sameh.gobriel@intel.com \
    --cc=stable@dpdk.org \
    --cc=yipeng1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).