MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_add_delete_free_lf

Function test_add_delete_free_lf

dpdk/app/test/test_hash.c:501–581  ·  view source on GitHub ↗

* Sequence of operations for a single key with 'rw concurrency lock free' set: * - add * - delete: hit * - free: hit * Repeat the test case when 'multi writer add' is enabled. * - add * - delete: hit * - free: hit */

Source from the content-addressed store, hash-verified

499 * - free: hit
500 */
501static int test_add_delete_free_lf(void)
502{
503/* Should match the #define LCORE_CACHE_SIZE value in rte_cuckoo_hash.h */
504#define LCORE_CACHE_SIZE 64
505 struct rte_hash *handle;
506 hash_sig_t hash_value;
507 int pos, expectedPos, delPos;
508 uint8_t extra_flag;
509 uint32_t i, ip_src;
510
511 extra_flag = ut_params.extra_flag;
512 ut_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF;
513 handle = rte_hash_create(&ut_params);
514 RETURN_IF_ERROR(handle == NULL, "hash creation failed");
515 ut_params.extra_flag = extra_flag;
516
517 /*
518 * The number of iterations is at least the same as the number of slots
519 * rte_hash allocates internally. This is to reveal potential issues of
520 * not freeing keys successfully.
521 */
522 for (i = 0; i < ut_params.entries + 1; i++) {
523 hash_value = rte_hash_hash(handle, &keys[0]);
524 pos = rte_hash_add_key_with_hash(handle, &keys[0], hash_value);
525 print_key_info("Add", &keys[0], pos);
526 RETURN_IF_ERROR(pos < 0, "failed to add key (pos=%d)", pos);
527 expectedPos = pos;
528
529 pos = rte_hash_del_key_with_hash(handle, &keys[0], hash_value);
530 print_key_info("Del", &keys[0], pos);
531 RETURN_IF_ERROR(pos != expectedPos,
532 "failed to delete key (pos=%d)", pos);
533 delPos = pos;
534
535 pos = rte_hash_free_key_with_position(handle, delPos);
536 print_key_info("Free", &keys[0], delPos);
537 RETURN_IF_ERROR(pos != 0,
538 "failed to free key (pos=%d)", delPos);
539 }
540
541 rte_hash_free(handle);
542
543 extra_flag = ut_params.extra_flag;
544 ut_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF |
545 RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD;
546 handle = rte_hash_create(&ut_params);
547 RETURN_IF_ERROR(handle == NULL, "hash creation failed");
548 ut_params.extra_flag = extra_flag;
549
550 ip_src = keys[0].ip_src;
551 /*
552 * The number of iterations is at least the same as the number of slots
553 * rte_hash allocates internally. This is to reveal potential issues of
554 * not freeing keys successfully.
555 */
556 for (i = 0; i < ut_params.entries + (RTE_MAX_LCORE - 1) *
557 (LCORE_CACHE_SIZE - 1) + 1; i++) {
558 keys[0].ip_src++;

Callers 1

test_hashFunction · 0.85

Calls 7

rte_hash_createFunction · 0.85
rte_hash_hashFunction · 0.85
rte_hash_freeFunction · 0.85
print_key_infoFunction · 0.70

Tested by

no test coverage detected