[11/12] lib: add telemetry as eal dependency
diff mbox series

Message ID 20200319171907.60891-12-ciara.power@intel.com
State Superseded, archived
Delegated to: David Marchand
Headers show
Series
  • update and simplify telemetry library.
Related show

Checks

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

Commit Message

Power, Ciara March 19, 2020, 5:19 p.m. UTC
This patch moves telemetry further down the build, and adds it as a
dependency for EAL. Telemetry is now configured to build by default, and
has EAL flags, shown below:
"--telemetry" = Enables telemetry (this is default if no flags given)
"--no-telemetry" = Disables telemetry

When telemetry is enabled, it will attempt to open the new socket
version, and also the legacy support socket (this will depend on Jansson
external dependency, as before).

Signed-off-by: Ciara Power <ciara.power@intel.com>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/common_base                         |  2 +-
 lib/Makefile                               |  5 ++---
 lib/librte_eal/common/eal_common_options.c |  9 ++++++++
 lib/librte_eal/common/eal_internal_cfg.h   |  1 +
 lib/librte_eal/common/eal_options.h        |  4 ++++
 lib/librte_eal/freebsd/eal/Makefile        |  1 +
 lib/librte_eal/freebsd/eal/eal.c           |  9 ++++++++
 lib/librte_eal/freebsd/eal/meson.build     |  2 +-
 lib/librte_eal/linux/eal/Makefile          |  1 +
 lib/librte_eal/linux/eal/eal.c             |  9 ++++++++
 lib/librte_eal/linux/eal/meson.build       |  2 +-
 lib/librte_eal/meson.build                 |  2 +-
 lib/librte_telemetry/Makefile              |  1 -
 lib/librte_telemetry/meson.build           |  1 -
 lib/librte_telemetry/rte_telemetry.h       |  2 +-
 lib/librte_telemetry/telemetry.c           | 24 +++++-----------------
 lib/meson.build                            |  2 +-
 mk/rte.app.mk                              |  3 ++-
 18 files changed, 49 insertions(+), 31 deletions(-)

Comments

Jerin Jacob March 20, 2020, 12:03 p.m. UTC | #1
On Thu, Mar 19, 2020 at 11:07 PM Ciara Power <ciara.power@intel.com> wrote:
>
> This patch moves telemetry further down the build, and adds it as a
> dependency for EAL. Telemetry is now configured to build by default, and
> has EAL flags, shown below:
> "--telemetry" = Enables telemetry (this is default if no flags given)
> "--no-telemetry" = Disables telemetry
>
> When telemetry is enabled, it will attempt to open the new socket
> version, and also the legacy support socket (this will depend on Jansson
> external dependency, as before).
>
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  config/common_base                         |  2 +-

I think, update to doc/guides/linux_gsg/eal_args.include.rst file is missing.


>  lib/Makefile                               |  5 ++---
>  lib/librte_eal/common/eal_common_options.c |  9 ++++++++
>  lib/librte_eal/common/eal_internal_cfg.h   |  1 +
>  lib/librte_eal/common/eal_options.h        |  4 ++++
>  lib/librte_eal/freebsd/eal/Makefile        |  1 +
>  lib/librte_eal/freebsd/eal/eal.c           |  9 ++++++++
>  lib/librte_eal/freebsd/eal/meson.build     |  2 +-
>  lib/librte_eal/linux/eal/Makefile          |  1 +
>  lib/librte_eal/linux/eal/eal.c             |  9 ++++++++
>  lib/librte_eal/linux/eal/meson.build       |  2 +-
>  lib/librte_eal/meson.build                 |  2 +-
>  lib/librte_telemetry/Makefile              |  1 -
>  lib/librte_telemetry/meson.build           |  1 -
>  lib/librte_telemetry/rte_telemetry.h       |  2 +-
>  lib/librte_telemetry/telemetry.c           | 24 +++++-----------------
>  lib/meson.build                            |  2 +-
>  mk/rte.app.mk                              |  3 ++-
Bruce Richardson March 20, 2020, 1:50 p.m. UTC | #2
On Fri, Mar 20, 2020 at 05:33:38PM +0530, Jerin Jacob wrote:
> On Thu, Mar 19, 2020 at 11:07 PM Ciara Power <ciara.power@intel.com> wrote:
> >
> > This patch moves telemetry further down the build, and adds it as a
> > dependency for EAL. Telemetry is now configured to build by default, and
> > has EAL flags, shown below:
> > "--telemetry" = Enables telemetry (this is default if no flags given)
> > "--no-telemetry" = Disables telemetry
> >
> > When telemetry is enabled, it will attempt to open the new socket
> > version, and also the legacy support socket (this will depend on Jansson
> > external dependency, as before).
> >
> > Signed-off-by: Ciara Power <ciara.power@intel.com>
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> >  config/common_base                         |  2 +-
> 
> I think, update to doc/guides/linux_gsg/eal_args.include.rst file is missing.
> 
Yes.
I think doc updates generally are missing from this set, but we felt
it worthwhile to get a version out now for initial reviews. We'll get the
doc updates in a v2, along with some other enhancements to this work.

/Bruce

Patch
diff mbox series

diff --git a/config/common_base b/config/common_base
index 7ca2f28b1..b48f4469e 100644
--- a/config/common_base
+++ b/config/common_base
@@ -919,7 +919,7 @@  CONFIG_RTE_LIBRTE_LATENCY_STATS=y
 #
 # Compile librte_telemetry
 #
-CONFIG_RTE_LIBRTE_TELEMETRY=n
+CONFIG_RTE_LIBRTE_TELEMETRY=y
 
 #
 # Compile librte_rcu
diff --git a/lib/Makefile b/lib/Makefile
index 31b943817..51a1e3b7a 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -4,8 +4,9 @@ 
 include $(RTE_SDK)/mk/rte.vars.mk
 
 DIRS-$(CONFIG_RTE_LIBRTE_KVARGS) += librte_kvargs
+DIRS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += librte_telemetry
 DIRS-$(CONFIG_RTE_LIBRTE_EAL) += librte_eal
-DEPDIRS-librte_eal := librte_kvargs
+DEPDIRS-librte_eal := librte_kvargs librte_telemetry
 DIRS-$(CONFIG_RTE_LIBRTE_PCI) += librte_pci
 DEPDIRS-librte_pci := librte_eal
 DIRS-$(CONFIG_RTE_LIBRTE_RING) += librte_ring
@@ -22,8 +23,6 @@  DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile
 DEPDIRS-librte_cfgfile := librte_eal
 DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DEPDIRS-librte_cmdline := librte_eal librte_net
-DIRS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += librte_telemetry
-DEPDIRS-librte_telemetry := librte_eal
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ethdev
 DEPDIRS-librte_ethdev := librte_net librte_eal librte_mempool librte_ring
 DEPDIRS-librte_ethdev += librte_mbuf
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 75974dd5b..386566b3d 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -86,6 +86,8 @@  eal_long_options[] = {
 	{OPT_LEGACY_MEM,        0, NULL, OPT_LEGACY_MEM_NUM       },
 	{OPT_SINGLE_FILE_SEGMENTS, 0, NULL, OPT_SINGLE_FILE_SEGMENTS_NUM},
 	{OPT_MATCH_ALLOCATIONS, 0, NULL, OPT_MATCH_ALLOCATIONS_NUM},
+	{OPT_TELEMETRY,         0, NULL, OPT_TELEMETRY_NUM        },
+	{OPT_NO_TELEMETRY,      0, NULL, OPT_NO_TELEMETRY_NUM     },
 	{0,                     0, NULL, 0                        }
 };
 
@@ -1455,6 +1457,11 @@  eal_parse_common_option(int opt, const char *optarg,
 			return -1;
 		}
 		break;
+	case OPT_TELEMETRY_NUM:
+		break;
+	case OPT_NO_TELEMETRY_NUM:
+		conf->no_telemetry = 1;
+		break;
 
 	/* don't know what to do, leave this to caller */
 	default:
@@ -1698,6 +1705,8 @@  eal_common_usage(void)
 	       "  --"OPT_IN_MEMORY"   Operate entirely in memory. This will\n"
 	       "                      disable secondary process support\n"
 	       "  --"OPT_BASE_VIRTADDR"     Base virtual address\n"
+	       "  --"OPT_TELEMETRY"   Enable telemetry support (on by default)\n"
+	       "  --"OPT_NO_TELEMETRY"   Disable telemetry support\n"
 	       "\nEAL options for DEBUG use only:\n"
 	       "  --"OPT_HUGE_UNLINK"       Unlink hugepage files after init\n"
 	       "  --"OPT_NO_HUGE"           Use malloc instead of hugetlbfs\n"
diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
index a42f34923..c650bc081 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -82,6 +82,7 @@  struct internal_config {
 	rte_cpuset_t ctrl_cpuset;         /**< cpuset for ctrl threads */
 	volatile unsigned int init_complete;
 	/**< indicates whether EAL has completed initialization */
+	unsigned int no_telemetry; /**< true to disable Telemetry */
 };
 extern struct internal_config internal_config; /**< Global EAL configuration. */
 
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index 9855429e5..225ad4bb5 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -69,6 +69,10 @@  enum {
 	OPT_IOVA_MODE_NUM,
 #define OPT_MATCH_ALLOCATIONS  "match-allocations"
 	OPT_MATCH_ALLOCATIONS_NUM,
+#define OPT_TELEMETRY         "telemetry"
+	OPT_TELEMETRY_NUM,
+#define OPT_NO_TELEMETRY      "no-telemetry"
+	OPT_NO_TELEMETRY_NUM,
 	OPT_LONG_MAX_NUM
 };
 
diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile
index b160b5790..cf31cd16e 100644
--- a/lib/librte_eal/freebsd/eal/Makefile
+++ b/lib/librte_eal/freebsd/eal/Makefile
@@ -19,6 +19,7 @@  LDLIBS += -lexecinfo
 LDLIBS += -lpthread
 LDLIBS += -lgcc_s
 LDLIBS += -lrte_kvargs
+LDLIBS += -lrte_telemetry
 
 EXPORT_MAP := ../../rte_eal_version.map
 
diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c
index 6ae37e7e6..54acafc31 100644
--- a/lib/librte_eal/freebsd/eal/eal.c
+++ b/lib/librte_eal/freebsd/eal/eal.c
@@ -44,6 +44,7 @@ 
 #include <rte_option.h>
 #include <rte_atomic.h>
 #include <malloc_heap.h>
+#include <rte_telemetry.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -952,6 +953,14 @@  rte_eal_init(int argc, char **argv)
 		rte_eal_init_alert("Cannot clear runtime directory\n");
 		return -1;
 	}
+	if (!internal_config.no_telemetry) {
+		const char *error_str;
+		if (rte_telemetry_init(rte_eal_get_runtime_dir(),
+				&error_str) != 0) {
+			rte_eal_init_alert(error_str);
+			return -1;
+		}
+	}
 
 	eal_mcfg_complete();
 
diff --git a/lib/librte_eal/freebsd/eal/meson.build b/lib/librte_eal/freebsd/eal/meson.build
index 1426f7e5f..9960837c2 100644
--- a/lib/librte_eal/freebsd/eal/meson.build
+++ b/lib/librte_eal/freebsd/eal/meson.build
@@ -19,4 +19,4 @@  env_sources = files('eal_alarm.c',
 		'eal_dev.c'
 )
 
-deps += ['kvargs']
+deps += ['kvargs', 'telemetry']
diff --git a/lib/librte_eal/linux/eal/Makefile b/lib/librte_eal/linux/eal/Makefile
index e70cf104a..570e9229b 100644
--- a/lib/librte_eal/linux/eal/Makefile
+++ b/lib/librte_eal/linux/eal/Makefile
@@ -23,6 +23,7 @@  LDLIBS += -lpthread
 LDLIBS += -lgcc_s
 LDLIBS += -lrt
 LDLIBS += -lrte_kvargs
+LDLIBS += -lrte_telemetry
 ifeq ($(CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES),y)
 LDLIBS += -lnuma
 endif
diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index 9530ee55f..8eeffe9aa 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -51,6 +51,7 @@ 
 #include <malloc_heap.h>
 #include <rte_vfio.h>
 #include <rte_option.h>
+#include <rte_telemetry.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -1291,6 +1292,14 @@  rte_eal_init(int argc, char **argv)
 		rte_eal_init_alert("Cannot clear runtime directory\n");
 		return -1;
 	}
+	if (!internal_config.no_telemetry) {
+		const char *error_str;
+		if (rte_telemetry_init(rte_eal_get_runtime_dir(),
+				&error_str) != 0) {
+			rte_eal_init_alert(error_str);
+			return -1;
+		}
+	}
 
 	eal_mcfg_complete();
 
diff --git a/lib/librte_eal/linux/eal/meson.build b/lib/librte_eal/linux/eal/meson.build
index b02b0695f..67ef2fca8 100644
--- a/lib/librte_eal/linux/eal/meson.build
+++ b/lib/librte_eal/linux/eal/meson.build
@@ -25,7 +25,7 @@  env_sources = files('eal_alarm.c',
 		'eal_dev.c',
 )
 
-deps += ['kvargs']
+deps += ['kvargs', 'telemetry']
 if has_libnuma == 1
 	dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
 endif
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index 4be5118ce..83ce2dec0 100644
--- a/lib/librte_eal/meson.build
+++ b/lib/librte_eal/meson.build
@@ -13,7 +13,7 @@  dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env + '/eal')
 
 allow_experimental_apis = true
-deps += 'kvargs'
+deps += ['kvargs', 'telemetry']
 if dpdk_conf.has('RTE_USE_LIBBSD')
 	ext_deps += libbsd
 endif
diff --git a/lib/librte_telemetry/Makefile b/lib/librte_telemetry/Makefile
index 4982aa457..e9b00a3bb 100644
--- a/lib/librte_telemetry/Makefile
+++ b/lib/librte_telemetry/Makefile
@@ -14,7 +14,6 @@  CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common/include
 CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common/include/arch/$(ARCH_DIR)/
 CFLAGS += -pthread
 
-LDLIBS += -lrte_eal
 LDLIBS += -lpthread
 
 EXPORT_MAP := rte_telemetry_version.map
diff --git a/lib/librte_telemetry/meson.build b/lib/librte_telemetry/meson.build
index 5d5ac8925..9c24c2066 100644
--- a/lib/librte_telemetry/meson.build
+++ b/lib/librte_telemetry/meson.build
@@ -8,4 +8,3 @@  sources = files('telemetry.c', 'telemetry_legacy.c')
 headers = files('rte_telemetry.h')
 cflags += '-DALLOW_EXPERIMENTAL_API'
 includes += include_directories('../librte_metrics')
-dpdk_app_link_libraries += ['telemetry']
diff --git a/lib/librte_telemetry/rte_telemetry.h b/lib/librte_telemetry/rte_telemetry.h
index 2b988e6cb..094e3006c 100644
--- a/lib/librte_telemetry/rte_telemetry.h
+++ b/lib/librte_telemetry/rte_telemetry.h
@@ -75,6 +75,6 @@  int rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn);
  *  -1 on failure.
  */
 __rte_experimental
-int rte_telemetry_init(void);
+int rte_telemetry_init(const char *runtime_dir, const char **err_str);
 
 #endif
diff --git a/lib/librte_telemetry/telemetry.c b/lib/librte_telemetry/telemetry.c
index a81cad4ec..d4ced4c0c 100644
--- a/lib/librte_telemetry/telemetry.c
+++ b/lib/librte_telemetry/telemetry.c
@@ -13,7 +13,6 @@ 
 #include <rte_string_fns.h>
 #include <rte_common.h>
 #include <rte_spinlock.h>
-#include <rte_option.h>
 
 #include "rte_telemetry.h"
 #include "rte_telemetry_legacy.h"
@@ -279,26 +278,13 @@  telemetry_v2_init(const char *runtime_dir, const char **err_str)
 }
 
 int32_t
-rte_telemetry_init(void)
+rte_telemetry_init(const char *runtime_dir, const char **err_str)
 {
-	const char *error_str;
-	if (telemetry_v2_init(rte_eal_get_runtime_dir(), &error_str) != 0) {
-		printf("Error initialising telemetry - %s", error_str);
+	if (telemetry_v2_init(runtime_dir, err_str) != 0) {
+		printf("Error initialising telemetry - %s", *err_str);
 		return -1;
 	}
-	if (telemetry_legacy_init(rte_eal_get_runtime_dir(), &error_str)
-			!= 0)
-		printf("No telemetry legacy support- %s", error_str);
+	if (telemetry_legacy_init(runtime_dir, err_str) != 0)
+		printf("No telemetry legacy support- %s", *err_str);
 	return 0;
 }
-
-static struct rte_option option = {
-	.name = "telemetry",
-	.usage = "Enable telemetry backend",
-	.cb = &rte_telemetry_init,
-	.enabled = 0
-};
-
-RTE_INIT(telemetry_register_op) {
-	rte_option_register(&option);
-}
diff --git a/lib/meson.build b/lib/meson.build
index 77bed670e..a2ffc59d9 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -10,8 +10,8 @@ 
 # core libs which are widely reused, so their deps are kept to a minimum.
 libraries = [
 	'kvargs', # eal depends on kvargs
+	'telemetry', # basic info querying capability about dpdk processes
 	'eal', # everything depends on eal
-	'telemetry',
 	'ring', 'mempool', 'mbuf', 'net', 'meter', 'ethdev', 'pci', # core
 	'cmdline',
 	'metrics', # bitrate/latency stats depends on this
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index fdaf3ec2c..12fe3ce08 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -52,6 +52,7 @@  _LDLIBS-$(CONFIG_RTE_LIBRTE_ACL)            += -lrte_acl
 _LDLIBS-$(CONFIG_RTE_LIBRTE_JOBSTATS)       += -lrte_jobstats
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METRICS)        += --whole-archive
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METRICS)        += -lrte_metrics
+_LDLIBS-y += $(shell $(PKG_CONFIG) --libs jansson 2> /dev/null)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_METRICS)        += --no-whole-archive
 _LDLIBS-$(CONFIG_RTE_LIBRTE_BITRATE)        += -lrte_bitratestats
 _LDLIBS-$(CONFIG_RTE_LIBRTE_LATENCY_STATS)  += -lrte_latencystats
@@ -74,6 +75,7 @@  _LDLIBS-$(CONFIG_RTE_LIBRTE_HASH)           += -lrte_hash
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MEMBER)         += -lrte_member
 _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST)          += -lrte_vhost
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KVARGS)         += -lrte_kvargs
+_LDLIBS-$(CONFIG_RTE_LIBRTE_TELEMETRY)      += -lrte_telemetry
 _LDLIBS-$(CONFIG_RTE_LIBRTE_MBUF)           += -lrte_mbuf
 _LDLIBS-$(CONFIG_RTE_LIBRTE_NET)            += -lrte_net
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ETHER)          += -lrte_ethdev
@@ -90,7 +92,6 @@  _LDLIBS-$(CONFIG_RTE_DRIVER_MEMPOOL_RING)   += -lrte_mempool_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_OCTEONTX2_MEMPOOL) += -lrte_mempool_octeontx2
 _LDLIBS-$(CONFIG_RTE_LIBRTE_RING)           += -lrte_ring
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PCI)            += -lrte_pci
-_LDLIBS-$(CONFIG_RTE_LIBRTE_TELEMETRY)      += -lrte_telemetry -ljansson
 _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL)            += -lrte_eal
 _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder