From nobody Sun Aug 09 23:15:59 2026 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 4hJDJx3qTNz6pFsV for ; Sun, 09 Aug 2026 23:16:01 +0000 (UTC) (envelope-from markj@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hJDJx21Vnz3Yhk; Sun, 09 Aug 2026 23:16:01 +0000 (UTC) (envelope-from markj@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786317361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UASGJEDVUhzYCiZXa/qIVYu67b6QVJF9FxbR0YRGmtc=; b=DnCHUwSVK1V22S9RB8EAhxGY4LU0n07yaOZYQApbYI98fjs5Y5QcytTwP5yq6mWcU5yFqv ZQF5YPFEyBQAIo4WIrImfFNPxNeP2Ate1rm8Oj7PhqYM66+hRHti3oXolTtcJwJfjEi4x4 haB6BP4oznVTnGZgdt+KRtqFroK0jyoghTit93Ru2Ev6VNu8Ji2TH/JJb3xanOioeXi778 eqpXtvmUpeoEpZTK3UhuJYJOBaqWLTamaTOkt2Arrj0Sq+mhh5wfth5TzYvUZlJfZtm/7r q18fLsuROGyj8Lo8i28wbpF9Pwx9WETF0rDGl9ajr2XwkDm/vnH4Yi/dxkI8uw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786317361; a=rsa-sha256; cv=none; b=xyFtsyls64n18tOm5t5w2UWqxcTrcMcKe8iyuXjoG5DqpUFiCHo1P9UR7RTbU9e0/HiK8c f4WneoWjblPNzaMKfYdg6DOyNobPrs1LDrdHHIlcJr8bGa25cC/PHi5l5diJYs++HDW7kP ZO2HGDPIZ0IHuvzK01bv4AK3aIrp1WCJbcJZVqmJId7J3n5f+8nnL0F8mlQkq2uwH8GurO 9uuqVwo4Wd0FZIDUgi58tGwXgE5m5+G2m0CoqJ+GbTatPH9kf+qB6hbSVRclR8QPRMK45v ivpEUwMluvcvk753q0pV9d801V3i6azU0LcHf36RuhfqIarWVvWEUBdH6yN6wQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786317361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UASGJEDVUhzYCiZXa/qIVYu67b6QVJF9FxbR0YRGmtc=; b=FPlwcxxjQy/ne7y+lu0udEYAll2GD7QRXgvkZKgFQLQUQ+QM/Nc3fZbylLYHORP2Kgrq2U BOFjED8nyU4JXqi1Pkljg5IeecG1PcSWZR+Jkh8nkfWrQhezzhajMqnXEbxhhfd9k4eRty 2ms1GqwGzLEXR1NzCRZmZhD55uG5FkYqGIIXnCgGvFsMHxx3iZyij/Vibx/+4kbwfZj8NQ mADlDRnLaSXtpBA6GQXBRfKHR393z4T0YjqLi5+5ZYu2hpo3mORIo5sNn7KUjJu9CLYbc5 z+AnUABhQp/AKO0N46QbIj16rvPgzAonJy06ttsKLfIkAgOOi69XGZIVFIYiaQ== Received: from nuc (192-0-220-237.cpe.teksavvy.com [192.0.220.237]) (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) (Authenticated sender: markj) by smtp.freebsd.org (Postfix) with ESMTPSA id 4hJDJw5v13zQB5; Sun, 09 Aug 2026 23:16:00 +0000 (UTC) (envelope-from markj@freebsd.org) Date: Sun, 9 Aug 2026 19:15:59 -0400 From: Mark Johnston To: Vadim Goncharov Cc: freebsd-hackers@freebsd.org Subject: Re: 5 gigs of contiguos kernel VM shared with userspace Message-ID: References: <20260810013202.1c5a16d1@nuclight.lan> 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260810013202.1c5a16d1@nuclight.lan> On Mon, Aug 10, 2026 at 01:32:02AM +0300, Vadim Goncharov wrote: > Hello, > > Are there ways to allocate in kernel a range of contiguous virtual address > space, share it with userspace, and preferably run memory allocator inside > it which has it's pointers relative to base address? Same as processes > cooperating via mmap(), but for kernel<->user. > > I'd like just run UMA inside it, but seems UMA zones cannot be told to take > from particular range, or am I missing something? On user side, jemalloc > mentions something like arenas, but seems it is too unprepared for even > mmap() between processes case (may be adapting some TLSF allocator [*] is > possible, but that's a premature question before VM one). UMA is really two fairly distinct things: a slab allocator, and a cache. UMA zones provide per-CPU and per-NUMA domain caches, and UMA kegs allocate and manage slabs. You can have a zone without a keg: if you have some collection of objects you want to allocate to consumers, you can use uma_zcache_create() to create a "cache zone" which provides the usual per-CPU etc. caches to store objects returned by a custom uz_import callback that you provide when creating the zone. For instance, if you have some static array of objects (i.e., there is no need to subdivide a slab) and just want to slap a scalable cache in front of it, uma_zcache_create() is handy. The other thing you could do is provide a custom slab allocator for the keg via uma_zone_set_allocf(). There, you provide some page allocator, and you can impose whatever constraints you want. uma_small_alloc() is used by default for page-sized slabs, and page_alloc() is used by default for multi-page slabs. Your implementation could return pages from some pre-allocated, contiguous range of memory. > Size is not necessarily gigabytes, I expect it more often to be just megabytes > (see ARB_* family of macros/functions), but in future can be. If it ever can be > turned to CoW transactional semantics (think of SQLite journal, but in memory), > it would be wonderful! > > > [*] A paper and several implementations: > http://www.gii.upv.es/tlsf/files/papers/ecrts04_tlsf.pdf > https://github.com/mattconte/tlsf > https://github.com/sysprog21/tlsf-bsd > https://github.com/rmind/tlsf > > -- > WBR, @nuclight >