Skip to contentSkip to conversation

Access to "vma_kernel_pagesize" from user-space

DISCUSSION Gerd Rausch 1 participant 1 message Nov 14, 2022 Memory management

lore
Share & tools
lore
#0 lore raw

Hi,

I'm hoping this is the right forum to ask the following question:

libibverbs uses "madvise(MADV_DONTFORK)" on memory that was previously registered with "ib_reg_mr".

With hugetlb support (environment variable "RDMAV_HUGEPAGES_SAFE" set), libibverbs parses "/proc/self/smaps" looking for the virtual-address in question to determine the proper page-size,
ultimately calling "vma_kernel_pagesize" -> "hugetlb_vm_op_pagesize".

Obviously, parsing "/proc/self/smaps" is rather slow with large processes that contain many VMAs.

Question is: How to make this faster?

One InfiniBand-specific way out is to create a sysfs entry, e.g. "/sys/class/infiniband_verbs/vma_pagesize"
and provide an interface (e.g. ioctl) that gives libiverbs the same information, just a tad faster than parsing "/proc/self/smaps".

But getting access to "vma_kernel_pagesize" is something that is hardly InfiniBand specific, and perhaps there are other applications/libraries out there (if not today, perhaps tomorrow) that would like to do the same.

A generic interface from user-space to "vma_kernel_pagesize" (other than parsing /proc/self/smaps) could have potential benefit.

But which API exactly?

For that I'm seeking input from this forum.

Thanks,

Gerd