From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 9B69341C89;
	Mon, 13 Feb 2023 15:11:46 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 0D0D242D13;
	Mon, 13 Feb 2023 15:11:34 +0100 (CET)
Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com
 [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id EC8F6400D5
 for <dev@dpdk.org>; Thu,  9 Feb 2023 13:09:39 +0100 (CET)
Received: by mail-pj1-f44.google.com with SMTP id
 v6-20020a17090ad58600b00229eec90a7fso6209060pju.0
 for <dev@dpdk.org>; Thu, 09 Feb 2023 04:09:39 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=bytedance-com.20210112.gappssmtp.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=UNxD2hn4Q4bpmR7GjeMZFPTOz2aG+2+tnDuwTdtyOE4=;
 b=2wktfxZNv/dywOlURoY5TzKY/HZ+xG16ar2UI3cLSEJToYhWGAqEWz+li9oU+5YkDG
 fm6BE7tSEWB7Q7AYwKwB9v+65PQpoN4DJ+MyI6EAuppAae6Xm4NxoXJu20ZsmyacG1G+
 KTlxYn3/U5Wp0YItBBzG22kS87vmFuV9/PJU5kdBovocaldTM2U1ZWcNdwgIdhNaFrs7
 MIyqux8gqrrIiYTs7dTeYsH4TRKNb8uDYAUAqA0rNNPUzcDihfyPHXd/TSyqkWWqu/iQ
 Irdx4DLMNNL/LJFM3QieSlDDVLUjY3v7yFWOLHwHUcJeZivVmCgk7kFRSuaiDxHtfkcq
 eikQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=UNxD2hn4Q4bpmR7GjeMZFPTOz2aG+2+tnDuwTdtyOE4=;
 b=D5QCL69iSqWK5/7jPV66KajKy5Ckfxk35VIuRh5nwAS91yVN/adPifpy8IWvQ1M3A5
 IwuORFEN+Qoj3DjAQYoNk5+vKde8lHlEMvM16sBalhXetyQftCZ2sW0Mb40k757LUnHV
 DuaXwI0V6s5PuVF9nPZ6lke6eXHMbIibT3gLS23V7s+tY4fa4UGNIAUmA8lQ9PBVfu7V
 uUNHdmX4P4LxzBUyIDuMMzvL4WDADMoj0CbIfcrR0PcJe1/5SaY8v0QEOK93Ps2H9Zwe
 CJcKJ0GFUJD6wVkuIy5vGk0ivLJZSrNZkm7q69jQ6DAA9z/v8FLbz7sHajheN+FH0HbM
 ODrg==
X-Gm-Message-State: AO0yUKXfq2Y37c4ZbV/C0wJYe2YsVqx+gSU3FqLVCCj4suBMmu74JHY4
 fO3icld0jfHmb1IkNkBf5M3U8A==
X-Google-Smtp-Source: AK7set8fq9+u5tCkkyLWqJpB3faI6r4TJEFrv+SGX8NPhrKFUXkVEJnhfnm9KfmZwugl6MqeA1NOmg==
X-Received: by 2002:a17:903:1107:b0:196:3f5a:b4f9 with SMTP id
 n7-20020a170903110700b001963f5ab4f9mr11547006plh.1.1675944579164; 
 Thu, 09 Feb 2023 04:09:39 -0800 (PST)
Received: from HTW5T2C6VL.bytedance.net ([139.177.225.231])
 by smtp.gmail.com with ESMTPSA id
 q10-20020a170902bd8a00b00199199bc82esm1307619pls.235.2023.02.09.04.09.35
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Thu, 09 Feb 2023 04:09:38 -0800 (PST)
From: Fengnan Chang <changfengnan@bytedance.com>
To: thomas@monjalon.net,
	david.marchand@redhat.com
Cc: dev@dpdk.org,
	Fengnan Chang <changfengnan@bytedance.com>
Subject: [PATCH v2] eal: cleanup alarm and multiprocess hotplug before memory
 detach
Date: Thu,  9 Feb 2023 20:09:30 +0800
Message-Id: <20230209120930.78558-1-changfengnan@bytedance.com>
X-Mailer: git-send-email 2.37.0 (Apple Git-136)
In-Reply-To: <20221213075938.36964-1-changfengnan@bytedance.com>
References: <20221213075938.36964-1-changfengnan@bytedance.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Mailman-Approved-At: Mon, 13 Feb 2023 15:11:29 +0100
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
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

Alarm and multiprocess hotplug still need access hugepage memory,
if alarm event processed after memory detach, it may cause SEGV.
So cleanup alarm and multiprocess hotplug before memory detach.

Fixes: 90b13ab8d4f7 ("alarm: remove direct access to interrupt handle")
Fixes: a0cc7be20dd1 ("mem: cleanup multiprocess resources")

Signed-off-by: Fengnan Chang <changfengnan@bytedance.com>
---
 lib/eal/freebsd/eal.c | 2 +-
 lib/eal/linux/eal.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 1b58cd3da6..83b99c601f 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -897,9 +897,9 @@ rte_eal_cleanup(void)
 	eal_bus_cleanup();
 	rte_trace_save();
 	eal_trace_fini();
+	rte_eal_alarm_cleanup();
 	/* after this point, any DPDK pointers will become dangling */
 	rte_eal_memory_detach();
-	rte_eal_alarm_cleanup();
 	eal_cleanup_config(internal_conf);
 	return 0;
 }
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 8c118d0d9f..c76f026023 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1372,11 +1372,11 @@ rte_eal_cleanup(void)
 	eal_bus_cleanup();
 	rte_trace_save();
 	eal_trace_fini();
+	eal_mp_dev_hotplug_cleanup();
+	rte_eal_alarm_cleanup();
 	/* 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();
 	eal_cleanup_config(internal_conf);
 	rte_eal_log_cleanup();
 	return 0;
-- 
2.37.0 (Apple Git-136)