From: Joyce Kong <joyce.kong@arm.com>
To: thomas@monjalon.net, david.marchand@redhat.com,
honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com,
konstantin.ananyev@intel.com, rsanford@akamai.com,
erik.g.carrillo@intel.com, olivier.matz@6wind.com,
yipeng1.wang@intel.com, sameh.gobriel@intel.com,
bruce.richardson@intel.com, vladimir.medvedkin@intel.com,
anatoly.burakov@intel.com, andrew.rybchenko@oktetlabs.ru,
jerinj@marvell.com, declan.doherty@intel.com,
ciara.power@intel.com, xiaoyun.li@intel.com,
nicolas.chautru@intel.com, maryam.tahhan@intel.com,
reshma.pattan@intel.com, cristian.dumitrescu@intel.com
Cc: dev@dpdk.org, nd@arm.com
Subject: [dpdk-dev] [PATCH v1 11/12] app/bbdev: use compiler atomics for thread sync
Date: Mon, 2 Aug 2021 05:18:46 -0500 [thread overview]
Message-ID: <20210802101847.3462-12-joyce.kong@arm.com> (raw)
In-Reply-To: <20210802101847.3462-1-joyce.kong@arm.com>
Convert rte_atomic usages to compiler atomic built-ins
for thread params sync in bbdev cases.
Signed-off-by: Joyce Kong <joyce.kong@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
app/test-bbdev/test_bbdev_perf.c | 135 ++++++++++++++-----------------
1 file changed, 59 insertions(+), 76 deletions(-)
diff --git a/app/test-bbdev/test_bbdev_perf.c b/app/test-bbdev/test_bbdev_perf.c
index 469597b8b3..dc62e16216 100644
--- a/app/test-bbdev/test_bbdev_perf.c
+++ b/app/test-bbdev/test_bbdev_perf.c
@@ -133,7 +133,7 @@ struct test_op_params {
uint16_t num_to_process;
uint16_t num_lcores;
int vector_mask;
- rte_atomic16_t sync;
+ uint16_t sync;
struct test_buffers q_bufs[RTE_MAX_NUMA_NODES][MAX_QUEUES];
};
@@ -148,9 +148,9 @@ struct thread_params {
uint8_t iter_count;
double iter_average;
double bler;
- rte_atomic16_t nb_dequeued;
- rte_atomic16_t processing_status;
- rte_atomic16_t burst_sz;
+ uint16_t nb_dequeued;
+ int16_t processing_status;
+ uint16_t burst_sz;
struct test_op_params *op_params;
struct rte_bbdev_dec_op *dec_ops[MAX_BURST];
struct rte_bbdev_enc_op *enc_ops[MAX_BURST];
@@ -2594,46 +2594,46 @@ dequeue_event_callback(uint16_t dev_id,
}
if (unlikely(event != RTE_BBDEV_EVENT_DEQUEUE)) {
- rte_atomic16_set(&tp->processing_status, TEST_FAILED);
+ __atomic_store_n(&tp->processing_status, TEST_FAILED, __ATOMIC_RELAXED);
printf(
"Dequeue interrupt handler called for incorrect event!\n");
return;
}
- burst_sz = rte_atomic16_read(&tp->burst_sz);
+ burst_sz = __atomic_load_n(&tp->burst_sz, __ATOMIC_RELAXED);
num_ops = tp->op_params->num_to_process;
if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
deq = rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
&tp->dec_ops[
- rte_atomic16_read(&tp->nb_dequeued)],
+ __atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
burst_sz);
else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
deq = rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
&tp->dec_ops[
- rte_atomic16_read(&tp->nb_dequeued)],
+ __atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
burst_sz);
else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
deq = rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
&tp->enc_ops[
- rte_atomic16_read(&tp->nb_dequeued)],
+ __atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
burst_sz);
else /*RTE_BBDEV_OP_TURBO_ENC*/
deq = rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
&tp->enc_ops[
- rte_atomic16_read(&tp->nb_dequeued)],
+ __atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
burst_sz);
if (deq < burst_sz) {
printf(
"After receiving the interrupt all operations should be dequeued. Expected: %u, got: %u\n",
burst_sz, deq);
- rte_atomic16_set(&tp->processing_status, TEST_FAILED);
+ __atomic_store_n(&tp->processing_status, TEST_FAILED, __ATOMIC_RELAXED);
return;
}
- if (rte_atomic16_read(&tp->nb_dequeued) + deq < num_ops) {
- rte_atomic16_add(&tp->nb_dequeued, deq);
+ if (__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED) + deq < num_ops) {
+ __atomic_fetch_add(&tp->nb_dequeued, deq, __ATOMIC_RELAXED);
return;
}
@@ -2670,7 +2670,7 @@ dequeue_event_callback(uint16_t dev_id,
if (ret) {
printf("Buffers validation failed\n");
- rte_atomic16_set(&tp->processing_status, TEST_FAILED);
+ __atomic_store_n(&tp->processing_status, TEST_FAILED, __ATOMIC_RELAXED);
}
switch (test_vector.op_type) {
@@ -2691,7 +2691,7 @@ dequeue_event_callback(uint16_t dev_id,
break;
default:
printf("Unknown op type: %d\n", test_vector.op_type);
- rte_atomic16_set(&tp->processing_status, TEST_FAILED);
+ __atomic_store_n(&tp->processing_status, TEST_FAILED, __ATOMIC_RELAXED);
return;
}
@@ -2700,7 +2700,7 @@ dequeue_event_callback(uint16_t dev_id,
tp->mbps += (((double)(num_ops * tb_len_bits)) / 1000000.0) /
((double)total_time / (double)rte_get_tsc_hz());
- rte_atomic16_add(&tp->nb_dequeued, deq);
+ __atomic_fetch_add(&tp->nb_dequeued, deq, __ATOMIC_RELAXED);
}
static int
@@ -2738,11 +2738,10 @@ throughput_intr_lcore_ldpc_dec(void *arg)
bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
- rte_atomic16_clear(&tp->processing_status);
- rte_atomic16_clear(&tp->nb_dequeued);
+ __atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
+ __atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
- while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
- rte_pause();
+ rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops,
num_to_process);
@@ -2790,17 +2789,15 @@ throughput_intr_lcore_ldpc_dec(void *arg)
* the number of operations is not a multiple of
* burst size.
*/
- rte_atomic16_set(&tp->burst_sz, num_to_enq);
+ __atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
/* Wait until processing of previous batch is
* completed
*/
- while (rte_atomic16_read(&tp->nb_dequeued) !=
- (int16_t) enqueued)
- rte_pause();
+ rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
}
if (j != TEST_REPETITIONS - 1)
- rte_atomic16_clear(&tp->nb_dequeued);
+ __atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
}
return TEST_SUCCESS;
@@ -2835,11 +2832,10 @@ throughput_intr_lcore_dec(void *arg)
bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
- rte_atomic16_clear(&tp->processing_status);
- rte_atomic16_clear(&tp->nb_dequeued);
+ __atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
+ __atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
- while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
- rte_pause();
+ rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops,
num_to_process);
@@ -2880,17 +2876,15 @@ throughput_intr_lcore_dec(void *arg)
* the number of operations is not a multiple of
* burst size.
*/
- rte_atomic16_set(&tp->burst_sz, num_to_enq);
+ __atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
/* Wait until processing of previous batch is
* completed
*/
- while (rte_atomic16_read(&tp->nb_dequeued) !=
- (int16_t) enqueued)
- rte_pause();
+ rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
}
if (j != TEST_REPETITIONS - 1)
- rte_atomic16_clear(&tp->nb_dequeued);
+ __atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
}
return TEST_SUCCESS;
@@ -2925,11 +2919,10 @@ throughput_intr_lcore_enc(void *arg)
bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
- rte_atomic16_clear(&tp->processing_status);
- rte_atomic16_clear(&tp->nb_dequeued);
+ __atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
+ __atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
- while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
- rte_pause();
+ rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops,
num_to_process);
@@ -2969,17 +2962,15 @@ throughput_intr_lcore_enc(void *arg)
* the number of operations is not a multiple of
* burst size.
*/
- rte_atomic16_set(&tp->burst_sz, num_to_enq);
+ __atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
/* Wait until processing of previous batch is
* completed
*/
- while (rte_atomic16_read(&tp->nb_dequeued) !=
- (int16_t) enqueued)
- rte_pause();
+ rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
}
if (j != TEST_REPETITIONS - 1)
- rte_atomic16_clear(&tp->nb_dequeued);
+ __atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
}
return TEST_SUCCESS;
@@ -3015,11 +3006,10 @@ throughput_intr_lcore_ldpc_enc(void *arg)
bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
- rte_atomic16_clear(&tp->processing_status);
- rte_atomic16_clear(&tp->nb_dequeued);
+ __atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
+ __atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
- while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
- rte_pause();
+ rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops,
num_to_process);
@@ -3061,17 +3051,15 @@ throughput_intr_lcore_ldpc_enc(void *arg)
* the number of operations is not a multiple of
* burst size.
*/
- rte_atomic16_set(&tp->burst_sz, num_to_enq);
+ __atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
/* Wait until processing of previous batch is
* completed
*/
- while (rte_atomic16_read(&tp->nb_dequeued) !=
- (int16_t) enqueued)
- rte_pause();
+ rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
}
if (j != TEST_REPETITIONS - 1)
- rte_atomic16_clear(&tp->nb_dequeued);
+ __atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
}
return TEST_SUCCESS;
@@ -3105,8 +3093,7 @@ throughput_pmd_lcore_dec(void *arg)
bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
- while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
- rte_pause();
+ rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
@@ -3209,8 +3196,7 @@ bler_pmd_lcore_ldpc_dec(void *arg)
bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
- while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
- rte_pause();
+ rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
@@ -3339,8 +3325,7 @@ throughput_pmd_lcore_ldpc_dec(void *arg)
bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
- while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
- rte_pause();
+ rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
@@ -3456,8 +3441,7 @@ throughput_pmd_lcore_enc(void *arg)
bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
- while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
- rte_pause();
+ rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops_enq,
num_ops);
@@ -3547,8 +3531,7 @@ throughput_pmd_lcore_ldpc_enc(void *arg)
bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
- while (rte_atomic16_read(&tp->op_params->sync) == SYNC_WAIT)
- rte_pause();
+ rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops_enq,
num_ops);
@@ -3731,7 +3714,7 @@ bler_test(struct active_device *ad,
else
return TEST_SKIPPED;
- rte_atomic16_set(&op_params->sync, SYNC_WAIT);
+ __atomic_store_n(&op_params->sync, SYNC_WAIT, __ATOMIC_RELAXED);
/* Main core is set at first entry */
t_params[0].dev_id = ad->dev_id;
@@ -3754,7 +3737,7 @@ bler_test(struct active_device *ad,
&t_params[used_cores++], lcore_id);
}
- rte_atomic16_set(&op_params->sync, SYNC_START);
+ __atomic_store_n(&op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = bler_function(&t_params[0]);
/* Main core is always used */
@@ -3849,7 +3832,7 @@ throughput_test(struct active_device *ad,
throughput_function = throughput_pmd_lcore_enc;
}
- rte_atomic16_set(&op_params->sync, SYNC_WAIT);
+ __atomic_store_n(&op_params->sync, SYNC_WAIT, __ATOMIC_RELAXED);
/* Main core is set at first entry */
t_params[0].dev_id = ad->dev_id;
@@ -3872,7 +3855,7 @@ throughput_test(struct active_device *ad,
&t_params[used_cores++], lcore_id);
}
- rte_atomic16_set(&op_params->sync, SYNC_START);
+ __atomic_store_n(&op_params->sync, SYNC_START, __ATOMIC_RELAXED);
ret = throughput_function(&t_params[0]);
/* Main core is always used */
@@ -3902,29 +3885,29 @@ throughput_test(struct active_device *ad,
* Wait for main lcore operations.
*/
tp = &t_params[0];
- while ((rte_atomic16_read(&tp->nb_dequeued) <
- op_params->num_to_process) &&
- (rte_atomic16_read(&tp->processing_status) !=
- TEST_FAILED))
+ while ((__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED) <
+ op_params->num_to_process) &&
+ (__atomic_load_n(&tp->processing_status, __ATOMIC_RELAXED) !=
+ TEST_FAILED))
rte_pause();
tp->ops_per_sec /= TEST_REPETITIONS;
tp->mbps /= TEST_REPETITIONS;
- ret |= (int)rte_atomic16_read(&tp->processing_status);
+ ret |= (int)__atomic_load_n(&tp->processing_status, __ATOMIC_RELAXED);
/* Wait for worker lcores operations */
for (used_cores = 1; used_cores < num_lcores; used_cores++) {
tp = &t_params[used_cores];
- while ((rte_atomic16_read(&tp->nb_dequeued) <
- op_params->num_to_process) &&
- (rte_atomic16_read(&tp->processing_status) !=
- TEST_FAILED))
+ while ((__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED) <
+ op_params->num_to_process) &&
+ (__atomic_load_n(&tp->processing_status, __ATOMIC_RELAXED) !=
+ TEST_FAILED))
rte_pause();
tp->ops_per_sec /= TEST_REPETITIONS;
tp->mbps /= TEST_REPETITIONS;
- ret |= (int)rte_atomic16_read(&tp->processing_status);
+ ret |= (int)__atomic_load_n(&tp->processing_status, __ATOMIC_RELAXED);
}
/* Print throughput if test passed */
--
2.17.1
next prev parent reply other threads:[~2021-08-02 10:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 10:18 [dpdk-dev] [PATCH v1 00/12] use compiler atomic builtins for app Joyce Kong
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 01/12] test/pmd_perf: use compiler atomic builtins for polling sync Joyce Kong
2021-11-08 22:50 ` Honnappa Nagarahalli
2021-11-10 6:10 ` Joyce Kong
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 02/12] test/ring_perf: use compiler atomic builtins for lcores sync Joyce Kong
2021-11-09 5:43 ` Honnappa Nagarahalli
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 03/12] test/timer: use compiler atomic builtins for sync Joyce Kong
2021-11-09 20:59 ` Honnappa Nagarahalli
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 04/12] test/stack_perf: use compiler atomics for lcore sync Joyce Kong
2021-11-09 21:12 ` Honnappa Nagarahalli
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 05/12] test/bpf: use compiler atomics for calculation Joyce Kong
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 06/12] test/func_reentrancy: use compiler atomic for data sync Joyce Kong
2021-11-09 21:54 ` Honnappa Nagarahalli
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 07/12] app/eventdev: use compiler atomic builtins for packets sync Joyce Kong
2021-11-10 23:19 ` Honnappa Nagarahalli
2021-11-11 7:27 ` Joyce Kong
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 08/12] app/crypto: use compiler atomic builtins for display sync Joyce Kong
2021-11-09 22:11 ` Honnappa Nagarahalli
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 09/12] app/compress: " Joyce Kong
2021-11-09 22:59 ` Honnappa Nagarahalli
2021-11-11 8:13 ` Joyce Kong
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 10/12] app/testpmd: use compiler atomic builtins for port sync Joyce Kong
2021-11-09 23:14 ` Honnappa Nagarahalli
2021-11-11 8:51 ` Joyce Kong
2021-08-02 10:18 ` Joyce Kong [this message]
2021-11-10 21:25 ` [PATCH v1 11/12] app/bbdev: use compiler atomics for thread sync Honnappa Nagarahalli
2021-08-02 10:18 ` [dpdk-dev] [PATCH v1 12/12] app: remove unnecessary include of atomic Joyce Kong
2021-10-21 6:35 ` [dpdk-dev] [PATCH v1 00/12] use compiler atomic builtins for app Joyce Kong
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=20210802101847.3462-12-joyce.kong@arm.com \
--to=joyce.kong@arm.com \
--cc=anatoly.burakov@intel.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=bruce.richardson@intel.com \
--cc=ciara.power@intel.com \
--cc=cristian.dumitrescu@intel.com \
--cc=david.marchand@redhat.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
--cc=erik.g.carrillo@intel.com \
--cc=honnappa.nagarahalli@arm.com \
--cc=jerinj@marvell.com \
--cc=konstantin.ananyev@intel.com \
--cc=maryam.tahhan@intel.com \
--cc=nd@arm.com \
--cc=nicolas.chautru@intel.com \
--cc=olivier.matz@6wind.com \
--cc=reshma.pattan@intel.com \
--cc=rsanford@akamai.com \
--cc=ruifeng.wang@arm.com \
--cc=sameh.gobriel@intel.com \
--cc=thomas@monjalon.net \
--cc=vladimir.medvedkin@intel.com \
--cc=xiaoyun.li@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).