From nobody Sat Sep 05 04:15:18 2026 X-Original-To: dev-commits-src-main@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 4hcKkG6bq7z6qrm8 for ; Sat, 05 Sep 2026 04:15:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hcKkG4jtnz3bH3 for ; Sat, 05 Sep 2026 04:15:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788581718; 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=4cPIeHHWc6D98fdMd8AVAbnSy9PbjdDpjI9ZmmdFJ2A=; b=R7hCmgZAMyujqJ3oE678bSpxSxi7V7jS2tb0n+3855BxTUhupZ0u4OSB+w+SXnwt61g+xq r9R4qrwAnespCjeT+DyFYxbzfaPH7DInAss7e3bz49r8aOw1rkatOoat+Gi++Vo/iXmvno 98CiajQRZsopw2lHvU8J/c31Dyj1Q10vtVREdS763vpXI/N9VqzgQkogi/7mcSX+vNIUWJ fo+sJE6JkMmhdMHQVt/D/ziepYXQu4tPw2fAMrWIqe4RSqU9uaEGx064b1d0XTXW8lGKrs 7RX7LELHNCKguXgJSvkvGDvNgNQM422otA7fVZ72qtKDDUeTJkPYFAgiIrq0Pw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788581718; a=rsa-sha256; cv=none; b=SUf33Qwje3mvDOQ90JLz1MIywwKIbK4cczHL13JQxabO0qSTxcyebntTXdQXhgIsvVbkU2 RQKFfzwRO7QXqdos5kG8g5bv+tfI1zAsJJ5Q1ve2lwLMKlJcrB54SgkSlHIdwYxLyEuOvB P+2O3KTvqRE3DX2CfyUooJee2+XBuN4fSgQ6VkTzHJISfBXqLEXU+pNPaj8jXjU4ruKqra D/b/lbZi/cescniiHCYT2hfN3P+V1NTySZblKe6PN6+8tdaM1x2e8XQmuiMS+5+zOpq2SP P39+K7OafmxAVCaV/Sho9/LfT0ZTSVoE4dFlrixrZhmOCYEMQAYUkvDEXEqFWw== 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=1788581718; 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=4cPIeHHWc6D98fdMd8AVAbnSy9PbjdDpjI9ZmmdFJ2A=; b=omyz3no8z5elTX0AFi+TQ4z/FXFXwuyvrp4AzRl3H6S3aQJoNM4LByucjEOftRJuNPj/mH gD3vKS8t8oiGXuIQ8BaVKCBpckRMU4EXSOdi8EnWGLNX8Y3g9P5x7SIw4+QgJOgZdoTGcB 3SggMDuzz+ALJJf+orboBWMD0fHKmTv9w9zLWx47Z/W5kJuJ4QmiOK9ZZMYdnr13YA24Dc mSqLyZsr7ReO1Bsng9C0V2BgEAvXeR2X6+lnMkiJi8LGN//T/rS4gU2mHe84Ar0XHLdYta C2lb6rNq+Ag45KreGD61oPUGXrbb0FTomH6wL4bs/Py6Tkz8d/UyJ6IJ+ogTbA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hcKkG36qWzW0W for ; Sat, 05 Sep 2026 04:15:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3f705 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 05 Sep 2026 04:15:18 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: d8f9d3388f5d - main - powerpc/pmap(booke): Allocate 64-bit roots from DMAP List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d8f9d3388f5dfed0b426d11a1b985397c12010e8 Auto-Submitted: auto-generated Date: Sat, 05 Sep 2026 04:15:18 +0000 Message-Id: <6a9b9756.3f705.778685ec@gitrepo.freebsd.org> The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=d8f9d3388f5dfed0b426d11a1b985397c12010e8 commit d8f9d3388f5dfed0b426d11a1b985397c12010e8 Author: Justin Hibbits AuthorDate: 2026-09-04 20:44:39 +0000 Commit: Justin Hibbits CommitDate: 2026-09-05 04:11:53 +0000 powerpc/pmap(booke): Allocate 64-bit roots from DMAP When a TLB miss exception occurs the exception handler must walk the page table from the root. When the root is allocated from KVA the TLB miss exception may take another exception if the root page(s) aren't in the TLB. The 64-bit page table is modeled after the AIM radix page table, with a 64kB root "page", so 16 pages. This makes regular use of UMA allocations unable to refer back to the DMAP, which itself is mapped in TLB1. Now we take another page from the radix pmap driver and grab contiguous pages from the VM system, so that we can simply refer directly to DMAP and avoid more nested TLB misses. We can still take a nested miss, though, because the pmap itself may be in KVA, but this reduces the nesting. --- sys/powerpc/booke/pmap.c | 6 +----- sys/powerpc/booke/pmap_32.c | 4 ++++ sys/powerpc/booke/pmap_64.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c index 2872da55f1f2..280b7df7a6b4 100644 --- a/sys/powerpc/booke/pmap.c +++ b/sys/powerpc/booke/pmap.c @@ -1121,11 +1121,7 @@ mmu_booke_init(void) /* Pre-fill pvzone with initial number of pv entries. */ uma_prealloc(pvzone, PV_ENTRY_ZONE_MIN); - /* Create a UMA zone for page table roots. */ - ptbl_root_zone = uma_zcreate("pmap root", PMAP_ROOT_SIZE, - NULL, NULL, NULL, NULL, UMA_ALIGN_CACHE, UMA_ZONE_VM); - - /* Initialize ptbl allocation. */ + /* Initialize ptbl allocation, including the page table root zone. */ ptbl_init(); } diff --git a/sys/powerpc/booke/pmap_32.c b/sys/powerpc/booke/pmap_32.c index ef946194b649..6442a64bc7b0 100644 --- a/sys/powerpc/booke/pmap_32.c +++ b/sys/powerpc/booke/pmap_32.c @@ -165,6 +165,10 @@ ptbl_init(void) { int i; + /* Create the UMA zone for page table roots. */ + ptbl_root_zone = uma_zcreate("pmap root", PMAP_ROOT_SIZE, + NULL, NULL, NULL, NULL, UMA_ALIGN_CACHE, UMA_ZONE_VM); + CTR3(KTR_PMAP, "%s: s (ptbl_bufs = 0x%08x size 0x%08x)", __func__, (uint32_t)ptbl_bufs, sizeof(struct ptbl_buf) * PTBL_BUFS); CTR3(KTR_PMAP, "%s: s (ptbl_buf_pool_vabase = 0x%08x size = 0x%08x)", diff --git a/sys/powerpc/booke/pmap_64.c b/sys/powerpc/booke/pmap_64.c index 3f2db07ce931..87c2c84ba83b 100644 --- a/sys/powerpc/booke/pmap_64.c +++ b/sys/powerpc/booke/pmap_64.c @@ -177,10 +177,55 @@ mmu_booke_alloc_page(pmap_t pmap, unsigned int idx, bool nosleep) return (VM_PAGE_TO_DMAP(m)); } +/* + * Allocate PMAP roots from the DMAP, as mmu_radix does on AIM. Since DMAP is + * statically mapped in TLB1, and all other PMAP pages are taken from DMAP, we + * can avoid all TLB misses when doing page table lookups. + */ +static int +ptbl_root_import(void *arg __unused, void **store, int count, + int domain __unused, int flags) +{ + vm_page_t m; + int i, req; + + req = VM_ALLOC_WIRED | malloc2vm_flags(flags); + for (i = 0; i < count; i++) { + m = vm_page_alloc_noobj_contig(req, PMAP_ROOT_SIZE / PAGE_SIZE, + 0, ~(vm_paddr_t)0, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT); + if (m == NULL) + break; + store[i] = VM_PAGE_TO_DMAP(m); + } + return (i); +} + +static void +ptbl_root_release(void *arg __unused, void **store, int count) +{ + struct spglist free; + vm_page_t m; + int i, j; + + for (i = 0; i < count; i++) { + SLIST_INIT(&free); + m = DMAP_TO_VM_PAGE(store[i]); + for (j = PMAP_ROOT_SIZE / PAGE_SIZE - 1; j >= 0; j--) { + vm_page_unwire_noq(&m[j]); + SLIST_INSERT_HEAD(&free, &m[j], plinks.s.ss); + } + vm_page_free_pages_toq(&free, false); + } +} + /* Initialize pool of kva ptbl buffers. */ static void ptbl_init(void) { + + ptbl_root_zone = uma_zcache_create("pmap root", PMAP_ROOT_SIZE, + NULL, NULL, NULL, NULL, ptbl_root_import, ptbl_root_release, + NULL, UMA_ZONE_NOBUCKET); } /* Get a pointer to a PTE in a page table. */