On 08-May-19 11:17 PM, Erik Gabriel Carrillo wrote:
Since memzones can be reserved from secondary processes as well as
primary processes, if the first call to the timer subsystem init
function occurs in a secondary process, we should allow it to succeed.

Fixes: c0749f7096c7 ("timer: allow management in shared memory")

Signed-off-by: Erik Gabriel Carrillo <[email protected]>
---
  lib/librte_timer/rte_timer.c | 52 +++++++++++++++++++++++---------------------
  1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index 9f2e921..c0f5b87 100644
--- a/lib/librte_timer/rte_timer.c
+++ b/lib/librte_timer/rte_timer.c
@@ -25,6 +25,7 @@
  #include <rte_memzone.h>
  #include <rte_malloc.h>
  #include <rte_compat.h>
+#include <rte_errno.h>
#include "rte_timer.h" @@ -155,40 +156,41 @@ rte_timer_subsystem_init_v1905(void)
        struct rte_timer_data *data;
        int i, lcore_id;
        static const char *mz_name = "rte_timer_mz";
+       const size_t data_arr_size =
+                               RTE_MAX_DATA_ELS * sizeof(*rte_timer_data_arr);
+       bool do_full_init;
if (rte_timer_subsystem_initialized)
                return -EALREADY;
- if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
-               mz = rte_memzone_lookup(mz_name);
-               if (mz == NULL)
-                       return -EEXIST;
+lookup:
+       mz = rte_memzone_lookup(mz_name);

Wouldn't it be better to attempt to reserve outright, and then do a lookup on EEXIST?

+       if (mz == NULL) {
+               mz = rte_memzone_reserve_aligned(mz_name, data_arr_size,
+                               SOCKET_ID_ANY, 0, RTE_CACHE_LINE_SIZE);
+               if (mz == NULL) {
+                       if (rte_errno == EEXIST)
+                               goto lookup;


--
Thanks,
Anatoly

Reply via email to