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 CF806A0524; Tue, 13 Apr 2021 19:19:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D29A8161213; Tue, 13 Apr 2021 19:19:36 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id AC0021611E2 for ; Tue, 13 Apr 2021 19:19:29 +0200 (CEST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 87ED720B83DA; Tue, 13 Apr 2021 10:19:28 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 87ED720B83DA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1618334368; bh=nq/M07A/fVy32HuKjYx3jdRXTSTOMsND4LsyK6CD0zA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rCtsDr+d0TIQLt4umU/oQ1UNOK/6MVrlQ1ULsQuYMSqJLsIyUNa0B54PNFXOeDbF4 NG8iNLt+FeRR2zi8XDPWuOlDptsC6Q1kDohOqcrsJQ10YYGKP5aQ4H89c2VOEIDVBk RUQner9CP5yPRLGQB94Qn5DCoWLG8kNN7/QJ3RzY= From: Jie Zhou To: dev@dpdk.org Cc: dmitry.kozliuk@gmail.com, xiaoyun.li@intel.com, roretzla@microsoft.com, pallavi.kadam@intel.com, thomas@monjalon.net, bruce.richardson@intel.com, ferruh.yigit@intel.com Date: Tue, 13 Apr 2021 10:19:22 -0700 Message-Id: <1618334363-15147-6-git-send-email-jizh@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1618334363-15147-1-git-send-email-jizh@linux.microsoft.com> References: <1616172695-28505-1-git-send-email-jizh@linux.microsoft.com> <1618334363-15147-1-git-send-email-jizh@linux.microsoft.com> Subject: [dpdk-dev] [PATCH v3 5/6] app/testpmd: add rte_mem_lockall in librte_eal 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" In order to replace POSIX mman APIs in testpmd, add rte_mem_lockall. - On Unix, it is a wrapper of mlockall - On Windows, it is just a stub Signed-off-by: Jie Zhou Signed-off-by: Jie Zhou --- lib/librte_eal/include/rte_eal_paging.h | 20 ++++++++++++++++++++ lib/librte_eal/unix/eal_unix_memory.c | 13 +++++++++++++ lib/librte_eal/version.map | 1 + lib/librte_eal/windows/eal_memory.c | 10 ++++++++++ 4 files changed, 44 insertions(+) diff --git a/lib/librte_eal/include/rte_eal_paging.h b/lib/librte_eal/include/rte_eal_paging.h index ed98e70e9..959c2e135 100644 --- a/lib/librte_eal/include/rte_eal_paging.h +++ b/lib/librte_eal/include/rte_eal_paging.h @@ -37,6 +37,14 @@ enum rte_map_flags { RTE_MAP_FORCE_ADDRESS = 1 << 3 }; +/** Flags for memory lockall. */ +enum rte_mem_lockall_flags { + /** Lock all pages currently mapped into process's address space. */ + RTE_MCL_CURRENT = 1 << 0, + /** Lock all pages mapped into process's address space in the future.*/ + RTE_MCL_FUTURE = 1 << 1 +}; + /** * Map a portion of an opened file or the page file into memory. * @@ -96,3 +104,15 @@ rte_mem_page_size(void); __rte_internal int rte_mem_lock(const void *virt, size_t size); + +/** + * locks all pages mapped into the address space of the calling process. + * + * @param flags + * Memory lockall flags, a combination of rte_mem_lockall_flags. + * @return + * 0 on success, negative on error. + */ +__rte_internal +int +rte_mem_lockall(int flags); diff --git a/lib/librte_eal/unix/eal_unix_memory.c b/lib/librte_eal/unix/eal_unix_memory.c index ec7156df9..90e0c547a 100644 --- a/lib/librte_eal/unix/eal_unix_memory.c +++ b/lib/librte_eal/unix/eal_unix_memory.c @@ -150,3 +150,16 @@ rte_mem_lock(const void *virt, size_t size) rte_errno = errno; return ret; } + +int +rte_mem_lockall(int flags) +{ + int mlockall_flags = 0; + + if (flags & RTE_MCL_CURRENT) + mlockall_flags |= MCL_CURRENT; + if (flags & RTE_MCL_FUTURE) + mlockall_flags |= MCL_FUTURE; + + return mlockall(mlockall_flags); +} diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map index e7217ae28..8dd8333e5 100644 --- a/lib/librte_eal/version.map +++ b/lib/librte_eal/version.map @@ -431,4 +431,5 @@ INTERNAL { rte_mem_map; rte_mem_page_size; rte_mem_unmap; + rte_mem_lockall; }; diff --git a/lib/librte_eal/windows/eal_memory.c b/lib/librte_eal/windows/eal_memory.c index 2cf5a5e64..4fe7e59a1 100644 --- a/lib/librte_eal/windows/eal_memory.c +++ b/lib/librte_eal/windows/eal_memory.c @@ -715,3 +715,13 @@ rte_eal_hugepage_attach(void) EAL_LOG_NOT_IMPLEMENTED(); return -1; } + +int +rte_mem_lockall(int flags) +{ + RTE_SET_USED(flags); + + EAL_LOG_NOT_IMPLEMENTED(); + + return -1; +} -- 2.30.0.vfs.0.2