This commit adds a new function rte_eal_cleanup().
The function serves as a hook to allow DPDK to release
internal resources (e.g.: hugepage allocations).
This function allows DPDK to become more like an ordinary
library, where the library context itself can be initialized
and cleaned up by the application.
The rte_exit() and rte_panic() functions must be considered,
particularly if they should call rte_eal_cleanup() to release any
resources or not. This patch adds the cleanup to rte_exit(),
but does not clean up on rte_panic(). The reason to not clean
up on panicing is that the developer may wish to inspect the
exact internal state of EAL and hugepages.
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Vipin Varghese <vipin.varghese@intel.com>
The creation and initialization functions for these objects are not multi-thread safe.
However, once initialized, the objects themselves can safely be used in multiple threads simultaneously.
+Shutdown and Cleanup
+~~~~~~~~~~~~~~~~~~~~
+
+During the initialization of EAL resources such as hugepage backed memory can be
+allocated by core components. The memory allocated during ``rte_eal_init()``
+can be released by calling the ``rte_eal_cleanup()`` function. Refer to the
+API documentation for details.
+
Multi-process Support
~~~~~~~~~~~~~~~~~~~~~
Also, make sure to start the actual text at the margin.
=========================================================
+* **Add function to allow releasing internal EAL resources on exit**
+
+ During ``rte_eal_init()`` EAL allocates memory from hugepages to enable its
+ core libraries to perform their tasks. The ``rte_eal_cleanup()`` function
+ releases these resources, ensuring that no hugepage memory is leaked. It is
+ expected that all DPDK applications call ``rte_eal_cleanup()`` before
+ exiting. Not calling this function could result in leaking hugepages, leading
+ to failure during initialization of secondary processes.
+
* **Added the ixgbe ethernet driver to support RSS with flow API.**
Rte_flow actually defined to include RSS, but till now, RSS is out of
return fctret;
}
+int rte_eal_cleanup(void)
+{
+ rte_service_finalize();
+ return 0;
+}
+
/* get core role */
enum rte_lcore_role_t
rte_eal_lcore_role(unsigned lcore_id)
#include <rte_log.h>
#include <rte_debug.h>
#include <rte_common.h>
+#include <rte_eal.h>
#define BACKTRACE_SIZE 256
va_end(ap);
#ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR
+ if (rte_eal_cleanup() != 0)
+ RTE_LOG(CRIT, EAL,
+ "EAL could not release all resources\n");
exit(exit_code);
#else
rte_dump_stack();
*/
int rte_eal_init(int argc, char **argv);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Clean up the Environment Abstraction Layer (EAL)
+ *
+ * This function must be called to release any internal resources that EAL has
+ * allocated during rte_eal_init(). After this call, no DPDK function calls may
+ * be made. It is expected that common usage of this function is to call it
+ * just before terminating the process.
+ *
+ * @return 0 Successfully released all internal EAL resources
+ * @return -EFAULT There was an error in releasing all resources.
+ */
+int rte_eal_cleanup(void);
+
/**
* Check if a primary process is currently alive
*
return fctret;
}
+int rte_eal_cleanup(void)
+{
+ rte_service_finalize();
+ return 0;
+}
+
/* get core role */
enum rte_lcore_role_t
rte_eal_lcore_role(unsigned lcore_id)
#include <rte_log.h>
#include <rte_debug.h>
#include <rte_common.h>
+#include <rte_eal.h>
#define BACKTRACE_SIZE 256
va_end(ap);
#ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR
+ if (rte_eal_cleanup() != 0)
+ RTE_LOG(CRIT, EAL,
+ "EAL could not release all resources\n");
exit(exit_code);
#else
rte_dump_stack();
EXPERIMENTAL {
global:
+ rte_eal_cleanup;
rte_eal_devargs_insert;
rte_eal_devargs_parse;
rte_eal_devargs_remove;