From: Ciara Power <ciara.power@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
Ciara Power <ciara.power@intel.com>
Subject: [dpdk-dev] [RFC 2/6] eal: integrate process-info library
Date: Thu, 5 Dec 2019 17:31:24 +0000 [thread overview]
Message-ID: <20191205173128.64543-3-ciara.power@intel.com> (raw)
In-Reply-To: <20191205173128.64543-1-ciara.power@intel.com>
From: Bruce Richardson <bruce.richardson@intel.com>
Integrate the process info library into the EAL.
- Initialize the process-info library as part of EAL init.
This can be disabled using an EAL parameter.
- Register commands to provide some basic info from EAL.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Ciara Power <ciara.power@intel.com>
---
lib/Makefile | 2 +-
lib/librte_eal/common/eal_common_options.c | 75 ++++++++++++++++++++++
lib/librte_eal/common/eal_internal_cfg.h | 1 +
lib/librte_eal/common/eal_options.h | 5 ++
lib/librte_eal/freebsd/eal/Makefile | 1 +
lib/librte_eal/freebsd/eal/eal.c | 14 ++++
lib/librte_eal/linux/eal/Makefile | 1 +
lib/librte_eal/linux/eal/eal.c | 15 +++++
lib/librte_eal/meson.build | 2 +-
9 files changed, 114 insertions(+), 2 deletions(-)
diff --git a/lib/Makefile b/lib/Makefile
index 466cd04ef..cc61176da 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -6,7 +6,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
DIRS-$(CONFIG_RTE_LIBRTE_KVARGS) += librte_kvargs
DIRS-$(CONFIG_RTE_LIBRTE_PROCESS_INFO) += librte_process_info
DIRS-$(CONFIG_RTE_LIBRTE_EAL) += librte_eal
-DEPDIRS-librte_eal := librte_kvargs
+DEPDIRS-librte_eal := librte_kvargs librte_process_info
DIRS-$(CONFIG_RTE_LIBRTE_PCI) += librte_pci
DEPDIRS-librte_pci := librte_eal
DIRS-$(CONFIG_RTE_LIBRTE_RING) += librte_ring
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index a7f9c5f9b..0839a523d 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -25,6 +25,7 @@
#include <rte_version.h>
#include <rte_devargs.h>
#include <rte_memcpy.h>
+#include <rte_process_info.h>
#include "eal_internal_cfg.h"
#include "eal_options.h"
@@ -82,6 +83,7 @@ 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_NO_PROCESS_INFO, 0, NULL, OPT_NO_PROCESS_INFO_NUM },
{0, 0, NULL, 0 }
};
@@ -126,6 +128,75 @@ static int master_lcore_parsed;
static int mem_parsed;
static int core_parsed;
+static char **eal_args;
+static char **eal_app_args;
+
+#define EAL_PARAM_REQ "/eal:params"
+#define EAL_APP_PARAM_REQ "/eal:app_params"
+
+/* callback handler for process_info library to report out EAL flags */
+int
+handle_eal_info_request(const char *cmd, const char *params __rte_unused,
+ char *buffer, int buf_len)
+{
+ char **args;
+ int used = 0;
+ int i = 0;
+
+ if (strcmp(cmd, EAL_PARAM_REQ) == 0)
+ args = eal_args;
+ else if (strcmp(cmd, EAL_APP_PARAM_REQ) == 0)
+ args = eal_app_args;
+ else /* version */
+ return snprintf(buffer, buf_len, "\"%s\"", rte_version());
+
+ if (args == NULL || args[0] == NULL)
+ return snprintf(buffer, buf_len, "[]"); /* empty list */
+
+ used = strlcpy(buffer, "[", buf_len);
+ while (args[i] != NULL)
+ used += snprintf(buffer + used, buf_len - used, "\"%s\",",
+ args[i++]);
+ buffer[used - 1] = ']';
+ return used;
+}
+
+int
+eal_save_args(int argc, char **argv)
+{
+ int i, j;
+
+ /* clone argv to report out later. We overprovision, but
+ * this does not waste huge amounts of memory
+ */
+ eal_args = calloc(argc + 1, sizeof(*eal_args));
+ if (eal_args == NULL)
+ return -1;
+
+ for (i = 0; i < argc; i++) {
+ eal_args[i] = strdup(argv[i]);
+ if (strcmp(argv[i], "--") == 0)
+ break;
+ }
+ eal_args[i++] = NULL; /* always finish with NULL */
+ rte_process_info_register(EAL_PARAM_REQ, handle_eal_info_request);
+
+ /* allow reporting of any app args we know about too */
+ if (i == argc)
+ return 0;
+
+ eal_app_args = calloc(argc - i + 1, sizeof(*eal_args));
+ if (eal_app_args == NULL)
+ return -1;
+
+ for (j = 0; i < argc; j++, i++)
+ eal_app_args[j] = strdup(argv[i]);
+ eal_app_args[j] = NULL;
+ rte_process_info_register(EAL_APP_PARAM_REQ, handle_eal_info_request);
+
+ return 0;
+}
+
static int
eal_option_device_add(enum rte_devtype type, const char *optarg)
{
@@ -1446,6 +1517,9 @@ eal_parse_common_option(int opt, const char *optarg,
return -1;
}
break;
+ case OPT_NO_PROCESS_INFO_NUM:
+ conf->no_process_info = 1;
+ break;
/* don't know what to do, leave this to caller */
default:
@@ -1687,6 +1761,7 @@ 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_NO_PROCESS_INFO" Disable process info\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..c8226cb44 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_process_info; /**< true to disable Process Info */
};
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..0692666ef 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -69,6 +69,8 @@ enum {
OPT_IOVA_MODE_NUM,
#define OPT_MATCH_ALLOCATIONS "match-allocations"
OPT_MATCH_ALLOCATIONS_NUM,
+#define OPT_NO_PROCESS_INFO "no-process-info"
+ OPT_NO_PROCESS_INFO_NUM,
OPT_LONG_MAX_NUM
};
@@ -84,5 +86,8 @@ int eal_check_common_options(struct internal_config *internal_cfg);
void eal_common_usage(void);
enum rte_proc_type_t eal_proc_type_detect(void);
int eal_plugins_init(void);
+int eal_save_args(int argc, char **argv);
+int handle_eal_info_request(const char *cmd, const char *params __rte_unused,
+ char *buffer, int buf_len);
#endif /* EAL_OPTIONS_H */
diff --git a/lib/librte_eal/freebsd/eal/Makefile b/lib/librte_eal/freebsd/eal/Makefile
index b160b5790..3fd0d5edd 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_process_info
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..6d52b035f 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_process_info.h>
#include "eal_private.h"
#include "eal_thread.h"
@@ -724,6 +725,9 @@ rte_eal_init(int argc, char **argv)
eal_reset_internal_config(&internal_config);
+ /* clone argv to report out later in telemetry */
+ eal_save_args(argc, argv);
+
/* set log level as early as possible */
eal_log_level_parse(argc, argv);
@@ -952,6 +956,16 @@ rte_eal_init(int argc, char **argv)
rte_eal_init_alert("Cannot clear runtime directory\n");
return -1;
}
+ if (!internal_config.no_process_info) {
+ const char *error_str;
+ if (rte_process_info_init(rte_eal_get_runtime_dir(),
+ &error_str) != 0) {
+ rte_eal_init_alert(error_str);
+ return -1;
+ }
+ rte_process_info_register("/eal:version",
+ handle_eal_info_request);
+ }
eal_mcfg_complete();
diff --git a/lib/librte_eal/linux/eal/Makefile b/lib/librte_eal/linux/eal/Makefile
index e70cf104a..d09d2b4d0 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_process_info
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 c4233ec3c..e191be6e0 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -50,6 +50,7 @@
#include <malloc_heap.h>
#include <rte_vfio.h>
#include <rte_option.h>
+#include <rte_process_info.h>
#include "eal_private.h"
#include "eal_thread.h"
@@ -987,6 +988,9 @@ rte_eal_init(int argc, char **argv)
eal_reset_internal_config(&internal_config);
+ /* clone argv to report out later in telemetry */
+ eal_save_args(argc, argv);
+
/* set log level as early as possible */
eal_log_level_parse(argc, argv);
@@ -1291,6 +1295,17 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ if (!internal_config.no_process_info) {
+ const char *error_str;
+ if (rte_process_info_init(rte_eal_get_runtime_dir(),
+ &error_str) != 0) {
+ rte_eal_init_alert(error_str);
+ return -1;
+ }
+ rte_process_info_register("/eal:version",
+ handle_eal_info_request);
+ }
+
eal_mcfg_complete();
/* Call each registered callback, if enabled */
diff --git a/lib/librte_eal/meson.build b/lib/librte_eal/meson.build
index 4be5118ce..89ee3b6b8 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', 'process_info']
if dpdk_conf.has('RTE_USE_LIBBSD')
ext_deps += libbsd
endif
--
2.17.1
next prev parent reply other threads:[~2019-12-05 17:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-05 17:31 [dpdk-dev] [RFC 0/6] replace telemetry with process_info Ciara Power
2019-12-05 17:31 ` [dpdk-dev] [RFC 1/6] process-info: introduce process-info library Ciara Power
2019-12-05 17:31 ` Ciara Power [this message]
2019-12-05 17:31 ` [dpdk-dev] [RFC 3/6] usertools: add process-info python script Ciara Power
2019-12-05 17:31 ` [dpdk-dev] [RFC 4/6] ethdev: add callback support for process-info Ciara Power
2019-12-05 17:31 ` [dpdk-dev] [RFC 5/6] rawdev: " Ciara Power
2019-12-05 17:31 ` [dpdk-dev] [RFC 6/6] examples/l3fwd-power: enable use of process-info Ciara Power
2020-02-05 15:21 ` [dpdk-dev] [RFC 0/6] replace telemetry with process_info David Marchand
2020-02-05 17:12 ` Bruce Richardson
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=20191205173128.64543-3-ciara.power@intel.com \
--to=ciara.power@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/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).