Skip to content

Perftest: use memfd for hugepage host memory#396

Open
Hong-L666 wants to merge 1 commit into
linux-rdma:masterfrom
Hong-L666:shm_fix
Open

Perftest: use memfd for hugepage host memory#396
Hong-L666 wants to merge 1 commit into
linux-rdma:masterfrom
Hong-L666:shm_fix

Conversation

@Hong-L666

@Hong-L666 Hong-L666 commented Jul 7, 2026

Copy link
Copy Markdown

Fixes #395

This changes the --use_hugepages host allocation path from SysV shm to a hugetlb memfd mapping.

The current code uses shmget(SHM_HUGETLB) for hugepage-backed host memory. That is fine for the normal path, where perftest allocates one large buffer and shares it between QPs.

With --mr_per_qp, perftest allocates one host buffer per QP. If --use_hugepages is also set, each buffer allocation creates one SysV shm segment. With a large QP count this can hit kernel.shmmni, even when the hugepage pool still has enough free pages.

Using memfd_create(MFD_HUGETLB) keeps the allocation backed by hugetlb pages, but avoids consuming one SysV shm id per buffer. The memfd is closed after mmap() succeeds, and the mapping is released with munmap().

Testing:

  • git diff --check
  • ./autogen.sh
  • ./configure
  • make

Runtime test:

Server:

ib_write_bw -d hrn5_0 -s 2 -Q 1 -q 4096 --use_hugepages --run --mr_per_qp

Client:

ib_write_bw -d hrn5_2 -s 2 -Q 1 -q 4096 --use_hugepages --run --mr_per_qp 192.168.100.1

Result:

The test passed with this patch. The same command failed before this patch
when the SysV shm segment count reached kernel.shmmni.

--use_hugepages allocates host buffers with SysV shared memory. When
--mr_per_qp is used, perftest allocates one buffer per QP, so high QP
counts can exhaust kernel.shmmni even when enough huge pages are
available.

Allocate hugetlb memory through memfd_create and mmap instead. Close the
memfd after mmap succeeds and release the mapping with munmap during
buffer cleanup.

Signed-off-by: Hong-L666 <84577812+Hong-L666@users.noreply.github.com>
@Hong-L666 Hong-L666 marked this pull request as ready for review July 8, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--use_hugepages with --mr_per_qp can exhaust kernel.shmmni

1 participant