aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2019-10-21 09:38:48 +0300
committerMatias Elo <matias.elo@nokia.com>2021-10-04 11:52:54 +0300
commit7ea90224a1c59cc26bd1c0c44fc1cab906ba798b (patch)
tree955a972be1b0f08e535404bc9af95898ce6d7edb
parentade7bd3fb7ee4b4bdf156bd2f1b6181fb72aa219 (diff)
linux-dpdk: thread: add counter for tracking thread mask changes
Add epoch counter for tracking changes to the global thread mask. An internal helper function _odp_thread_thrmask_epoch() is added for reading the epoch value. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Jere Leppänen <jere.leppanen@nokia.com>
-rw-r--r--platform/linux-dpdk/include/odp_thread_internal.h7
-rw-r--r--platform/linux-dpdk/odp_thread.c12
2 files changed, 18 insertions, 1 deletions
diff --git a/platform/linux-dpdk/include/odp_thread_internal.h b/platform/linux-dpdk/include/odp_thread_internal.h
index c95786810..6342cc420 100644
--- a/platform/linux-dpdk/include/odp_thread_internal.h
+++ b/platform/linux-dpdk/include/odp_thread_internal.h
@@ -23,6 +23,13 @@ extern "C" {
*/
int _odp_thread_cpu_ids(unsigned int cpu_ids[], int max_num);
+/**
+ * Read current epoch value of thread mask all
+ *
+ * @return Thread mask all epoch value
+ */
+uint64_t _odp_thread_thrmask_epoch(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/platform/linux-dpdk/odp_thread.c b/platform/linux-dpdk/odp_thread.c
index 0f8a55d5f..59394b3e4 100644
--- a/platform/linux-dpdk/odp_thread.c
+++ b/platform/linux-dpdk/odp_thread.c
@@ -8,6 +8,7 @@
#include <odp_posix_extensions.h>
#include <sched.h>
+#include <odp/api/atomic.h>
#include <odp/api/thread.h>
#include <odp/api/thrmask.h>
#include <odp/api/spinlock.h>
@@ -18,6 +19,7 @@
#include <odp/api/align.h>
#include <odp/api/cpu.h>
#include <odp_schedule_if.h>
+#include <odp/api/plat/atomic_inlines.h>
#include <odp/api/plat/thread_inlines.h>
#include <odp_thread_internal.h>
#include <odp_libconfig_internal.h>
@@ -37,7 +39,7 @@ typedef struct {
odp_thrmask_t worker;
odp_thrmask_t control;
};
-
+ odp_atomic_u64_t thrmask_all_epoch;
uint32_t num;
uint32_t num_worker;
uint32_t num_control;
@@ -88,6 +90,7 @@ int _odp_thread_init_global(void)
thread_globals->shm = shm;
odp_spinlock_init(&thread_globals->lock);
+ odp_atomic_init_u64(&thread_globals->thrmask_all_epoch, 0);
thread_globals->num_max = num_max;
ODP_PRINT("System config:\n");
ODP_PRINT(" system.thread_count_max: %d\n\n", num_max);
@@ -113,6 +116,11 @@ int _odp_thread_term_global(void)
return ret;
}
+uint64_t _odp_thread_thrmask_epoch(void)
+{
+ return odp_atomic_load_u64(&thread_globals->thrmask_all_epoch);
+}
+
int _odp_thread_cpu_ids(unsigned int cpu_ids[], int max_num)
{
odp_thrmask_t *all = &thread_globals->all;
@@ -138,6 +146,7 @@ static int alloc_id(odp_thread_type_t type)
for (thr = 0; thr < (int)thread_globals->num_max; thr++) {
if (odp_thrmask_isset(all, thr) == 0) {
odp_thrmask_set(all, thr);
+ odp_atomic_inc_u64(&thread_globals->thrmask_all_epoch);
if (type == ODP_THREAD_WORKER) {
odp_thrmask_set(&thread_globals->worker, thr);
@@ -166,6 +175,7 @@ static int free_id(int thr)
return -1;
odp_thrmask_clr(all, thr);
+ odp_atomic_inc_u64(&thread_globals->thrmask_all_epoch);
if (thread_globals->thr[thr].type == ODP_THREAD_WORKER) {
odp_thrmask_clr(&thread_globals->worker, thr);