From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
david.marchand@redhat.com, stephen@networkplumber.org,
han.li1@zte.com.cn, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v5 1/2] eal: make base address hint OS-specific
Date: Thu, 24 Oct 2019 13:36:49 +0100 [thread overview]
Message-ID: <ea8457f47a25f20f59bb1f37dcf2a1f0bf340c9d.1571920604.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <09c3f9d74e1e49aa5b3608d4bf4a773d086e83ff.1564577214.git.anatoly.burakov@intel.com>
Not all OS's follow Linux's memory layout, which may lead to
problems following the suggested common address hint absent
of a base-virtaddr flag. Make this address hint OS-specific.
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
Notes:
v5:
- Add ULL suffix as per Stephen's comment
lib/librte_eal/common/eal_common_memory.c | 19 +------------------
lib/librte_eal/common/eal_private.h | 6 ++++++
lib/librte_eal/freebsd/eal/eal_memory.c | 10 ++++++++++
lib/librte_eal/linux/eal/eal_memory.c | 20 ++++++++++++++++++++
4 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 19ea47570b..4a9cc1f19a 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -40,23 +40,6 @@
static void *next_baseaddr;
static uint64_t system_page_sz;
-#ifdef RTE_ARCH_64
-/*
- * Linux kernel uses a really high address as starting address for serving
- * mmaps calls. If there exists addressing limitations and IOVA mode is VA,
- * this starting address is likely too high for those devices. However, it
- * is possible to use a lower address in the process virtual address space
- * as with 64 bits there is a lot of available space.
- *
- * Current known limitations are 39 or 40 bits. Setting the starting address
- * at 4GB implies there are 508GB or 1020GB for mapping the available
- * hugepages. This is likely enough for most systems, although a device with
- * addressing limitations should call rte_mem_check_dma_mask for ensuring all
- * memory is within supported range.
- */
-static uint64_t baseaddr = 0x100000000;
-#endif
-
#define MAX_MMAP_WITH_DEFINED_ADDR_TRIES 5
void *
eal_get_virtual_area(void *requested_addr, size_t *size,
@@ -85,7 +68,7 @@ eal_get_virtual_area(void *requested_addr, size_t *size,
#ifdef RTE_ARCH_64
if (next_baseaddr == NULL && internal_config.base_virtaddr == 0 &&
rte_eal_process_type() == RTE_PROC_PRIMARY)
- next_baseaddr = (void *) baseaddr;
+ next_baseaddr = (void *) eal_get_baseaddr();
#endif
if (requested_addr == NULL && next_baseaddr != NULL) {
requested_addr = next_baseaddr;
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 798ede553b..31eae22787 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -381,4 +381,10 @@ rte_option_init(void);
void
rte_option_usage(void);
+/**
+ * Get OS-specific EAL mapping base address.
+ */
+uint64_t
+eal_get_baseaddr(void);
+
#endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/librte_eal/freebsd/eal/eal_memory.c b/lib/librte_eal/freebsd/eal/eal_memory.c
index cd31827c2b..98d65fde0a 100644
--- a/lib/librte_eal/freebsd/eal/eal_memory.c
+++ b/lib/librte_eal/freebsd/eal/eal_memory.c
@@ -21,6 +21,16 @@
#define EAL_PAGE_SIZE (sysconf(_SC_PAGESIZE))
+uint64_t eal_get_baseaddr(void)
+{
+ /*
+ * FreeBSD may allocate something in the space we will be mapping things
+ * before we get a chance to do that, so use a base address that's far
+ * away from where malloc() et al usually map things.
+ */
+ return 0x1000000000ULL;
+}
+
/*
* Get physical address of any mapped virtual address in the current process.
*/
diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c
index 8f62c343d6..fa598b21a4 100644
--- a/lib/librte_eal/linux/eal/eal_memory.c
+++ b/lib/librte_eal/linux/eal/eal_memory.c
@@ -69,6 +69,26 @@ static int phys_addrs_available = -1;
#define RANDOMIZE_VA_SPACE_FILE "/proc/sys/kernel/randomize_va_space"
+uint64_t eal_get_baseaddr(void)
+{
+ /*
+ * Linux kernel uses a really high address as starting address for
+ * serving mmaps calls. If there exists addressing limitations and IOVA
+ * mode is VA, this starting address is likely too high for those
+ * devices. However, it is possible to use a lower address in the
+ * process virtual address space as with 64 bits there is a lot of
+ * available space.
+ *
+ * Current known limitations are 39 or 40 bits. Setting the starting
+ * address at 4GB implies there are 508GB or 1020GB for mapping the
+ * available hugepages. This is likely enough for most systems, although
+ * a device with addressing limitations should call
+ * rte_mem_check_dma_mask for ensuring all memory is within supported
+ * range.
+ */
+ return 0x100000000ULL;
+}
+
/*
* Get physical address of any mapped virtual address in the current process.
*/
--
2.17.1
next prev parent reply other threads:[~2019-10-24 12:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 12:42 [dpdk-dev] [PATCH " Anatoly Burakov
2019-07-29 11:10 ` Anatoly Burakov
2019-07-29 11:18 ` Anatoly Burakov
2019-07-29 12:42 ` [dpdk-dev] [PATCH 2/2] eal: use base address hint to reserve space for mem config Anatoly Burakov
2019-07-29 11:10 ` Anatoly Burakov
2019-07-29 11:18 ` Anatoly Burakov
2019-07-29 13:13 ` Burakov, Anatoly
2019-07-30 15:37 ` [dpdk-dev] [PATCH v2 1/2] eal: make base address hint OS-specific Anatoly Burakov
2019-07-30 15:51 ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2019-07-31 12:47 ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2019-10-02 11:41 ` David Marchand
2019-10-02 14:42 ` Stephen Hemminger
2019-10-24 12:32 ` Burakov, Anatoly
2019-10-24 12:32 ` Burakov, Anatoly
2019-10-24 12:36 ` Anatoly Burakov [this message]
2019-10-26 16:02 ` [dpdk-dev] [dpdk-stable] [PATCH v5 " David Marchand
2019-10-24 12:36 ` [dpdk-dev] [PATCH v5 2/2] eal: use base address hint to reserve space for mem config Anatoly Burakov
2019-10-26 16:02 ` [dpdk-dev] [dpdk-stable] " David Marchand
2019-07-31 12:47 ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2019-07-30 15:51 ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2019-07-30 15:37 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea8457f47a25f20f59bb1f37dcf2a1f0bf340c9d.1571920604.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=han.li1@zte.com.cn \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).