From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 02276A0C47; Mon, 18 Oct 2021 22:56:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7B38410E5; Mon, 18 Oct 2021 22:56:37 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 5355A40DF5 for ; Mon, 18 Oct 2021 22:56:37 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19IK0Nkq000899; Mon, 18 Oct 2021 13:56:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=jvdbQ2muAn2Si/wnJv0HrwTlxlMhbI28R670UxlcsXI=; b=JeMDxV8mn2HBJa9TPZM+DQb46mamnVEXlXdgdrRX6f2DL3P6o981ZhVVjPsTUgj4lK0n Zj64jiz5Umy3LgxRh4bwhWLgNY7KDyIEb3l0WPgrTNfP9J6A7cGOZnOmCaFr33Gl9HM5 ziWqkIz8Y0aXuspE7Anz4HjlahYCpylD3Y5fH0GPF562ezfVTmhYN9VRKeGdavMXXFop pV7bB+ezOUeb6G4Vch94tRwPjr5IcDX4dhk3PrgPLZYnz71Gw/YJCFJ0m/t/vhn5y8Mz sgzgnJOanwBbOXyX6fUuDlvqgwBK8rBe2p9dOQsIJxozohDbe4GTEcd/wPWsXB3Jq5jR vQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3bsfk485yw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Oct 2021 13:56:35 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 18 Oct 2021 13:56:33 -0700 Received: from maili.marvell.com (10.68.76.51) by dc5-exch02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 18 Oct 2021 13:56:33 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 7B1D94020D9; Mon, 18 Oct 2021 12:38:16 -0700 (PDT) From: Harman Kalra To: , Bruce Richardson CC: , , , , Harman Kalra Date: Tue, 19 Oct 2021 01:07:07 +0530 Message-ID: <20211018193707.123559-8-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20211018193707.123559-1-hkalra@marvell.com> References: <20210826145726.102081-1-hkalra@marvell.com> <20211018193707.123559-1-hkalra@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: hXKoYTfuQcQv8xfLf6e8rJ8cIe-kfy3d X-Proofpoint-GUID: hXKoYTfuQcQv8xfLf6e8rJ8cIe-kfy3d X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-18_07,2021-10-18_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH v3 7/7] eal/alarm: introduce alarm fini routine X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Implementing alarm cleanup routine, where the memory allocated for interrupt instance can be freed. Signed-off-by: Harman Kalra --- lib/eal/common/eal_private.h | 11 +++++++++++ lib/eal/freebsd/eal.c | 1 + lib/eal/freebsd/eal_alarm.c | 7 +++++++ lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_alarm.c | 10 +++++++++- 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 86dab1f057..7fb9bc1324 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -163,6 +163,17 @@ int rte_eal_intr_init(void); */ int rte_eal_alarm_init(void); +/** + * Init alarm mechanism. This is to allow a callback be called after + * specific time. + * + * This function is private to EAL. + * + * @return + * 0 on success, negative on error + */ +void rte_eal_alarm_fini(void); + /** * Function is to check if the kernel module(like, vfio, vfio_iommu_type1, * etc.) loaded. diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 56a60f13e9..535ea687ca 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -977,6 +977,7 @@ rte_eal_cleanup(void) rte_eal_memory_detach(); rte_trace_save(); eal_trace_fini(); + rte_eal_alarm_fini(); eal_cleanup_config(internal_conf); return 0; } diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c index cd971036cd..167384e79a 100644 --- a/lib/eal/freebsd/eal_alarm.c +++ b/lib/eal/freebsd/eal_alarm.c @@ -46,6 +46,13 @@ static rte_spinlock_t alarm_list_lk = RTE_SPINLOCK_INITIALIZER; static struct rte_intr_handle *intr_handle; static void eal_alarm_callback(void *arg); +void +rte_eal_alarm_fini(void) +{ + if (intr_handle) + rte_intr_instance_free(intr_handle); +} + int rte_eal_alarm_init(void) { diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 0d0fc66668..806158f297 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1370,6 +1370,7 @@ rte_eal_cleanup(void) rte_eal_memory_detach(); rte_trace_save(); eal_trace_fini(); + rte_eal_alarm_fini(); eal_cleanup_config(internal_conf); return 0; } diff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c index cf8e2f2066..56f69d8e6d 100644 --- a/lib/eal/linux/eal_alarm.c +++ b/lib/eal/linux/eal_alarm.c @@ -58,6 +58,13 @@ static struct rte_intr_handle *intr_handle; static int handler_registered = 0; static void eal_alarm_callback(void *arg); +void +rte_eal_alarm_fini(void) +{ + if (intr_handle) + rte_intr_instance_free(intr_handle); +} + int rte_eal_alarm_init(void) { @@ -68,7 +75,8 @@ rte_eal_alarm_init(void) goto error; } - rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_ALARM); + if (rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_ALARM)) + goto error; /* create a timerfd file descriptor */ if (rte_intr_fd_set(intr_handle, -- 2.18.0