Provide the EAL base address as a hint to mmap(2), so device resources
are not mapped where malloc(3) et al. make allocations.

This makes mapping conflicts less likely for secondary processes that
make memory allocations before initializing EAL.

Signed-off-by: Jake Freeland <jf...@freebsd.org>
---
 drivers/bus/pci/bsd/pci.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c
index 5e2e09d5a4..0581daf130 100644
--- a/drivers/bus/pci/bsd/pci.c
+++ b/drivers/bus/pci/bsd/pci.c
@@ -182,7 +182,15 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, 
int res_idx,
 
        /* if matching map is found, then use it */
        offset = res_idx * pagesz;
-       mapaddr = pci_map_resource(NULL, fd, (off_t)offset,
+
+       /*
+        * Use baseaddr as a hint to avoid mapping resources where
+        * malloc(3) et al. usually make allocations. This reduces
+        * mapping conflicts in secondary processes that make
+        * memory allocations before initializing EAL.
+        */
+       mapaddr = pci_map_resource((void *)rte_eal_get_baseaddr(),
+                       fd, (off_t)offset,
                        (size_t)dev->mem_resource[res_idx].len, 0);
        close(fd);
        if (mapaddr == NULL)
-- 
2.47.2

Reply via email to