Article View: muc.lists.freebsd.bugs
Article #816[Bug 301207] uma(9): item_domain() evaluates vtophys() before vm_phys_domain() checks vm_ndomains, so every FIRSTTOUCH free call...
From: bugzilla-noreply
Date: Fri, 27 Nov 2026 23:29
Date: Fri, 27 Nov 2026 23:29
93 lines
5669 bytes
5669 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301207
Bug ID: 301207
Summary: uma(9): item_domain() evaluates vtophys() before
vm_phys_domain() checks vm_ndomains, so every
FIRSTTOUCH free calls pmap_kextract() on single-domain
systems
Product: Base System
Version: 16.0-CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: laamalif@proton.me
With options NUMA enabled in GENERIC, keg_ctor() sets
UMA_ZONE_FIRSTTOUCH on standard zones, so cache_free_reuse() and
cache_free_defer() in sys/vm/uma_core.c (main 2534dcb233ad) call
item_domain(item) on every per-CPU cache free:
static int
item_domain(void *item)
{
int domain;
domain = vm_phys_domain(vtophys(item));
Since commit 431fb8abd794 made vm_phys_domain() in sys/vm/vm_phys.h an
inline function beginning with:
if (vm_ndomains == 1)
return (0);
C still evaluates the argument vtophys(item) (out-of-line
pmap_kextract()) before entering vm_phys_domain(). On single-domain
systems (vm.ndomains=1), every uma_zfree_arg() and uma_zfree_smr() on a
FIRSTTOUCH zone calls pmap_kextract() (walking kernel page tables for
multipage KVA slabs) and discards the returned physical address.
On FreeBSD 16.0-CURRENT amd64 GENERIC-NODEBUG (main 2534dcb233ad, Xeon
6975P-C, vm.ndomains=1), counting non-DMAP pmap_kextract() calls during
6000 zero-length 256-iovec writev() calls to /dev/null (5000 warmup +
1000 timed, freeing 4144-byte uio buffers from malloc-8192) shows half
of all pmap_kextract() calls (the 6000 calls from uma_zfree_arg(), plus
1 from fdescfree(), leaving only the 6000 from free() -> vtozoneslab())
disappearing:
cc -O2 -Wall -Wextra -Werror -o uma_free_churn uma_free_churn.c
dtrace -x nolibs -qn 'fbt::pmap_kextract:entry /pid == $target/ { @ = count();
}' -c './uma_free_churn writev 1000'
Unmodified GENERIC-NODEBUG: 12001
Patched GENERIC-NODEBUG: 6002
Across 10 runs of 500000 writev() calls (ns/call):
x base_writev.txt
+ patched_writev.txt
+--------------------------------------------------------------------------+
|+ + + + + + x+ * x * x x+ xx x x|
| |___________M_____A______________|__|________M_A____________| |
+--------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 10 445.46 451.15 447.72 447.946 1.8136348
+ 10 441.56 448.35 443.395 444.236 2.3725945
Difference at 95.0% confidence
-3.71 +/- 1.98414
-0.828225% +/- 0.441591%
(Student's t, pooled s = 2.11169)
On 1-page DMAP frees (2000000 __getcwd() calls on NAMEI, N=10), mean
latency moves from 91.78 ns to 91.38 ns (-0.44% +/- 0.10% at 95%
confidence), and debug GENERIC (INVARIANTS and WITNESS, including the
uma_zalloc_domain() KASSERT) boots and runs cleanly.
Checking vm_ndomains == 1 at the top of item_domain() returns 0 before
evaluating vtophys(item).
Tested on 16.0-CURRENT amd64 with vm.ndomains=1; I have not tested a
multi-domain (vm.ndomains > 1) NUMA machine or arm64.
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<bug-301207-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: bugzilla-noreply@freebsd.org Newsgroups: muc.lists.freebsd.bugs Subject: [Bug 301207] uma(9): item_domain() evaluates vtophys() before vm_phys_domain() checks vm_ndomains, so every FIRSTTOUCH free calls pmap_kextract() on single-domain systems Date: Fri, 27 Nov 2026 23:29:56 +0000 Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <bug-301207-227@https.bugs.freebsd.org/bugzilla/> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="81425"; mail-complaints-to="news-admin@muc.de" X-Original-To: bugs@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795822196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4ntW2BrikKjseZ/FjejBRU7x7yRj3XvaML16AWeouHQ=; b=qzswqAafc3nHpAhxQgDTFHppc5p+VBtuzVu+VRaNBBOUXvZl5iQYVz/QPiqDjYyQo5pAsX kSzVAfcnq9Lxtv14aLt4WV4XusPFXyd5tkC37gmEI+XEDHOUNGkRJP13Kfi0VMnnzsjJ+i +vp0MLEL4unbErGKvU7yoVCTA8rWy+erhuf0NBYrcstZOq1OoZwlUr3ocfGmY3vYtUdBjA 0IIL7c5U3+FBp21HBNnubc+j84KWAB/8kSpsIlyMlrjQivK6JfISeDAtDw+D0sPL+D3uAI /HpZ4L+wpPhXy8cq7Y8r9vOtyp+gtClogSooWP8zo7CMShuseZTKDNzixgOeCQ== X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Auto-Submitted: auto-generated Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes