diff mbox series

[v6,5/5] eal: malloc: cleanup mp resources

Message ID 20211113172257.6543-6-stephen@networkplumber.org (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers show
Series cleanup more resources on eal_cleanup | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Nov. 13, 2021, 5:22 p.m. UTC
The mp action resources in malloc should be cleaned up via
rte_eal_cleanup.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/eal/common/malloc_heap.c |  6 ++++++
 lib/eal/common/malloc_heap.h |  3 +++
 lib/eal/common/malloc_mp.c   | 12 ++++++++++++
 lib/eal/common/malloc_mp.h   |  3 +++
 lib/eal/linux/eal.c          |  1 +
 lib/eal/windows/eal_mp.c     |  7 +++++++
 6 files changed, 32 insertions(+)
diff mbox series

Patch

diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index 55aad2711b39..666f770fbf6d 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -1403,3 +1403,9 @@  rte_eal_malloc_heap_init(void)
 	/* add all IOVA-contiguous areas to the heap */
 	return rte_memseg_contig_walk(malloc_add_seg, NULL);
 }
+
+void
+rte_eal_malloc_heap_cleanup(void)
+{
+	unregister_mp_requests();
+}
diff --git a/lib/eal/common/malloc_heap.h b/lib/eal/common/malloc_heap.h
index 3a29d024b4ca..3b2fbc0aa059 100644
--- a/lib/eal/common/malloc_heap.h
+++ b/lib/eal/common/malloc_heap.h
@@ -85,4 +85,7 @@  malloc_socket_to_heap_id(unsigned int socket_id);
 int
 rte_eal_malloc_heap_init(void);
 
+void
+rte_eal_malloc_heap_cleanup(void);
+
 #endif /* MALLOC_HEAP_H_ */
diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c
index 2e597a17a2f2..5f6f275b7859 100644
--- a/lib/eal/common/malloc_mp.c
+++ b/lib/eal/common/malloc_mp.c
@@ -806,3 +806,15 @@  register_mp_requests(void)
 	}
 	return 0;
 }
+
+void
+unregister_mp_requests(void)
+{
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		rte_mp_action_unregister(MP_ACTION_REQUEST);
+	} else {
+		rte_mp_action_unregister(MP_ACTION_SYNC);
+		rte_mp_action_unregister(MP_ACTION_ROLLBACK);
+		rte_mp_action_unregister(MP_ACTION_RESPONSE);
+	}
+}
diff --git a/lib/eal/common/malloc_mp.h b/lib/eal/common/malloc_mp.h
index 0095062b72f2..c806f7beafe0 100644
--- a/lib/eal/common/malloc_mp.h
+++ b/lib/eal/common/malloc_mp.h
@@ -63,6 +63,9 @@  struct malloc_mp_req {
 int
 register_mp_requests(void);
 
+void
+unregister_mp_requests(void);
+
 int
 request_to_primary(struct malloc_mp_req *req);
 
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 1a13a3474e38..ea663fe02b93 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1371,6 +1371,7 @@  rte_eal_cleanup(void)
 	/* after this point, any DPDK pointers will become dangling */
 	rte_eal_memory_detach();
 	eal_mp_dev_hotplug_cleanup();
+	rte_eal_malloc_heap_cleanup();
 	rte_eal_alarm_cleanup();
 	rte_trace_save();
 	eal_trace_fini();
diff --git a/lib/eal/windows/eal_mp.c b/lib/eal/windows/eal_mp.c
index f2fa9366f668..76413f49a393 100644
--- a/lib/eal/windows/eal_mp.c
+++ b/lib/eal/windows/eal_mp.c
@@ -87,6 +87,13 @@  register_mp_requests(void)
 	return 0;
 }
 
+void
+unregister_mp_requests(void)
+{
+	/* Non-stub function succeeds if multi-process is not supported. */
+	EAL_LOG_STUB();
+}
+
 int
 request_to_primary(struct malloc_mp_req *req)
 {