From patchwork Mon Oct 18 19:37:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harman Kalra X-Patchwork-Id: 102094 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BA805A0C47; Mon, 18 Oct 2021 23:00:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8751340142; Mon, 18 Oct 2021 23:00:46 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 7518440141 for ; Mon, 18 Oct 2021 23:00:45 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19IIxYcW001386; Mon, 18 Oct 2021 14:00:42 -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=eFR22b65UBGNM3OPulA+WYmudhLiGKgICPJU4BU159I=; b=E4CFd594AEd6HG2b6QXgt2vcvo36lmKO+S4G7f0CJDbFMvsnxez3vOQkmiULtKklPMnG +PiZ3JdX7tnKczxriCAkomZzDkJqCE9zffegFiEGvOGoygd1mTuNLf1PdxydM3IOJ4/r 8EuhM9CblGumTbYrYZ+PilrDbPEfx4IHWq9RIx6nRe5WNv0aGjgEt7ENOdinqZZgfKlx m8NLCEk3bzXp7WLuFhMchA7eTr1/kQCw7LdJhC+Ou0PaXYcgmvvRYczM6wMy79LiE2hM rq84qoz05HCae9IJoDDQzEBfDTG3BbqG7VDmDCkoCNGawEJiKF9W2bEaUImY/hIFT0em mg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3bsepf8ca1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Oct 2021 14:00:42 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 18 Oct 2021 14:00:40 -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 14:00:41 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 99F3A402066; Mon, 18 Oct 2021 12:37:24 -0700 (PDT) From: Harman Kalra To: , Anatoly Burakov CC: , , , , Harman Kalra Date: Tue, 19 Oct 2021 01:07:01 +0530 Message-ID: <20211018193707.123559-2-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 X-Proofpoint-GUID: 48rCW2x4nsygfTYY2F0gdnCH89LhbUkL X-Proofpoint-ORIG-GUID: 48rCW2x4nsygfTYY2F0gdnCH89LhbUkL 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 1/7] malloc: introduce malloc is ready API 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 a new API get the state if DPDK memory management APIs are initialized. One of the use case of this API is while allocating an interrupt instance, if malloc APIs are ready memory for interrupt handles should be allocated via rte_malloc_* APIs else glibc malloc APIs are used. Eg. Alarm subsystem is initialised before DPDK memory infra setup and it allocates an interrupt handle. Signed-off-by: Harman Kalra --- lib/eal/common/malloc_heap.c | 16 +++++++++++++++- lib/eal/common/malloc_heap.h | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index ee400f38ec..4d649e3e5c 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -36,6 +36,8 @@ #define CONST_MAX(a, b) (a > b ? a : b) /* RTE_MAX is not a constant */ #define EXTERNAL_HEAP_MIN_SOCKET_ID (CONST_MAX((1 << 8), RTE_MAX_NUMA_NODES)) +static bool malloc_ready; + static unsigned check_hugepage_sz(unsigned flags, uint64_t hugepage_sz) { @@ -1328,6 +1330,7 @@ rte_eal_malloc_heap_init(void) { struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; unsigned int i; + int ret; const struct internal_config *internal_conf = eal_get_internal_configuration(); @@ -1369,5 +1372,16 @@ rte_eal_malloc_heap_init(void) return 0; /* add all IOVA-contiguous areas to the heap */ - return rte_memseg_contig_walk(malloc_add_seg, NULL); + ret = rte_memseg_contig_walk(malloc_add_seg, NULL); + + if (!ret) + malloc_ready = true; + + return ret; +} + +bool +rte_malloc_is_ready(void) +{ + return malloc_ready == true; } diff --git a/lib/eal/common/malloc_heap.h b/lib/eal/common/malloc_heap.h index 3a6ec6ecf0..f55d408492 100644 --- a/lib/eal/common/malloc_heap.h +++ b/lib/eal/common/malloc_heap.h @@ -96,4 +96,7 @@ malloc_socket_to_heap_id(unsigned int socket_id); int rte_eal_malloc_heap_init(void); +bool +rte_malloc_is_ready(void); + #endif /* MALLOC_HEAP_H_ */