From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 113A5A0096 for ; Thu, 9 May 2019 13:44:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DC4BC37B7; Thu, 9 May 2019 13:44:44 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 9DD7C2862 for ; Thu, 9 May 2019 13:44:43 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2019 04:44:42 -0700 X-ExtLoop1: 1 Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.251.91.208]) ([10.251.91.208]) by fmsmga001.fm.intel.com with ESMTP; 09 May 2019 04:44:41 -0700 To: Erik Gabriel Carrillo , rsanford@akamai.com, thomas@monjalon.net Cc: dev@dpdk.org References: <1557353861-31997-1-git-send-email-erik.g.carrillo@intel.com> From: "Burakov, Anatoly" Message-ID: Date: Thu, 9 May 2019 12:44:39 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1557353861-31997-1-git-send-email-erik.g.carrillo@intel.com> Content-Type: text/plain; charset="UTF-8"; format="flowed" Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] timer: allow first subsystem init from secondary X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190509114439.PXBOohpcGvg5ja_Zfh1b2R9oN9ua-A2C5-3tSSz_lYE@z> 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 > --- > 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 > #include > #include > +#include > > #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