eal: do not panic on CPU detection
authorAaron Conole <aconole@redhat.com>
Wed, 22 Mar 2017 20:19:27 +0000 (16:19 -0400)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 27 Mar 2017 13:47:10 +0000 (15:47 +0200)
There may be no way to gracefully recover, but the application
should be notified that a failure happened, rather than completely
aborting.  This allows the user to proceed with a "slow-path" type
solution.

After this change, the EAL CPU NUMA node resolution step can no longer
emit an rte_panic.  This aligns with the code in rte_eal_init, which
expects failures to return an error code.

Signed-off-by: Aaron Conole <aconole@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/librte_eal/bsdapp/eal/eal.c
lib/librte_eal/common/eal_common_lcore.c
lib/librte_eal/linuxapp/eal/eal.c

index ee7c9de..12df127 100644 (file)
@@ -56,6 +56,7 @@
 #include <rte_launch.h>
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
+#include <rte_errno.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
 #include <rte_log.h>
@@ -487,6 +488,12 @@ rte_eal_iopl_init(void)
        return 0;
 }
 
+static void rte_eal_init_alert(const char *msg)
+{
+       fprintf(stderr, "EAL: FATAL: %s\n", msg);
+       RTE_LOG(ERR, EAL, "%s\n", msg);
+}
+
 /* Launch threads, called at application init(). */
 int
 rte_eal_init(int argc, char **argv)
@@ -510,8 +517,11 @@ rte_eal_init(int argc, char **argv)
        /* 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");
+       if (rte_eal_cpu_init() < 0) {
+               rte_eal_init_alert("Cannot detect lcores.");
+               rte_errno = ENOTSUP;
+               return -1;
+       }
 
        fctret = eal_parse_args(argc, argv);
        if (fctret < 0)
index 2cd4132..84fa0cb 100644 (file)
@@ -83,16 +83,17 @@ rte_eal_cpu_init(void)
                config->lcore_role[lcore_id] = ROLE_RTE;
                lcore_config[lcore_id].core_id = eal_cpu_core_id(lcore_id);
                lcore_config[lcore_id].socket_id = eal_cpu_socket_id(lcore_id);
-               if (lcore_config[lcore_id].socket_id >= RTE_MAX_NUMA_NODES)
+               if (lcore_config[lcore_id].socket_id >= RTE_MAX_NUMA_NODES) {
 #ifdef RTE_EAL_ALLOW_INV_SOCKET_ID
                        lcore_config[lcore_id].socket_id = 0;
 #else
-                       rte_panic("Socket ID (%u) is greater than "
+                       RTE_LOG(ERR, EAL, "Socket ID (%u) is greater than "
                                "RTE_MAX_NUMA_NODES (%d)\n",
                                lcore_config[lcore_id].socket_id,
                                RTE_MAX_NUMA_NODES);
+                       return -1;
 #endif
-
+               }
                RTE_LOG(DEBUG, EAL, "Detected lcore %u as "
                                "core %u on socket %u\n",
                                lcore_id, lcore_config[lcore_id].core_id,
index bf6b818..81692e7 100644 (file)
@@ -61,6 +61,7 @@
 #include <rte_launch.h>
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
+#include <rte_errno.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
 #include <rte_log.h>
@@ -740,6 +741,12 @@ static int rte_eal_vfio_setup(void)
 }
 #endif
 
+static void rte_eal_init_alert(const char *msg)
+{
+       fprintf(stderr, "EAL: FATAL: %s\n", msg);
+       RTE_LOG(ERR, EAL, "%s\n", msg);
+}
+
 /* Launch threads, called at application init(). */
 int
 rte_eal_init(int argc, char **argv)
@@ -767,8 +774,11 @@ rte_eal_init(int argc, char **argv)
        /* 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");
+       if (rte_eal_cpu_init() < 0) {
+               rte_eal_init_alert("Cannot detect lcores.");
+               rte_errno = ENOTSUP;
+               return -1;
+       }
 
        fctret = eal_parse_args(argc, argv);
        if (fctret < 0)