mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git
synced 2026-04-18 06:34:27 -04:00
Update vfio_pci_bar_map() to align BAR mmaps for efficient huge page mappings. The manual mmap alignment can be removed once mmap(!MAP_FIXED) on vfio device fds improves to automatically return well-aligned addresses. Also add MADV_HUGEPAGE, which encourages the kernel to use huge pages (e.g. when /sys/kernel/mm/transparent_hugepage/enabled is set to "madvise"). Drop MAP_FILE from mmap(). It is an ignored compatibility flag. Signed-off-by: Alex Mastro <amastro@fb.com> Reviewed-by: David Matlack <dmatlack@google.com> Tested-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20260114-map-mmio-test-v3-2-44e036d95e64@fb.com Signed-off-by: Alex Williamson <alex@shazbot.org>
36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_H
|
|
#define SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_H
|
|
|
|
#include <libvfio/assert.h>
|
|
#include <libvfio/iommu.h>
|
|
#include <libvfio/iova_allocator.h>
|
|
#include <libvfio/vfio_pci_device.h>
|
|
#include <libvfio/vfio_pci_driver.h>
|
|
|
|
/*
|
|
* Return the BDF string of the device that the test should use.
|
|
*
|
|
* If a BDF string is provided by the user on the command line (as the last
|
|
* element of argv[]), then this function will return that and decrement argc
|
|
* by 1.
|
|
*
|
|
* Otherwise this function will attempt to use the environment variable
|
|
* $VFIO_SELFTESTS_BDF.
|
|
*
|
|
* If BDF cannot be determined then the test will exit with KSFT_SKIP.
|
|
*/
|
|
const char *vfio_selftests_get_bdf(int *argc, char *argv[]);
|
|
char **vfio_selftests_get_bdfs(int *argc, char *argv[], int *nr_bdfs);
|
|
|
|
/*
|
|
* Reserve virtual address space of size at an address satisfying
|
|
* (vaddr % align) == offset.
|
|
*
|
|
* Returns the reserved vaddr. The caller is responsible for unmapping
|
|
* the returned region.
|
|
*/
|
|
void *mmap_reserve(size_t size, size_t align, size_t offset);
|
|
|
|
#endif /* SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_H */
|