From nobody Thu Jul 25 19:02:23 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WVKyQ56RPz5R5MX for ; Thu, 25 Jul 2024 19:02:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4WVKyP6TKGz59L3 for ; Thu, 25 Jul 2024 19:02:37 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 46PJ2NJ8014268; Thu, 25 Jul 2024 22:02:26 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 46PJ2NJ8014268 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 46PJ2N5M014267; Thu, 25 Jul 2024 22:02:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 25 Jul 2024 22:02:23 +0300 From: Konstantin Belousov To: Jake Freeland Cc: freebsd-hackers@freebsd.org Subject: Re: FreeBSD hugepages Message-ID: References: <1ced4290-4a31-4218-8611-63a44c307e87@technologyfriends.net> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1ced4290-4a31-4218-8611-63a44c307e87@technologyfriends.net> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4WVKyP6TKGz59L3 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).