[dpdk-dev] eal: list acceptable init priorities

Message ID 20180322155824.30723-1-gaetan.rivet@6wind.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues

Commit Message

Gaëtan Rivet March 22, 2018, 3:58 p.m. UTC
  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.

Cc: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 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(-)
  

Comments

Neil Horman March 23, 2018, 12:40 a.m. UTC | #1
On Thu, Mar 22, 2018 at 04:58:24PM +0100, 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.
> 
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
>  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 37b2e20e5..b384c72d3 100644
> --- a/lib/librte_eal/common/eal_common_log.c
> +++ b/lib/librte_eal/common/eal_common_log.c
> @@ -224,7 +224,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 46911afa7..747baf140 100644
> --- a/lib/librte_eal/common/include/rte_bus.h
> +++ b/lib/librte_eal/common/include/rte_bus.h
> @@ -326,7 +326,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 500fc3adb..5ff0de08f 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)
>  
>  /**
>   * Run after main() with high priority.
> -- 
> 2.11.0
> 
> 
This seems like a good start, something that we can expand if we need more priorities later
Acked-by: Neil Horman <nhorman@tuxdriver.com>
  

Patch

diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c
index 37b2e20e5..b384c72d3 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -224,7 +224,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 46911afa7..747baf140 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -326,7 +326,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 500fc3adb..5ff0de08f 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)
 
 /**
  * Run after main() with high priority.