From: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
To: rsanford@akamai.com, thomas@monjalon.net
Cc: anatoly.burakov@intel.com, dev@dpdk.org
Subject: [dpdk-dev] [PATCH] timer: allow first subsystem init from secondary
Date: Wed, 8 May 2019 17:17:41 -0500 [thread overview]
Message-ID: <1557353861-31997-1-git-send-email-erik.g.carrillo@intel.com> (raw)
Message-ID: <20190508221741.JkfXuXyYsZLP25EOd2igW2su7uhDyG07ZuvQri07S7A@z> (raw)
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 <erik.g.carrillo@intel.com>
---
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);
+ 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;
- rte_timer_data_arr = mz->addr;
-
- rte_timer_data_arr[default_data_id].internal_flags |=
- FL_ALLOCATED;
-
- rte_timer_subsystem_initialized = 1;
+ return -ENOMEM;
+ }
- return 0;
+ do_full_init = true;
}
- mz = rte_memzone_reserve_aligned(mz_name,
- RTE_MAX_DATA_ELS * sizeof(*rte_timer_data_arr),
- SOCKET_ID_ANY, 0, RTE_CACHE_LINE_SIZE);
- if (mz == NULL)
- return -ENOMEM;
-
rte_timer_data_arr = mz->addr;
- for (i = 0; i < RTE_MAX_DATA_ELS; i++) {
- data = &rte_timer_data_arr[i];
+ if (do_full_init) {
+ for (i = 0; i < RTE_MAX_DATA_ELS; i++) {
+ data = &rte_timer_data_arr[i];
- for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
- rte_spinlock_init(
- &data->priv_timer[lcore_id].list_lock);
- data->priv_timer[lcore_id].prev_lcore = lcore_id;
+ for (lcore_id = 0; lcore_id < RTE_MAX_LCORE;
+ lcore_id++) {
+ rte_spinlock_init(
+ &data->priv_timer[lcore_id].list_lock);
+ data->priv_timer[lcore_id].prev_lcore =
+ lcore_id;
+ }
}
}
@@ -205,8 +207,8 @@ BIND_DEFAULT_SYMBOL(rte_timer_subsystem_init, _v1905, 19.05);
void __rte_experimental
rte_timer_subsystem_finalize(void)
{
- if (rte_timer_data_arr)
- rte_free(rte_timer_data_arr);
+ if (!rte_timer_subsystem_initialized)
+ return;
rte_timer_subsystem_initialized = 0;
}
--
2.6.4
next reply other threads:[~2019-05-08 22:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-08 22:17 Erik Gabriel Carrillo [this message]
2019-05-08 22:17 ` Erik Gabriel Carrillo
2019-05-09 11:44 ` Burakov, Anatoly
2019-05-09 11:44 ` Burakov, Anatoly
2019-05-09 19:47 ` Carrillo, Erik G
2019-05-09 19:47 ` Carrillo, Erik G
2019-05-09 19:39 ` [dpdk-dev] [PATCH v2] " Erik Gabriel Carrillo
2019-05-09 19:39 ` Erik Gabriel Carrillo
2019-05-09 19:51 ` Thomas Monjalon
2019-05-09 19:51 ` Thomas Monjalon
2019-05-09 20:08 ` Carrillo, Erik G
2019-05-09 20:12 ` Thomas Monjalon
2019-05-09 20:12 ` Thomas Monjalon
2019-05-09 21:19 ` Carrillo, Erik G
2019-05-09 21:19 ` Carrillo, Erik G
2019-05-09 22:07 ` Thomas Monjalon
2019-05-09 22:07 ` Thomas Monjalon
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=1557353861-31997-1-git-send-email-erik.g.carrillo@intel.com \
--to=erik.g.carrillo@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=rsanford@akamai.com \
--cc=thomas@monjalon.net \
/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).