Skip to content

Commit

Permalink
test/hash: use existing lcore API
Browse files Browse the repository at this point in the history
Prefer the existing apis rather than direct access the configuration
structure.

test_hash_multi_add_lookup() currently starts n readers and N writers
using rte_eal_remote_launch().
It then waits for the N writers to complete with a custom
multi_writer_done[] array to synchronise over.
Jump on the occasion to use rte_eal_wait_lcore() so that the code is
more straightforward:
- we start n readers with rte_eal_remote_launch(),
- we start N writers with rte_eal_remote_launch(),
- we wait for N writers to join with rte_eal_wait_lcore(),
- we wait for n readers to join with rte_eal_wait_lcore(),

Fixes: c7eb097 ("test/hash: add lock-free r/w concurrency")
Fixes: 3f9aab9 ("test/hash: check lock-free extendable bucket")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
david-marchand authored and tmonjalo committed May 29, 2019
1 parent 4df7d46 commit dfd9d55
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions app/test/test_hash_readwrite_lf.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ static rte_atomic64_t gread_cycles;
static rte_atomic64_t greads;

static volatile uint8_t writer_done;
static volatile uint8_t multi_writer_done[4];

uint16_t enabled_core_ids[RTE_MAX_LCORE];

Expand Down Expand Up @@ -690,7 +689,6 @@ test_rwc_multi_writer(__attribute__((unused)) void *arg)
for (i = offset; i < offset + tbl_rwc_test_param.single_insert; i++)
rte_hash_add_key(tbl_rwc_test_param.h,
tbl_rwc_test_param.keys_ks + i);
multi_writer_done[pos_core] = 1;
return 0;
}

Expand Down Expand Up @@ -738,10 +736,9 @@ test_hash_add_no_ks_lookup_hit(struct rwc_perf *rwc_perf_results, int rwc_lf,
rte_eal_remote_launch(test_rwc_reader,
(void *)(uintptr_t)read_type,
enabled_core_ids[i]);
rte_eal_mp_wait_lcore();

for (i = 1; i <= rwc_core_cnt[n]; i++)
if (lcore_config[i].ret < 0)
if (rte_eal_wait_lcore(i) < 0)
goto err;

unsigned long long cycles_per_lookup =
Expand All @@ -758,6 +755,7 @@ test_hash_add_no_ks_lookup_hit(struct rwc_perf *rwc_perf_results, int rwc_lf,
return 0;

err:
rte_eal_mp_wait_lcore();
rte_hash_free(tbl_rwc_test_param.h);
return -1;
}
Expand Down Expand Up @@ -808,12 +806,11 @@ test_hash_add_no_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf,
enabled_core_ids[i]);
ret = write_keys(write_type);
writer_done = 1;
rte_eal_mp_wait_lcore();

if (ret < 0)
goto err;
for (i = 1; i <= rwc_core_cnt[n]; i++)
if (lcore_config[i].ret < 0)
if (rte_eal_wait_lcore(i) < 0)
goto err;

unsigned long long cycles_per_lookup =
Expand All @@ -830,6 +827,7 @@ test_hash_add_no_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf,
return 0;

err:
rte_eal_mp_wait_lcore();
rte_hash_free(tbl_rwc_test_param.h);
return -1;
}
Expand Down Expand Up @@ -884,12 +882,11 @@ test_hash_add_ks_lookup_hit_non_sp(struct rwc_perf *rwc_perf_results,
write_type = WRITE_KEY_SHIFT;
ret = write_keys(write_type);
writer_done = 1;
rte_eal_mp_wait_lcore();

if (ret < 0)
goto err;
for (i = 1; i <= rwc_core_cnt[n]; i++)
if (lcore_config[i].ret < 0)
if (rte_eal_wait_lcore(i) < 0)
goto err;

unsigned long long cycles_per_lookup =
Expand All @@ -906,6 +903,7 @@ test_hash_add_ks_lookup_hit_non_sp(struct rwc_perf *rwc_perf_results,
return 0;

err:
rte_eal_mp_wait_lcore();
rte_hash_free(tbl_rwc_test_param.h);
return -1;
}
Expand Down Expand Up @@ -960,12 +958,11 @@ test_hash_add_ks_lookup_hit_sp(struct rwc_perf *rwc_perf_results, int rwc_lf,
write_type = WRITE_KEY_SHIFT;
ret = write_keys(write_type);
writer_done = 1;
rte_eal_mp_wait_lcore();

if (ret < 0)
goto err;
for (i = 1; i <= rwc_core_cnt[n]; i++)
if (lcore_config[i].ret < 0)
if (rte_eal_wait_lcore(i) < 0)
goto err;

unsigned long long cycles_per_lookup =
Expand All @@ -982,6 +979,7 @@ test_hash_add_ks_lookup_hit_sp(struct rwc_perf *rwc_perf_results, int rwc_lf,
return 0;

err:
rte_eal_mp_wait_lcore();
rte_hash_free(tbl_rwc_test_param.h);
return -1;
}
Expand Down Expand Up @@ -1035,12 +1033,11 @@ test_hash_add_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf, int
write_type = WRITE_KEY_SHIFT;
ret = write_keys(write_type);
writer_done = 1;
rte_eal_mp_wait_lcore();

if (ret < 0)
goto err;
for (i = 1; i <= rwc_core_cnt[n]; i++)
if (lcore_config[i].ret < 0)
if (rte_eal_wait_lcore(i) < 0)
goto err;

unsigned long long cycles_per_lookup =
Expand All @@ -1056,6 +1053,7 @@ test_hash_add_ks_lookup_miss(struct rwc_perf *rwc_perf_results, int rwc_lf, int
return 0;

err:
rte_eal_mp_wait_lcore();
rte_hash_free(tbl_rwc_test_param.h);
return -1;
}
Expand Down Expand Up @@ -1108,8 +1106,6 @@ test_hash_multi_add_lookup(struct rwc_perf *rwc_perf_results, int rwc_lf,

rte_hash_reset(tbl_rwc_test_param.h);
writer_done = 0;
for (i = 0; i < 4; i++)
multi_writer_done[i] = 0;
write_type = WRITE_NO_KEY_SHIFT;
if (write_keys(write_type) < 0)
goto err;
Expand All @@ -1133,15 +1129,15 @@ test_hash_multi_add_lookup(struct rwc_perf *rwc_perf_results, int rwc_lf,
}

/* Wait for writers to complete */
for (i = 0; i < rwc_core_cnt[m]; i++)
while
(multi_writer_done[i] == 0);
writer_done = 1;
for (i = rwc_core_cnt[n] + 1;
i <= rwc_core_cnt[m] + rwc_core_cnt[n];
i++)
rte_eal_wait_lcore(i);

rte_eal_mp_wait_lcore();
writer_done = 1;

for (i = 1; i <= rwc_core_cnt[n]; i++)
if (lcore_config[i].ret < 0)
if (rte_eal_wait_lcore(i) < 0)
goto err;

unsigned long long cycles_per_lookup =
Expand All @@ -1160,6 +1156,7 @@ test_hash_multi_add_lookup(struct rwc_perf *rwc_perf_results, int rwc_lf,
return 0;

err:
rte_eal_mp_wait_lcore();
rte_hash_free(tbl_rwc_test_param.h);
return -1;
}
Expand Down Expand Up @@ -1222,10 +1219,9 @@ test_hash_add_ks_lookup_hit_extbkt(struct rwc_perf *rwc_perf_results,
}
}
writer_done = 1;
rte_eal_mp_wait_lcore();

for (i = 1; i <= rwc_core_cnt[n]; i++)
if (lcore_config[i].ret < 0)
if (rte_eal_wait_lcore(i) < 0)
goto err;

unsigned long long cycles_per_lookup =
Expand All @@ -1242,6 +1238,7 @@ test_hash_add_ks_lookup_hit_extbkt(struct rwc_perf *rwc_perf_results,
return 0;

err:
rte_eal_mp_wait_lcore();
rte_hash_free(tbl_rwc_test_param.h);
return -1;
}
Expand Down

0 comments on commit dfd9d55

Please sign in to comment.