* [dpdk-users] Failing to add entry to hashmap
@ 2021-04-09 1:35 Cacheco Gnudu
2021-04-09 22:05 ` Cacheco Gnudu
0 siblings, 1 reply; 2+ messages in thread
From: Cacheco Gnudu @ 2021-04-09 1:35 UTC (permalink / raw)
To: users
Hello everyone,
I'm programming a testbed with DPDK that needs to create a hashmap with
32768 entries and maybe more in the future. To create it, I use
rte_hash_add_key_data() inside a for loop.
I was checking the return value of rte_hash_add_key_data() and whenever
it was negative, the program would terminate with rte_exit(). Every time
it added the 32224th entry it would terminate with -ENOSPC. I replaced
rte_exit() to a simple printf() to let me know it received a negative
value from rte_hash_add_key_data(), but would keep adding new entries
and it does. It alternatively succeeds and fails, and when it fails its
always with -ENOSPC. At the end only 32640 entries are added.
I pasted the hash creation code and the end of the execution output as
well.
--- code starts here ---
/* ... */
#define MAX_IPS 32768
/* ... */
int err = 0;
static struct rte_hash *PPVE_HASHMAP;
struct rte_hash_parameters params = { 0 };
params.name = "ip_filter_hashmap";
params.entries = MAX_IPS;
params.key_len = sizeof(uint64_t);
params.hash_func = rte_jhash;
params.hash_func_init_val = 0;
params.socket_id = rte_socket_id();
uint32_t size = rte_hash_count(PPVE_HASHMAP);
printf("%d\n", size);
PPVE_HASHMAP = rte_hash_create(¶ms);
if (PPVE_HASHMAP == NULL)
rte_exit(EXIT_DPDK_FAIL,
"Failed to create hash table, errno = %d\n", rte_errno);
size = rte_hash_count(PPVE_HASHMAP);
printf("%d\n", size);
uint64_t key = 10, value = 0xdead;
for (int i = 0; i < MAX_IPS; i++) {
err = rte_hash_add_key_data(PPVE_HASHMAP, &key, &value);
uint32_t size = rte_hash_count(PPVE_HASHMAP);
printf("%d\n", size);
if (err < 0)
rte_exit(EXIT_DPDK_FAIL,
"Failed to add entry to hash table, err: %d\n", err);
key++;
}
/* ... */
--- code ends here ---
--- end of program output starts here ---
32635
32635
Failed to add entry to hash table, err: -28
32636
32637
32638
32639
32639
Failed to add entry to hash table, err: -28
32640
32640
Failed to add entry to hash table, err: -28
32640
Failed to add entry to hash table, err: -28
32640
Failed to add entry to hash table, err: -28
32640
Failed to add entry to hash table, err: -28
32640
Failed to add entry to hash table, err: -28
32640
Failed to add entry to hash table, err: -28
32640
Failed to add entry to hash table, err: -28
32640
Failed to add entry to hash table, err: -28
32640
Failed to add entry to hash table, err: -28
--- end of program output ends here ---
--
Sincerely,
Cacheco
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-users] Failing to add entry to hashmap
2021-04-09 1:35 [dpdk-users] Failing to add entry to hashmap Cacheco Gnudu
@ 2021-04-09 22:05 ` Cacheco Gnudu
0 siblings, 0 replies; 2+ messages in thread
From: Cacheco Gnudu @ 2021-04-09 22:05 UTC (permalink / raw)
To: users
On 4/8/21 10:35 PM, Cacheco Gnudu wrote:
> Hello everyone,
>
> I'm programming a testbed with DPDK that needs to create a hashmap with
> 32768 entries and maybe more in the future. To create it, I use
> rte_hash_add_key_data() inside a for loop.
>
> I was checking the return value of rte_hash_add_key_data() and whenever
> it was negative, the program would terminate with rte_exit(). Every time
> it added the 32224th entry it would terminate with -ENOSPC. I replaced
> rte_exit() to a simple printf() to let me know it received a negative
> value from rte_hash_add_key_data(), but would keep adding new entries
> and it does. It alternatively succeeds and fails, and when it fails its
> always with -ENOSPC. At the end only 32640 entries are added.
>
> I pasted the hash creation code and the end of the execution output as
> well.
>
> --- code starts here ---
> /* ... */
> #define MAX_IPS 32768
> /* ... */
> int err = 0;
> static struct rte_hash *PPVE_HASHMAP;
> struct rte_hash_parameters params = { 0 };
> params.name = "ip_filter_hashmap";
> params.entries = MAX_IPS;
> params.key_len = sizeof(uint64_t);
> params.hash_func = rte_jhash;
> params.hash_func_init_val = 0;
> params.socket_id = rte_socket_id();
>
> uint32_t size = rte_hash_count(PPVE_HASHMAP);
> printf("%d\n", size);
>
> PPVE_HASHMAP = rte_hash_create(¶ms);
> if (PPVE_HASHMAP == NULL)
> rte_exit(EXIT_DPDK_FAIL,
> "Failed to create hash table, errno = %d\n", rte_errno);
> size = rte_hash_count(PPVE_HASHMAP);
> printf("%d\n", size);
>
> uint64_t key = 10, value = 0xdead;
> for (int i = 0; i < MAX_IPS; i++) {
>
> err = rte_hash_add_key_data(PPVE_HASHMAP, &key, &value);
> uint32_t size = rte_hash_count(PPVE_HASHMAP);
>
> printf("%d\n", size);
> if (err < 0)
> rte_exit(EXIT_DPDK_FAIL,
> "Failed to add entry to hash table, err: %d\n", err);
> key++;
> }
> /* ... */
> --- code ends here ---
>
>
> --- end of program output starts here ---
> 32635
> 32635
> Failed to add entry to hash table, err: -28
> 32636
> 32637
> 32638
> 32639
> 32639
> Failed to add entry to hash table, err: -28
> 32640
> 32640
> Failed to add entry to hash table, err: -28
> 32640
> Failed to add entry to hash table, err: -28
> 32640
> Failed to add entry to hash table, err: -28
> 32640
> Failed to add entry to hash table, err: -28
> 32640
> Failed to add entry to hash table, err: -28
> 32640
> Failed to add entry to hash table, err: -28
> 32640
> Failed to add entry to hash table, err: -28
> 32640
> Failed to add entry to hash table, err: -28
> 32640
> Failed to add entry to hash table, err: -28
> --- end of program output ends here ---
>
I was trying some workarounds and used
params.entries = MAX_IPS+1;
Apparently it worked, rte_hash_add_key_data() can add all entries now,
I'm just not sure if this approach is exactly correct. If anyone has any
suggestions let me know.
--
Sincerely,
Cacheco
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-09 22:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09 1:35 [dpdk-users] Failing to add entry to hashmap Cacheco Gnudu
2021-04-09 22:05 ` Cacheco Gnudu
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).