aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2024-05-06 09:23:28 +0300
committerMatias Elo <matias.elo@nokia.com>2024-06-05 13:11:08 +0300
commit6c61a637fed688a4240876451ecce06447cecce9 (patch)
treeb021139601218d83d659b39b0fc3dfda82860591
parentf8a2c2c9913e0859fdc5f0dae2fd41205cd667a6 (diff)
Port 71ba58f50 "linux-gen: thread: lock spinlock in odp_thrmask_worker() and odp_thrmask_control()"
Port original commit from linux-generic. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
-rw-r--r--platform/linux-dpdk/odp_thread.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/platform/linux-dpdk/odp_thread.c b/platform/linux-dpdk/odp_thread.c
index 646ff288f..cb290a115 100644
--- a/platform/linux-dpdk/odp_thread.c
+++ b/platform/linux-dpdk/odp_thread.c
@@ -316,12 +316,23 @@ int odp_thread_worker_count_max(void)
int odp_thrmask_worker(odp_thrmask_t *mask)
{
+ uint32_t num_worker;
+
+ odp_spinlock_lock(&thread_globals->lock);
odp_thrmask_copy(mask, &thread_globals->worker);
- return thread_globals->num_worker;
+ num_worker = thread_globals->num_worker;
+ odp_spinlock_unlock(&thread_globals->lock);
+ return num_worker;
+
}
int odp_thrmask_control(odp_thrmask_t *mask)
{
+ uint32_t num_control;
+
+ odp_spinlock_lock(&thread_globals->lock);
odp_thrmask_copy(mask, &thread_globals->control);
- return thread_globals->num_control;
+ num_control = thread_globals->num_control;
+ odp_spinlock_unlock(&thread_globals->lock);
+ return num_control;
}