From: Yoan Picchi <yoan.picchi@arm.com>
To: Thomas Monjalon <thomas@monjalon.net>,
Yipeng Wang <yipeng1.wang@intel.com>,
Sameh Gobriel <sameh.gobriel@intel.com>,
Bruce Richardson <bruce.richardson@intel.com>,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Cc: dev@dpdk.org, nd@arm.com, Yoan Picchi <yoan.picchi@arm.com>,
Harjot Singh <harjot.singh@arm.com>,
Ruifeng Wang <ruifeng.wang@arm.com>,
Nathan Brown <nathan.brown@arm.com>
Subject: [PATCH v11 6/7] test/hash: check bulk lookup of keys after collision
Date: Fri, 5 Jul 2024 17:45:25 +0000 [thread overview]
Message-ID: <20240705174526.3035295-7-yoan.picchi@arm.com> (raw)
In-Reply-To: <20240705174526.3035295-1-yoan.picchi@arm.com>
This patch adds unit test for rte_hash_lookup_bulk().
It also update the test_full_bucket test to the current number of entries
in a hash bucket.
Signed-off-by: Yoan Picchi <yoan.picchi@arm.com>
Signed-off-by: Harjot Singh <harjot.singh@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Nathan Brown <nathan.brown@arm.com>
---
.mailmap | 1 +
app/test/test_hash.c | 99 ++++++++++++++++++++++++++++++++++----------
2 files changed, 77 insertions(+), 23 deletions(-)
diff --git a/.mailmap b/.mailmap
index ec525981fe..41a8a99a7c 100644
--- a/.mailmap
+++ b/.mailmap
@@ -505,6 +505,7 @@ Hari Kumar Vemula <hari.kumarx.vemula@intel.com>
Harini Ramakrishnan <harini.ramakrishnan@microsoft.com>
Hariprasad Govindharajan <hariprasad.govindharajan@intel.com>
Harish Patil <harish.patil@cavium.com> <harish.patil@qlogic.com>
+Harjot Singh <harjot.singh@arm.com>
Harman Kalra <hkalra@marvell.com>
Harneet Singh <harneet.singh@intel.com>
Harold Huang <baymaxhuang@gmail.com>
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index 24d3b547ad..ab3b37de3f 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -95,7 +95,7 @@ static uint32_t pseudo_hash(__rte_unused const void *keys,
__rte_unused uint32_t key_len,
__rte_unused uint32_t init_val)
{
- return 3;
+ return 3 | (3 << 16);
}
RTE_LOG_REGISTER(hash_logtype_test, test.hash, INFO);
@@ -115,8 +115,10 @@ static void print_key_info(const char *msg, const struct flow_key *key,
rte_log(RTE_LOG_DEBUG, hash_logtype_test, " @ pos %d\n", pos);
}
+#define KEY_PER_BUCKET 8
+
/* Keys used by unit test functions */
-static struct flow_key keys[5] = { {
+static struct flow_key keys[KEY_PER_BUCKET+1] = { {
.ip_src = RTE_IPV4(0x03, 0x02, 0x01, 0x00),
.ip_dst = RTE_IPV4(0x07, 0x06, 0x05, 0x04),
.port_src = 0x0908,
@@ -146,6 +148,30 @@ static struct flow_key keys[5] = { {
.port_src = 0x4948,
.port_dst = 0x4b4a,
.proto = 0x4c,
+}, {
+ .ip_src = RTE_IPV4(0x53, 0x52, 0x51, 0x50),
+ .ip_dst = RTE_IPV4(0x57, 0x56, 0x55, 0x54),
+ .port_src = 0x5958,
+ .port_dst = 0x5b5a,
+ .proto = 0x5c,
+}, {
+ .ip_src = RTE_IPV4(0x63, 0x62, 0x61, 0x60),
+ .ip_dst = RTE_IPV4(0x67, 0x66, 0x65, 0x64),
+ .port_src = 0x6968,
+ .port_dst = 0x6b6a,
+ .proto = 0x6c,
+}, {
+ .ip_src = RTE_IPV4(0x73, 0x72, 0x71, 0x70),
+ .ip_dst = RTE_IPV4(0x77, 0x76, 0x75, 0x74),
+ .port_src = 0x7978,
+ .port_dst = 0x7b7a,
+ .proto = 0x7c,
+}, {
+ .ip_src = RTE_IPV4(0x83, 0x82, 0x81, 0x80),
+ .ip_dst = RTE_IPV4(0x87, 0x86, 0x85, 0x84),
+ .port_src = 0x8988,
+ .port_dst = 0x8b8a,
+ .proto = 0x8c,
} };
/* Parameters used for hash table in unit test functions. Name set later. */
@@ -783,13 +809,15 @@ static int test_five_keys(void)
/*
* Add keys to the same bucket until bucket full.
- * - add 5 keys to the same bucket (hash created with 4 keys per bucket):
- * first 4 successful, 5th successful, pushing existing item in bucket
- * - lookup the 5 keys: 5 hits
- * - add the 5 keys again: 5 OK
- * - lookup the 5 keys: 5 hits (updated data)
- * - delete the 5 keys: 5 OK
- * - lookup the 5 keys: 5 misses
+ * - add 9 keys to the same bucket (hash created with 8 keys per bucket):
+ * first 8 successful, 9th successful, pushing existing item in bucket
+ * - lookup the 9 keys: 9 hits
+ * - bulk lookup for all the 9 keys: 9 hits
+ * - add the 9 keys again: 9 OK
+ * - lookup the 9 keys: 9 hits (updated data)
+ * - delete the 9 keys: 9 OK
+ * - lookup the 9 keys: 9 misses
+ * - bulk lookup for all the 9 keys: 9 misses
*/
static int test_full_bucket(void)
{
@@ -801,16 +829,17 @@ static int test_full_bucket(void)
.hash_func_init_val = 0,
.socket_id = 0,
};
+ const void *key_array[KEY_PER_BUCKET+1] = {0};
struct rte_hash *handle;
- int pos[5];
- int expected_pos[5];
+ int pos[KEY_PER_BUCKET+1];
+ int expected_pos[KEY_PER_BUCKET+1];
unsigned i;
-
+ int ret;
handle = rte_hash_create(¶ms_pseudo_hash);
RETURN_IF_ERROR(handle == NULL, "hash creation failed");
/* Fill bucket */
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < KEY_PER_BUCKET; i++) {
pos[i] = rte_hash_add_key(handle, &keys[i]);
print_key_info("Add", &keys[i], pos[i]);
RETURN_IF_ERROR(pos[i] < 0,
@@ -821,22 +850,36 @@ static int test_full_bucket(void)
* This should work and will push one of the items
* in the bucket because it is full
*/
- pos[4] = rte_hash_add_key(handle, &keys[4]);
- print_key_info("Add", &keys[4], pos[4]);
- RETURN_IF_ERROR(pos[4] < 0,
- "failed to add key (pos[4]=%d)", pos[4]);
- expected_pos[4] = pos[4];
+ pos[KEY_PER_BUCKET] = rte_hash_add_key(handle, &keys[KEY_PER_BUCKET]);
+ print_key_info("Add", &keys[KEY_PER_BUCKET], pos[KEY_PER_BUCKET]);
+ RETURN_IF_ERROR(pos[KEY_PER_BUCKET] < 0,
+ "failed to add key (pos[%d]=%d)", KEY_PER_BUCKET, pos[KEY_PER_BUCKET]);
+ expected_pos[KEY_PER_BUCKET] = pos[KEY_PER_BUCKET];
/* Lookup */
- for (i = 0; i < 5; i++) {
+ for (i = 0; i < KEY_PER_BUCKET+1; i++) {
pos[i] = rte_hash_lookup(handle, &keys[i]);
print_key_info("Lkp", &keys[i], pos[i]);
RETURN_IF_ERROR(pos[i] != expected_pos[i],
"failed to find key (pos[%u]=%d)", i, pos[i]);
}
+ for (i = 0; i < KEY_PER_BUCKET+1; i++)
+ key_array[i] = &keys[i];
+
+ /*Bulk lookup after add with same hash*/
+ ret = rte_hash_lookup_bulk(handle, key_array, KEY_PER_BUCKET+1, (int32_t *)pos);
+ RETURN_IF_ERROR(ret, "rte_hash_lookup_bulk returned an error: %d\n", ret);
+ for (i = 0; i < KEY_PER_BUCKET+1; i++) {
+ print_key_info("Blk_Lkp", key_array[i], pos[i]);
+ RETURN_IF_ERROR(pos[i] != expected_pos[i],
+ "failed to find key (pos[%u]=%d)", i, pos[i]);
+ }
+
+
+
/* Add - update */
- for (i = 0; i < 5; i++) {
+ for (i = 0; i < KEY_PER_BUCKET+1; i++) {
pos[i] = rte_hash_add_key(handle, &keys[i]);
print_key_info("Add", &keys[i], pos[i]);
RETURN_IF_ERROR(pos[i] != expected_pos[i],
@@ -844,7 +887,7 @@ static int test_full_bucket(void)
}
/* Lookup */
- for (i = 0; i < 5; i++) {
+ for (i = 0; i < KEY_PER_BUCKET+1; i++) {
pos[i] = rte_hash_lookup(handle, &keys[i]);
print_key_info("Lkp", &keys[i], pos[i]);
RETURN_IF_ERROR(pos[i] != expected_pos[i],
@@ -869,7 +912,7 @@ static int test_full_bucket(void)
RETURN_IF_ERROR(pos[1] < 0, "failed to add key (pos[1]=%d)", pos[1]);
/* Delete */
- for (i = 0; i < 5; i++) {
+ for (i = 0; i < KEY_PER_BUCKET+1; i++) {
pos[i] = rte_hash_del_key(handle, &keys[i]);
print_key_info("Del", &keys[i], pos[i]);
RETURN_IF_ERROR(pos[i] != expected_pos[i],
@@ -877,13 +920,23 @@ static int test_full_bucket(void)
}
/* Lookup */
- for (i = 0; i < 5; i++) {
+ for (i = 0; i < KEY_PER_BUCKET+1; i++) {
pos[i] = rte_hash_lookup(handle, &keys[i]);
print_key_info("Lkp", &keys[i], pos[i]);
RETURN_IF_ERROR(pos[i] != -ENOENT,
"fail: found non-existent key (pos[%u]=%d)", i, pos[i]);
}
+ /* Bulk Lookup on empty table*/
+ ret = rte_hash_lookup_bulk(handle, &key_array[0], KEY_PER_BUCKET+1, (int32_t *)pos);
+ RETURN_IF_ERROR(ret, "rte_hash_lookup_bulk returned an error: %d\n", ret);
+ for (i = 0; i < KEY_PER_BUCKET+1; i++) {
+ print_key_info("Blk_Lkp", key_array[i], pos[i]);
+ RETURN_IF_ERROR(pos[i] != -ENOENT,
+ "failed to find key (pos[%u]=%d)", i, pos[i]);
+ }
+
+
rte_hash_free(handle);
/* Cover the NULL case. */
--
2.34.1
next prev parent reply other threads:[~2024-07-05 17:46 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-20 16:51 [PATCH v2 0/4] hash: add SVE support for bulk key lookup Yoan Picchi
2023-10-20 16:51 ` [PATCH v2 1/4] hash: pack the hitmask for hash in bulk lookup Yoan Picchi
2023-10-20 16:51 ` [PATCH v2 2/4] hash: optimize compare signature for NEON Yoan Picchi
2023-10-20 16:51 ` [PATCH v2 3/4] test/hash: check bulk lookup of keys after collision Yoan Picchi
2023-10-20 16:51 ` [PATCH v2 4/4] hash: add SVE support for bulk key lookup Yoan Picchi
2024-02-27 17:41 ` [PATCH v5 0/4] " Yoan Picchi
2024-02-27 17:42 ` [PATCH v5 1/4] hash: pack the hitmask for hash in bulk lookup Yoan Picchi
2024-02-27 17:42 ` [PATCH v5 2/4] hash: optimize compare signature for NEON Yoan Picchi
2024-02-27 17:42 ` [PATCH v5 3/4] test/hash: check bulk lookup of keys after collision Yoan Picchi
2024-02-27 17:42 ` [PATCH v5 4/4] hash: add SVE support for bulk key lookup Yoan Picchi
2024-02-28 10:56 ` Konstantin Ananyev
2024-02-28 14:48 ` Yoan Picchi
2024-03-04 13:35 ` Konstantin Ananyev
2024-03-05 15:36 ` Yoan Picchi
2024-03-11 23:21 ` [PATCH v6 0/4] " Yoan Picchi
2024-03-11 23:21 ` [PATCH v6 1/4] hash: pack the hitmask for hash in bulk lookup Yoan Picchi
2024-03-11 23:21 ` [PATCH v6 2/4] hash: optimize compare signature for NEON Yoan Picchi
2024-03-11 23:21 ` [PATCH v6 3/4] test/hash: check bulk lookup of keys after collision Yoan Picchi
2024-03-11 23:21 ` [PATCH v6 4/4] hash: add SVE support for bulk key lookup Yoan Picchi
2024-03-12 3:57 ` fengchengwen
2024-03-12 15:08 ` Yoan Picchi
2024-03-12 15:42 ` [PATCH v7 0/4] " Yoan Picchi
2024-03-12 15:42 ` [PATCH v7 1/4] hash: pack the hitmask for hash in bulk lookup Yoan Picchi
2024-03-19 10:41 ` Konstantin Ananyev
2024-03-19 13:09 ` Yoan Picchi
2024-03-19 13:25 ` Konstantin Ananyev
2024-03-19 16:09 ` Stephen Hemminger
2024-03-12 15:42 ` [PATCH v7 2/4] hash: optimize compare signature for NEON Yoan Picchi
2024-03-20 7:37 ` [EXTERNAL] " Pavan Nikhilesh Bhagavatula
2024-04-11 13:32 ` Yoan Picchi
2024-03-12 15:42 ` [PATCH v7 3/4] test/hash: check bulk lookup of keys after collision Yoan Picchi
2024-03-12 15:42 ` [PATCH v7 4/4] hash: add SVE support for bulk key lookup Yoan Picchi
2024-04-17 16:08 ` [PATCH v8 0/4] " Yoan Picchi
2024-04-17 16:08 ` [PATCH v8 1/4] hash: pack the hitmask for hash in bulk lookup Yoan Picchi
2024-04-17 18:12 ` Stephen Hemminger
2024-04-17 16:08 ` [PATCH v8 2/4] hash: optimize compare signature for NEON Yoan Picchi
2024-04-17 16:08 ` [PATCH v8 3/4] test/hash: check bulk lookup of keys after collision Yoan Picchi
2024-04-17 16:08 ` [PATCH v8 4/4] hash: add SVE support for bulk key lookup Yoan Picchi
2024-04-30 16:27 ` [PATCH v9 0/4] " Yoan Picchi
2024-04-30 16:27 ` [PATCH v9 1/4] hash: pack the hitmask for hash in bulk lookup Yoan Picchi
2024-06-14 13:42 ` David Marchand
2024-04-30 16:27 ` [PATCH v9 2/4] hash: optimize compare signature for NEON Yoan Picchi
2024-04-30 16:27 ` [PATCH v9 3/4] test/hash: check bulk lookup of keys after collision Yoan Picchi
2024-04-30 16:27 ` [PATCH v9 4/4] hash: add SVE support for bulk key lookup Yoan Picchi
2024-06-14 13:42 ` David Marchand
2024-06-14 13:43 ` [PATCH v9 0/4] " David Marchand
2024-06-18 15:55 ` Konstantin Ananyev
2024-06-27 14:48 ` Thomas Monjalon
2024-07-03 17:13 ` [PATCH v10 " Yoan Picchi
2024-07-03 17:13 ` [PATCH v10 1/4] hash: pack the hitmask for hash in bulk lookup Yoan Picchi
2024-07-04 20:31 ` David Marchand
2024-07-05 17:43 ` Yoan Picchi
2024-07-07 12:08 ` Thomas Monjalon
2024-07-03 17:13 ` [PATCH v10 2/4] hash: optimize compare signature for NEON Yoan Picchi
2024-07-03 17:13 ` [PATCH v10 3/4] test/hash: check bulk lookup of keys after collision Yoan Picchi
2024-07-03 17:13 ` [PATCH v10 4/4] hash: add SVE support for bulk key lookup Yoan Picchi
2024-07-05 17:45 ` [PATCH v11 0/7] " Yoan Picchi
2024-07-05 17:45 ` [PATCH v11 1/7] hash: make compare signature function enum private Yoan Picchi
2024-07-05 17:45 ` [PATCH v11 2/7] hash: split compare signature into arch-specific files Yoan Picchi
2024-07-05 17:45 ` [PATCH v11 3/7] hash: add a check on hash entry max size Yoan Picchi
2024-07-05 17:45 ` [PATCH v11 4/7] hash: pack the hitmask for hash in bulk lookup Yoan Picchi
2024-07-05 17:45 ` [PATCH v11 5/7] hash: optimize compare signature for NEON Yoan Picchi
2024-07-05 17:45 ` Yoan Picchi [this message]
2024-07-05 17:45 ` [PATCH v11 7/7] hash: add SVE support for bulk key lookup Yoan Picchi
2024-07-08 12:14 ` [PATCH v12 0/7] " Yoan Picchi
2024-07-08 12:14 ` [PATCH v12 1/7] hash: make compare signature function enum private Yoan Picchi
2024-07-08 12:14 ` [PATCH v12 2/7] hash: split compare signature into arch-specific files Yoan Picchi
2024-07-08 12:14 ` [PATCH v12 3/7] hash: add a check on hash entry max size Yoan Picchi
2024-07-08 12:14 ` [PATCH v12 4/7] hash: pack the hitmask for hash in bulk lookup Yoan Picchi
2024-07-08 12:14 ` [PATCH v12 5/7] hash: optimize compare signature for NEON Yoan Picchi
2024-07-08 12:14 ` [PATCH v12 6/7] test/hash: check bulk lookup of keys after collision Yoan Picchi
2024-07-08 12:14 ` [PATCH v12 7/7] hash: add SVE support for bulk key lookup Yoan Picchi
2024-07-09 4:48 ` [PATCH v12 0/7] " David Marchand
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=20240705174526.3035295-7-yoan.picchi@arm.com \
--to=yoan.picchi@arm.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=harjot.singh@arm.com \
--cc=nathan.brown@arm.com \
--cc=nd@arm.com \
--cc=ruifeng.wang@arm.com \
--cc=sameh.gobriel@intel.com \
--cc=thomas@monjalon.net \
--cc=vladimir.medvedkin@intel.com \
--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).