]> git.droids-corp.org - dpdk.git/commitdiff
mem: mark pages as freeable on exit
authorAnatoly Burakov <anatoly.burakov@intel.com>
Thu, 31 May 2018 16:11:47 +0000 (17:11 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 13 Jul 2018 09:06:14 +0000 (11:06 +0200)
When rte_eal_cleanup() is called, it is expected that DPDK will be able to
release all of its memory back to the system. However, if pages are marked
as unfreeable, the pages will not be released back. Fix this to mark all
pages as freeable on calling rte_eal_cleanup(), but only do it for primary
process, as secondaries can come and go.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_eal/linuxapp/eal/eal.c

index 8655b869155fc9d326026374e577f9aed5640a5a..987b57f87765c979a93ca2f73aa70c813b9b4c52 100644 (file)
@@ -1044,9 +1044,26 @@ rte_eal_init(int argc, char **argv)
        return fctret;
 }
 
+static int
+mark_freeable(const struct rte_memseg_list *msl, const struct rte_memseg *ms,
+               void *arg __rte_unused)
+{
+       /* ms is const, so find this memseg */
+       struct rte_memseg *found = rte_mem_virt2memseg(ms->addr, msl);
+
+       found->flags &= ~RTE_MEMSEG_FLAG_DO_NOT_FREE;
+
+       return 0;
+}
+
 int __rte_experimental
 rte_eal_cleanup(void)
 {
+       /* if we're in a primary process, we need to mark hugepages as freeable
+        * so that finalization can release them back to the system.
+        */
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+               rte_memseg_walk(mark_freeable, NULL);
        rte_service_finalize();
        return 0;
 }