From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet Subject: Re: [PATCH v5 02/21] eal: list acceptable init priorities Date: Thu, 12 Apr 2018 23:57:47 +0200 Message-ID: <20180412215747.f5ga5dh6rfoqx46l@bidouze.vm.6wind.com> References: <3c46c7947bec6462e07a6c33e39f680c8d9e688b.1523404469.git.gaetan.rivet@6wind.com> <20180412112826.GA8105@hmswarspite.think-freely.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: dev@dpdk.org To: Neil Horman Return-path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id AFEEF1B7C2 for ; Thu, 12 Apr 2018 23:58:02 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id x82so903898wmg.1 for ; Thu, 12 Apr 2018 14:58:02 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20180412112826.GA8105@hmswarspite.think-freely.org> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hello Neil, On Thu, Apr 12, 2018 at 07:28:26AM -0400, Neil Horman wrote: > On Wed, Apr 11, 2018 at 02:04:03AM +0200, Gaetan Rivet wrote: > > Build a central list to quickly see each used priorities for > > constructors, allowing to verify that they are both above 100 and in the > > proper order. > > > > Signed-off-by: Gaetan Rivet > > Acked-by: Neil Horman > > Acked-by: Shreyansh Jain > > --- > > lib/librte_eal/common/eal_common_log.c | 2 +- > > lib/librte_eal/common/include/rte_bus.h | 2 +- > > lib/librte_eal/common/include/rte_common.h | 8 +++++++- > > 3 files changed, 9 insertions(+), 3 deletions(-) > > > > diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c > > index a27192620..36b9d6e08 100644 > > --- a/lib/librte_eal/common/eal_common_log.c > > +++ b/lib/librte_eal/common/eal_common_log.c > > @@ -260,7 +260,7 @@ static const struct logtype logtype_strings[] = { > > }; > > > > /* Logging should be first initializer (before drivers and bus) */ > > -RTE_INIT_PRIO(rte_log_init, 101); > > +RTE_INIT_PRIO(rte_log_init, LOG); > > static void > > rte_log_init(void) > > { > > diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h > > index 6fb08341a..eb9eded4e 100644 > > --- a/lib/librte_eal/common/include/rte_bus.h > > +++ b/lib/librte_eal/common/include/rte_bus.h > > @@ -325,7 +325,7 @@ enum rte_iova_mode rte_bus_get_iommu_class(void); > > * The constructor has higher priority than PMD constructors. > > */ > > #define RTE_REGISTER_BUS(nm, bus) \ > > -RTE_INIT_PRIO(businitfn_ ##nm, 110); \ > > +RTE_INIT_PRIO(businitfn_ ##nm, BUS); \ > > static void businitfn_ ##nm(void) \ > > {\ > > (bus).name = RTE_STR(nm);\ > > diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h > > index 6c5bc5a76..8f04518f7 100644 > > --- a/lib/librte_eal/common/include/rte_common.h > > +++ b/lib/librte_eal/common/include/rte_common.h > > @@ -81,6 +81,12 @@ typedef uint16_t unaligned_uint16_t; > > */ > > #define RTE_SET_USED(x) (void)(x) > > > > +#define RTE_PRIORITY_LOG 101 > > +#define RTE_PRIORITY_BUS 110 > > + > > +#define RTE_PRIO(prio) \ > > + RTE_PRIORITY_ ## prio > > + > > /** > > * Run function before main() with low priority. > > * > > @@ -102,7 +108,7 @@ static void __attribute__((constructor, used)) func(void) > > * Lowest number is the first to run. > > */ > > #define RTE_INIT_PRIO(func, prio) \ > > -static void __attribute__((constructor(prio), used)) func(void) > > +static void __attribute__((constructor(RTE_PRIO(prio)), used)) func(void) > > > It just occured to me, that perhaps you should add a RTE_PRORITY_LAST priority, > and redefine RTE_INIT to RTE_INIT_PRIO(func, RTE_PRIORITY_LAST) for clarity. I > presume that constructors with no explicit priority run last, but the gcc > manual doesn't explicitly say that. It would be a heck of a bug to track down > if somehow unprioritized constructors ran early. > > Neil > While certainly poorly documented, the behavior is well-defined. I don't see a situation where the bug you describe could arise. Adding RTE_PRIORITY_LAST is pretty harmless, but I'm not sure it's justified to add it. If you still think it is useful, I will do it. I'd be curious to hear if anyone has had issues of this kind. -- Gaëtan Rivet 6WIND