[dpdk-dev] [PATCH v2 8/8] eal: malloc: cleanup mp resources
Stephen Hemminger
stephen at networkplumber.org
Wed Apr 29 01:14:15 CEST 2020
The mp action resources in malloc should be cleaned up via
rte_eal_cleanup.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
lib/librte_eal/common/malloc_heap.c | 6 ++++++
lib/librte_eal/common/malloc_heap.h | 3 +++
lib/librte_eal/common/malloc_mp.c | 12 ++++++++++++
lib/librte_eal/common/malloc_mp.h | 3 +++
lib/librte_eal/linux/eal.c | 1 +
5 files changed, 25 insertions(+)
diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c
index 842eb9de75a1..13c673f363a9 100644
--- a/lib/librte_eal/common/malloc_heap.c
+++ b/lib/librte_eal/common/malloc_heap.c
@@ -1362,3 +1362,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/librte_eal/common/malloc_heap.h b/lib/librte_eal/common/malloc_heap.h
index 772736b53f3c..ffad1b61e246 100644
--- a/lib/librte_eal/common/malloc_heap.h
+++ b/lib/librte_eal/common/malloc_heap.h
@@ -100,6 +100,9 @@ malloc_socket_to_heap_id(unsigned int socket_id);
int
rte_eal_malloc_heap_init(void);
+void
+rte_eal_malloc_heap_cleanup(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c
index 1f212f834993..a9a9e8a45221 100644
--- a/lib/librte_eal/common/malloc_mp.c
+++ b/lib/librte_eal/common/malloc_mp.c
@@ -749,3 +749,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/librte_eal/common/malloc_mp.h b/lib/librte_eal/common/malloc_mp.h
index 2b86b76f6848..fb3d18c4e458 100644
--- a/lib/librte_eal/common/malloc_mp.h
+++ b/lib/librte_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/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c
index ffb0678b864a..abd478c9ceb0 100644
--- a/lib/librte_eal/linux/eal.c
+++ b/lib/librte_eal/linux/eal.c
@@ -1351,6 +1351,7 @@ rte_eal_cleanup(void)
#endif
rte_eal_alarm_cleanup();
eal_mp_dev_hotplug_cleanup();
+ rte_eal_malloc_heap_cleanup();
rte_mp_channel_cleanup();
rte_trace_save();
eal_trace_fini();
--
2.20.1
More information about the dev
mailing list