Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jul 2024 22:02:23 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Jake Freeland <jake@technologyfriends.net>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: FreeBSD hugepages
Message-ID:  <ZqKhP0aR0fb_f6XE@kib.kiev.ua>
In-Reply-To: <1ced4290-4a31-4218-8611-63a44c307e87@technologyfriends.net>
References:  <1ced4290-4a31-4218-8611-63a44c307e87@technologyfriends.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jul 25, 2024 at 01:46:17PM -0500, Jake Freeland wrote:
> Hi there,
> 
> I have been steadily working on bringing Data Plane Development Kit (DPDK)
> on FreeBSD up to date with the Linux version. The most significant hurdle so
> far has been supporting concurrent DPDK processes, each with their own
> contiguous memory regions.
> 
> These contiguous regions are used by DPDK as a heap for allocating DMA
> buffers and other miscellaneous resources. Retrieving the underlying memory
> and mapping these regions is currently different on Linux and FreeBSD:
> 
> On Linux, hugepages are fetched from the kernel's pre-allocated hugepage
> pool and are mapped into virtual address space on DPDK initialization. Since
> the hugepages exist in a pool, multiple processes can reserve their own
> hugepages and operate concurrently.
> 
> On FreeBSD, DPDK uses an in-house contigmem kernel module that reserves a
> large contiguous region of memory on load. During DPDK initialization, the
> entire region is mapped into virtual address space. This leaves no memory
> for another independent DPDK process, so only one process can operate at a
> time.
> 
> I could modify the DPDK contigmem module to mimic Linux's hugepages, but I
> thought it would be better to integrate and upstream a hugepage-like
> interface directly in the FreeBSD kernel source. I am writing this email to
> see if anyone has any advice on the matter. I did not see any previous
> attempts at this in Phabriactor or the commit log, but it is possible that I
> missed it. I have read about transparent superpage promotion, but that seems
> like a different mechanism altogether.
> 
> At a quick glance, the implementation seems straightforward: read some
> loader tunables, allocate persistent hugepages at boot time, and create a
> pseudo filesystem that supports creating and mapping hugepages. I could be
> underestimating the magnitude of this task, but that is why I'm asking for
> thoughts and advice :)
> 
> For reference, here is Linux's documentation on hugepages:
> https://docs.kernel.org/admin-guide/mm/hugetlbpage.html

Are posix shm largepages objects enough (they were developed to support
DPDK).  Look for shm_create_largepage(3).



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZqKhP0aR0fb_f6XE>