[2/4] bus/pci/bsd: Map resources at EAL baseaddr
Checks
Commit Message
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 <jfree@FreeBSD.org>
---
drivers/bus/pci/bsd/pci.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
Comments
On 5/6/2025 7:40 PM, Jake Freeland wrote:
> 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 <jfree@FreeBSD.org>
> ---
I remember attempting to fix this issue by reserving some amount of
address space for PCI devices in a similar way memory subsystem reserves
its address space. This doesn't quite do that but is as good a fix as it
can get without major rework IMO.
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
@@ -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)