From: "Montorsi, Francesco" <fmontorsi@empirix.com>
To: "Montorsi, Francesco" <fmontorsi@empirix.com>,
Panu Matilainen <pmatilai@redhat.com>,
Thomas Monjalon <thomas.monjalon@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] rte_eal_init() alternative?
Date: Fri, 9 Oct 2015 10:13:32 +0000 [thread overview]
Message-ID: <786931fdd268483eb6623389603dfbb6@bilemail1.empirix.com> (raw)
In-Reply-To: <69ead0cc07ec49f884b92de0756de3df@bilemail1.empirix.com>
> > It seems the patch missed the boat :)
>
> Correct, sorry. I'm attaching it now.
Ok, for some reason the email client is removing the attachment... I'm copying and pasting it:
(the points marked as TODO are functions that still contain rte_panic() calls...)
==== dpdk-2.1.0/lib/librte_eal/common/eal_common_log.c - dpdk-2.1.0/lib/librte_eal/common/eal_common_log.c ====
==== dpdk-2.1.0/lib/librte_eal/common/include/rte_eal.h - dpdk-2.1.0/lib/librte_eal/common/include/rte_eal.h ====
--- /tmp/tmp.6220.37 2015-10-08 16:15:22.402607404 +0200
+++ dpdk-2.1.0/lib/librte_eal/common/include/rte_eal.h 2015-10-08 15:57:21.442627152 +0200
@@ -141,6 +141,9 @@
* returning. See also the rte_eal_get_configuration() function. Note:
* This behavior may change in the future.
*
+ * This function will log and eventually abort the entire application if
+ * initialization fails.
+ *
* @param argc
* The argc argument that was given to the main() function.
* @param argv
@@ -153,6 +156,27 @@
* - On failure, a negative error value.
*/
int rte_eal_init(int argc, char **argv);
+
+/**
+ * Initialize the Environment Abstraction Layer (EAL).
+ *
+ * Please refer to rte_eal_init() for more information.
+ * The difference between rte_eal_init() and rte_eal_init_raw()
+ * is that the latter will never abort the entire process but rather
+ * will just log an error and return an error code.
+ *
+ * @param logid
+ * A string that identifies the whole process, used to prefix log messages;
+ * on Linux will be used as the 'ident' parameter of the syslog facility openlog().
+ * @param cfg
+ * The internal configuration for RTE EAL.
+ * @return
+ * - On success, zero.
+ * - On failure, a negative error value.
+ */
+struct internal_config;
+int rte_eal_init_raw(const char* logid, struct internal_config *cfg);
+
/**
* Usage function typedef used by the application usage function.
*
==== dpdk-2.1.0/lib/librte_eal/linuxapp/eal/eal.c - dpdk-2.1.0/lib/librte_eal/linuxapp/eal/eal.c ====
--- /tmp/tmp.6220.75 2015-10-08 16:15:22.406607404 +0200
+++ dpdk-2.1.0/lib/librte_eal/linuxapp/eal/eal.c 2015-10-08 16:15:10.106607628 +0200
@@ -178,7 +178,7 @@
* on other parts, e.g. memzones, to detect if there are running secondary
* processes. */
static void
-rte_eal_config_create(void)
+rte_eal_config_create(void) // TODO
{
void *rte_mem_cfg_addr;
int retval;
@@ -232,7 +232,7 @@
/* attach to an existing shared memory config */
static void
-rte_eal_config_attach(void)
+rte_eal_config_attach(void) // TODO
{
struct rte_mem_config *mem_config;
@@ -258,7 +258,7 @@
/* reattach the shared config at exact memory location primary process has it */
static void
-rte_eal_config_reattach(void)
+rte_eal_config_reattach(void) // TODO
{
struct rte_mem_config *mem_config;
void *rte_mem_cfg_addr;
@@ -305,7 +305,7 @@
/* Sets up rte_config structure with the pointer to shared memory config.*/
static void
-rte_config_init(void)
+rte_config_init(void) // TODO
{
rte_config.process_type = internal_config.process_type;
@@ -724,25 +724,17 @@
#endif
}
-/* Launch threads, called at application init(). */
+
+/* Launch threads, called at application init(). Logs and aborts on critical errors. */
int
rte_eal_init(int argc, char **argv)
{
- int i, fctret, ret;
- pthread_t thread_id;
- static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
- struct shared_driver *solib = NULL;
+ int fctret;
const char *logid;
- char cpuset[RTE_CPU_AFFINITY_STR_LEN];
-
- if (!rte_atomic32_test_and_set(&run_once))
- return -1;
logid = strrchr(argv[0], '/');
logid = strdup(logid ? logid + 1: argv[0]);
- thread_id = pthread_self();
-
if (rte_eal_log_early_init() < 0)
rte_panic("Cannot init early logs\n");
@@ -751,18 +743,54 @@
/* set log level as early as possible */
rte_set_log_level(internal_config.log_level);
- if (rte_eal_cpu_init() < 0)
- rte_panic("Cannot detect lcores\n");
-
fctret = eal_parse_args(argc, argv);
if (fctret < 0)
exit(1);
+ if (rte_eal_init_raw(logid, NULL) < 0)
+ rte_panic("Errors encountered during initialization. Cannot proceed.\n");
+
+ return fctret;
+}
+
+/* Library-style init(), will attempt initialization, log on errors and return;
+ * This function does not rte_panic() or exit() the whole process. */
+int
+rte_eal_init_raw(const char* logid, struct internal_config *cfg)
+{
+ int i, ret;
+ pthread_t thread_id;
+ static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
+ struct shared_driver *solib = NULL;
+ char cpuset[RTE_CPU_AFFINITY_STR_LEN];
+
+ if (!rte_atomic32_test_and_set(&run_once))
+ return -1;
+
+ thread_id = pthread_self();
+ if (rte_eal_log_early_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init early logs\n");
+ return -1;
+ }
+
+ if (cfg)
+ memcpy(&internal_config, cfg, sizeof(*cfg));
+
+ /* set log level as early as possible */
+ rte_set_log_level(internal_config.log_level);
+
+ if (rte_eal_cpu_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot detect lcores\n");
+ return -1;
+ }
+
if (internal_config.no_hugetlbfs == 0 &&
internal_config.process_type != RTE_PROC_SECONDARY &&
internal_config.xen_dom0_support == 0 &&
- eal_hugepage_info_init() < 0)
- rte_panic("Cannot get hugepage information\n");
+ eal_hugepage_info_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot get hugepage information\n");
+ return -1;
+ }
if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
if (internal_config.no_hugetlbfs)
@@ -786,42 +814,62 @@
rte_config_init();
- if (rte_eal_pci_init() < 0)
- rte_panic("Cannot init PCI\n");
+ if (rte_eal_pci_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init PCI\n");
+ return -1;
+ }
#ifdef RTE_LIBRTE_IVSHMEM
- if (rte_eal_ivshmem_init() < 0)
- rte_panic("Cannot init IVSHMEM\n");
+ if (rte_eal_ivshmem_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init IVSHMEM\n");
+ return -1;
+ }
#endif
- if (rte_eal_memory_init() < 0)
- rte_panic("Cannot init memory\n");
+ if (rte_eal_memory_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init memory\n");
+ return -1;
+ }
/* the directories are locked during eal_hugepage_info_init */
eal_hugedirs_unlock();
- if (rte_eal_memzone_init() < 0)
- rte_panic("Cannot init memzone\n");
+ if (rte_eal_memzone_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init memzone\n");
+ return -1;
+ }
- if (rte_eal_tailqs_init() < 0)
- rte_panic("Cannot init tail queues for objects\n");
+ if (rte_eal_tailqs_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init tail queues for objects\n");
+ return -1;
+ }
#ifdef RTE_LIBRTE_IVSHMEM
- if (rte_eal_ivshmem_obj_init() < 0)
- rte_panic("Cannot init IVSHMEM objects\n");
+ if (rte_eal_ivshmem_obj_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init IVSHMEM objects\n");
+ return -1;
+ }
#endif
- if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0)
- rte_panic("Cannot init logs\n");
+ if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init logs\n");
+ return -1;
+ }
- if (rte_eal_alarm_init() < 0)
- rte_panic("Cannot init interrupt-handling thread\n");
+ if (rte_eal_alarm_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init alarm\n");
+ return -1;
+ }
- if (rte_eal_intr_init() < 0)
- rte_panic("Cannot init interrupt-handling thread\n");
+ if (rte_eal_intr_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init interrupt-handling thread\n");
+ return -1;
+ }
- if (rte_eal_timer_init() < 0)
- rte_panic("Cannot init HPET or TSC timers\n");
+ if (rte_eal_timer_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init HPET or TSC timers\n");
+ return -1;
+ }
eal_check_mem_on_local_socket();
@@ -842,8 +890,10 @@
rte_config.master_lcore, (int)thread_id, cpuset,
ret == 0 ? "" : "...");
- if (rte_eal_dev_init() < 0)
- rte_panic("Cannot init pmd devices\n");
+ if (rte_eal_dev_init() < 0) {
+ RTE_LOG (ERR, EAL, "Cannot init pmd devices\n");
+ return -1;
+ }
RTE_LCORE_FOREACH_SLAVE(i) {
@@ -851,18 +901,24 @@
* create communication pipes between master thread
* and children
*/
- if (pipe(lcore_config[i].pipe_master2slave) < 0)
- rte_panic("Cannot create pipe\n");
- if (pipe(lcore_config[i].pipe_slave2master) < 0)
- rte_panic("Cannot create pipe\n");
+ if (pipe(lcore_config[i].pipe_master2slave) < 0) {
+ RTE_LOG (ERR, EAL, "Cannot create pipe\n");
+ return -1;
+ }
+ if (pipe(lcore_config[i].pipe_slave2master) < 0) {
+ RTE_LOG (ERR, EAL, "Cannot create pipe\n");
+ return -1;
+ }
lcore_config[i].state = WAIT;
/* create a thread for each lcore */
ret = pthread_create(&lcore_config[i].thread_id, NULL,
eal_thread_loop, NULL);
- if (ret != 0)
- rte_panic("Cannot create thread\n");
+ if (ret != 0) {
+ RTE_LOG (ERR, EAL, "Cannot create thread\n");
+ return -1;
+ }
}
/*
@@ -873,12 +929,15 @@
rte_eal_mp_wait_lcore();
/* Probe & Initialize PCI devices */
- if (rte_eal_pci_probe())
- rte_panic("Cannot probe PCI\n");
+ if (rte_eal_pci_probe()) {
+ RTE_LOG (ERR, EAL, "Cannot probe PCI\n");
+ return -1;
+ }
- return fctret;
+ return 0;
}
+
/* get core role */
enum rte_lcore_role_t
rte_eal_lcore_role(unsigned lcore_id)
next prev parent reply other threads:[~2015-10-09 10:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-02 12:49 Montorsi, Francesco
2015-09-02 12:56 ` Bruce Richardson
2015-09-02 13:10 ` Thomas Monjalon
2015-09-02 18:17 ` Don Provan
2015-09-02 19:00 ` Stephen Hemminger
2015-09-02 20:50 ` Marc Sune
2015-09-02 21:08 ` Thomas Monjalon
2015-09-02 22:01 ` Wiles, Keith
2015-09-08 18:01 ` Don Provan
2015-09-11 17:15 ` Wiles, Keith
2015-10-08 14:58 ` Montorsi, Francesco
2015-10-09 8:25 ` Panu Matilainen
2015-10-09 10:03 ` Montorsi, Francesco
2015-10-09 10:13 ` Montorsi, Francesco [this message]
2015-10-09 11:12 ` Panu Matilainen
2015-10-09 10:40 ` Panu Matilainen
2015-10-09 16:03 ` Thomas F Herbert
2015-09-02 14:08 ` Jay Rolette
2015-09-02 19:23 ` Zoltan Kiss
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=786931fdd268483eb6623389603dfbb6@bilemail1.empirix.com \
--to=fmontorsi@empirix.com \
--cc=dev@dpdk.org \
--cc=pmatilai@redhat.com \
--cc=thomas.monjalon@6wind.com \
/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).