From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 2A454A00BE;
	Wed, 29 Apr 2020 01:59:43 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id F0E711D6AB;
	Wed, 29 Apr 2020 01:58:54 +0200 (CEST)
Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com
 [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id AFBC01D68E
 for <dev@dpdk.org>; Wed, 29 Apr 2020 01:58:49 +0200 (CEST)
Received: by mail-pf1-f196.google.com with SMTP id 18so181002pfx.6
 for <dev@dpdk.org>; Tue, 28 Apr 2020 16:58:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20150623.gappssmtp.com; s=20150623;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=A0YsfnmAGAC8zy3k9FjyYg5Ott247hG2qGL4g4NcAAA=;
 b=TxAE6umqovqJeuqu7194zFntBQGgGdiNKeub2PR+dhesaqoidDGav6F666bKlI3G2B
 BXwNQrypdtu56jrK9Li4vqbhnte1SSe1PA0nZ+478gzEuYWbghGnFUs2Tnl/J9pHXvnD
 b+7V4rNn1tV9DTdPNskucur4ldLvrDPrzpD8gE8jiyvGw7Iys4CD7wWAaAmRWwN72gwT
 tidh3HxUqoK5oc8naQdLr5ugSgeNL0rAivwJKpeY9xE2e6YKIrIY9YSuY4RfPUTyLIao
 xF6OsKY6ZndcvKVXR5z4b1l4c9I+8OrgVOcW/8omkge2eF4jGqQqivmFRTbsExiW95Tz
 bCxA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=A0YsfnmAGAC8zy3k9FjyYg5Ott247hG2qGL4g4NcAAA=;
 b=VO+AlwkQormbaufTOLeK0xcFxx434TcMSXyhR7xjR6agF+9ALw3bpuPkSG8StYNLY2
 h5YYJMxlky6E8UCN0lcpiOPf9gLoK2keLZ5b0uzbL1YiacAiVy5r/6+bkxHP2zjXfY14
 Ym/kJBl957FhIrkyUXO+PwgJE0DAdsaIoU/S2zurSF7YDRtOlm4rJDGu2v2WdD0KjLhd
 6bNbbfsuDN5o9bpRxkYvUYxfi0tOSq6PFJUwJFQzkG48flpldlOFaDaNgwT5a13TGhbz
 k4iygXCiEhemkn3LYKTDupjRtSKIMe8FeBwA+ZfWq84HjnAh2WICQuOnwNIQpEo5MbIw
 2Ang==
X-Gm-Message-State: AGi0Pub8Z7jnQJuZb9OjMjs0nmPpdOVbP7kya8Ry5LnvldDM2Szi+9eQ
 QGvd5E8eQVvtV4WSWeSkIx/2YiuGmCu4fw==
X-Google-Smtp-Source: APiQypKDQ9+ucwI+3S8eMVZPsmyrjxXvRoa5Th3tM54k3De2CDnxU5BbdyETHrYUO4uoM3hjoFzN2Q==
X-Received: by 2002:a63:d546:: with SMTP id v6mr30272168pgi.228.1588118328416; 
 Tue, 28 Apr 2020 16:58:48 -0700 (PDT)
Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127])
 by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.46
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 28 Apr 2020 16:58:47 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
 Anatoly Burakov <anatoly.burakov@intel.com>
Date: Tue, 28 Apr 2020 16:58:27 -0700
Message-Id: <20200428235827.15383-9-stephen@networkplumber.org>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org>
References: <20200104013341.19809-1-stephen@networkplumber.org>
 <20200428235827.15383-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v3 8/8] eal: malloc: cleanup mp resources
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

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/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